Cédric Hi, Could you pleaser try the following function, you will have to make the necessary adaptations to your code.
int set_format(int fd, int formatIn, int width, int height, int fps) { struct v4l2_format fmt; struct v4l2_streamparm streamparm; int ret=0; // set format fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; fmt.fmt.pix.width = width; fmt.fmt.pix.height = height; fmt.fmt.pix.pixelformat = formatIn; fmt.fmt.pix.field = V4L2_FIELD_ANY; ret = ioctl(fd, VIDIOC_S_FMT, &fmt); if (ret < 0) { fprintf(stderr, "VIDIOC_S_FORMAT - Unable to set format\n"); return (-1); } if ((fmt.fmt.pix.width != width) || (fmt.fmt.pix.height != height)) { fprintf(stderr, "Requested Format unavailable: get width %d height %d \n", fmt.fmt.pix.width, fmt.fmt.pix.height); return(-2); } streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; streamparm.parm.capture.timeperframe.numerator = 1; streamparm.parm.capture.timeperframe.denominator = fps; ret = ioctl(fd,VIDIOC_S_PARM, &streamparm); if (ret < 0) { fprintf(stderr, "VIDIOC_S_PARM error\n"); return (-3); } return (0); } Best regards, Paulo lesc...@esiee.fr escreveu: > Hi, > > This is my problem, I don't have any errors. V4L2 API says that when you > ask for a Width and Heigth, the driver will give you the max ones below > the values you asked for. Meaning if you ask for 817x616, it will set > 800x600 without returning any errors. > > > My DMESG (no pb, I have got my "/dev/video0"): > > usb 1-2: new full speed USB device using ohci_hcd and address 3 > usb 1-2: configuration #1 chosen from 1 choice > uvcvideo: Found UVC 1.00 device <unnamed> (046d:0991) > input: UVC Camera (046d:0991) as > /devices/pci0000:00/0000:00:02.2/usb1/1-2/1-2:1.0/input/input9 > > > An extract of my code, taken from the web (Capture.c): > > CLEAR (fmt); > > fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; > if (-1 == xioctl (fd, VIDIOC_G_FMT, &fmt)) > errno_exit ("VIDIOC_G_FMT"); > > fmt.fmt.pix.width = WB_FRAME_WIDTH; // 800 > fmt.fmt.pix.height = WB_FRAME_HEIGHT; // 600 > fmt.fmt.pix.pixelformat = WB_COLOR_FORMAT; // YUYV which is perfect for me > fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; > > // Note VIDIOC_S_FMT may change width and height > // So I check the *new* values > > fprintf (stderr, > "width: %d\n" > "height: %d\n", > fmt.fmt.pix.width, > fmt.fmt.pix.height); > > > It prints 176 by 144! What am I doing wrong? > (later, I check the buffer size allocated via MMAP: 50688 => 176 x 144 x 2) > > Any ideas? Where could be the problem? > > Regards, > > > Cédric Lescop > > > > On Wed, March 18, 2009 13:52, Laurent Pinchart wrote: > >> Hi, >> >> >> On Monday 16 March 2009 14:43:35 lesc...@esiee.fr wrote: >> >> >>> Hello everyone, >>> >>> >>> I'm using this webcam to do some streaming and image analysis. >>> When using Logitech's driver under MS Window, it works fine. I've access >>> to all resolutions with the RGB24 format. >>> >> The camera doesn't support the RGB24 format natively. Transcoding has to >> be done in software. libv4l2 can help you there. >> >> >>> The problem is when running under Linux. I'm using uvcvideo driver via >>> V4L2 but I can't make it work properly. >>> The resolution gets stuck to 176x144 >>> and the format is YUYV. >>> >>> Normally, the webcam is supposed to support a 1600x1200 resolution, how >>> can I set it up correctly? >>> >> You should be able to use higher resolutions. Can you describe your >> problem in details, including the steps performed and the error messages >> being printed ? >> >> >>> Thank you in advance, >>> >>> >>> xioctl (fd, VIDIOC_ENUM_FMT, &fdq) >>> >>> returns me 2 formats only: MJPEG and YUYV. YUYV is fine for me but I >>> can't reach 1600x1200, or 800x600 or even not 320x240!!!! >>> >> Best regards, >> >> >> Laurent Pinchart >> >> >> >> > > > _______________________________________________ > Linux-uvc-devel mailing list > Linux-uvc-devel@lists.berlios.de > https://lists.berlios.de/mailman/listinfo/linux-uvc-devel > > _______________________________________________ Linux-uvc-devel mailing list Linux-uvc-devel@lists.berlios.de https://lists.berlios.de/mailman/listinfo/linux-uvc-devel