forked from tTh/FloatImg
90 lines
1.8 KiB
C
90 lines
1.8 KiB
C
/*
|
|
* tests pour capturer les webcams
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <math.h>
|
|
#include <string.h>
|
|
|
|
#include <linux/videodev2.h>
|
|
|
|
#include "funcs.h"
|
|
#include "../floatimg.h"
|
|
|
|
#include "v4l2_pr_structs.h"
|
|
|
|
|
|
int verbosity;
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
int essai(char *dev, int k)
|
|
{
|
|
int vfd, foo;
|
|
struct v4l2_format fmt;
|
|
|
|
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, dev, k);
|
|
|
|
vfd = open_device(dev);
|
|
fprintf(stderr, "\topen %s -> %d\n", dev, vfd);
|
|
|
|
memset(&fmt, 0, sizeof(fmt));
|
|
pr_v4l2_format("after 0", &fmt);
|
|
|
|
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
fmt.fmt.pix.width = 640;
|
|
fmt.fmt.pix.height = 480;
|
|
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24;
|
|
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
|
|
|
|
pr_v4l2_format("before ioctl", &fmt);
|
|
|
|
|
|
return k;
|
|
}
|
|
/* --------------------------------------------------------------------- */
|
|
int liste_des_devices(int K)
|
|
{
|
|
fprintf(stderr, "%s not implemented\n", __func__);
|
|
return -1;
|
|
}
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
void help(int k)
|
|
{
|
|
puts("Options :");
|
|
puts("\t-d\tselect the video device");
|
|
puts("\t-K\tset the K parameter");
|
|
puts("\t-l\tlist video devices");
|
|
puts("\t-v\tincrease verbosity");
|
|
exit(0);
|
|
}
|
|
/* --------------------------------------------------------------------- */
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int foo, opt;
|
|
|
|
char *device = "/dev/video0";
|
|
int K = 0;
|
|
|
|
while ((opt = getopt(argc, argv, "d:hK:v")) != -1) {
|
|
switch(opt) {
|
|
case 'd': device = optarg; break;
|
|
case 'h': help(0); break;
|
|
case 'K': K = atol(optarg); break;
|
|
case 'v': verbosity++; break;
|
|
}
|
|
}
|
|
|
|
if (verbosity) fimg_print_version(0);
|
|
|
|
foo = essai(device, K);
|
|
fprintf(stderr, "\tessai -> %d\n", foo);
|
|
|
|
return 0;
|
|
}
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|