size of capture is now an option
This commit is contained in:
		
							parent
							
								
									7abdf7b43e
								
							
						
					
					
						commit
						d65b93fc66
					
				@ -36,9 +36,6 @@
 | 
				
			|||||||
#define SAVE_AS_PNM	0
 | 
					#define SAVE_AS_PNM	0
 | 
				
			||||||
#define SAVE_AS_FIMG	0
 | 
					#define SAVE_AS_FIMG	0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define		WIDTH		1920
 | 
					 | 
				
			||||||
#define		HEIGHT		1080
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* --------------------------------------------------------------------- */
 | 
					/* --------------------------------------------------------------------- */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CLEAR(x) memset(&(x), 0, sizeof(x))
 | 
					#define CLEAR(x) memset(&(x), 0, sizeof(x))
 | 
				
			||||||
@ -78,6 +75,7 @@ puts("\t-n NNN\t\thow many frames ?");
 | 
				
			|||||||
puts("\t-O ./\t\tset Output dir");
 | 
					puts("\t-O ./\t\tset Output dir");
 | 
				
			||||||
puts("\t-o bla\t\tset output filename");
 | 
					puts("\t-o bla\t\tset output filename");
 | 
				
			||||||
puts("\t-p NNN\t\tperiod in seconds");
 | 
					puts("\t-p NNN\t\tperiod in seconds");
 | 
				
			||||||
 | 
					puts("\t-s WxH\t\tsize of capture");
 | 
				
			||||||
puts("\t-v\t\tincrease verbosity");
 | 
					puts("\t-v\t\tincrease verbosity");
 | 
				
			||||||
exit(0);
 | 
					exit(0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -102,6 +100,8 @@ int		foo, bar;
 | 
				
			|||||||
double		period = 10.0;		/* delai entre les captures */
 | 
					double		period = 10.0;		/* delai entre les captures */
 | 
				
			||||||
int		nbre_capt = 1;		/* nombre de captures */
 | 
					int		nbre_capt = 1;		/* nombre de captures */
 | 
				
			||||||
int		opt;
 | 
					int		opt;
 | 
				
			||||||
 | 
					int		width = 640;
 | 
				
			||||||
 | 
					int		height = 480;
 | 
				
			||||||
double		t_final;
 | 
					double		t_final;
 | 
				
			||||||
char		*dest_dir = ".";	/* no trailing slash */
 | 
					char		*dest_dir = ".";	/* no trailing slash */
 | 
				
			||||||
char		*outfile = "out.pnm";
 | 
					char		*outfile = "out.pnm";
 | 
				
			||||||
@ -110,7 +110,7 @@ char		*outfile = "out.pnm";
 | 
				
			|||||||
FloatImg	grab, cumul;
 | 
					FloatImg	grab, cumul;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
while ((opt = getopt(argc, argv, "d:hn:o:O:p:v")) != -1) {
 | 
					while ((opt = getopt(argc, argv, "d:hn:o:O:p:s:v")) != -1) {
 | 
				
			||||||
	switch(opt) {
 | 
						switch(opt) {
 | 
				
			||||||
		case 'd':	dev_name = optarg;		break;
 | 
							case 'd':	dev_name = optarg;		break;
 | 
				
			||||||
		case 'h':	help(0);			break;
 | 
							case 'h':	help(0);			break;
 | 
				
			||||||
@ -118,6 +118,7 @@ while ((opt = getopt(argc, argv, "d:hn:o:O:p:v")) != -1) {
 | 
				
			|||||||
		case 'O':	dest_dir = optarg;		break;
 | 
							case 'O':	dest_dir = optarg;		break;
 | 
				
			||||||
		case 'o':	outfile = optarg;		break;
 | 
							case 'o':	outfile = optarg;		break;
 | 
				
			||||||
		case 'p':	period = 1e6*atof(optarg);	break;
 | 
							case 'p':	period = 1e6*atof(optarg);	break;
 | 
				
			||||||
 | 
							case 's':	parse_WxH(optarg, &width, &height);	break;
 | 
				
			||||||
		case 'v':	verbosity++;			break;
 | 
							case 'v':	verbosity++;			break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -125,6 +126,7 @@ while ((opt = getopt(argc, argv, "d:hn:o:O:p:v")) != -1) {
 | 
				
			|||||||
if (verbosity) {
 | 
					if (verbosity) {
 | 
				
			||||||
	fprintf(stderr, "running %s  pid=%d\n", argv[0], getpid());
 | 
						fprintf(stderr, "running %s  pid=%d\n", argv[0], getpid());
 | 
				
			||||||
	fprintf(stderr, "period is %.3f microseconds\n", period);
 | 
						fprintf(stderr, "period is %.3f microseconds\n", period);
 | 
				
			||||||
 | 
						fprintf(stderr, "framesize is %dx%d\n", width, height);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fd = v4l2_open(dev_name, O_RDWR | O_NONBLOCK, 0);
 | 
					fd = v4l2_open(dev_name, O_RDWR | O_NONBLOCK, 0);
 | 
				
			||||||
@ -135,8 +137,8 @@ if (fd < 0) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
CLEAR(fmt);
 | 
					CLEAR(fmt);
 | 
				
			||||||
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 | 
					fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 | 
				
			||||||
fmt.fmt.pix.width       = WIDTH;
 | 
					fmt.fmt.pix.width       = width;
 | 
				
			||||||
fmt.fmt.pix.height      = HEIGHT;
 | 
					fmt.fmt.pix.height      = height;
 | 
				
			||||||
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24;
 | 
					fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24;
 | 
				
			||||||
fmt.fmt.pix.field       = V4L2_FIELD_INTERLACED;
 | 
					fmt.fmt.pix.field       = V4L2_FIELD_INTERLACED;
 | 
				
			||||||
xioctl(fd, VIDIOC_S_FMT, &fmt);
 | 
					xioctl(fd, VIDIOC_S_FMT, &fmt);
 | 
				
			||||||
@ -144,7 +146,7 @@ if (fmt.fmt.pix.pixelformat != V4L2_PIX_FMT_RGB24) {
 | 
				
			|||||||
	printf("Libv4l didn't accept RGB24 format. Can't proceed.\n");
 | 
						printf("Libv4l didn't accept RGB24 format. Can't proceed.\n");
 | 
				
			||||||
	exit(EXIT_FAILURE);
 | 
						exit(EXIT_FAILURE);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
if ((fmt.fmt.pix.width != WIDTH) || (fmt.fmt.pix.height != HEIGHT)) {
 | 
					if ((fmt.fmt.pix.width != width) || (fmt.fmt.pix.height != height)) {
 | 
				
			||||||
	printf("Warning: driver is sending image at %dx%d\n",
 | 
						printf("Warning: driver is sending image at %dx%d\n",
 | 
				
			||||||
			    fmt.fmt.pix.width, fmt.fmt.pix.height);
 | 
								    fmt.fmt.pix.width, fmt.fmt.pix.height);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user