V4L2 - Capturing uncompressed data
Hello,
I'm a French student and I'm doing an intern ship in a French image processing software company,
and I've got some questions about V4L2 and more precisely, the video formats.
In the application, I just need to capture frames of webcams and display the result.
After research, I found the capture example on the
http://v4l2spec.bytesex.org/ website.
So now, I capture correctly the frames.
During the initialisation of the device,
I'm doing a VIDIOC_G_FMT in order to
get the format description of the webcam.
Then, I tried to change the pixelformat.
Indeed, I wanted the YUYV FORMAT because I need to get the raw data in order to get the best quality possible.
My problem is, after the VIDIOC_S_FMT, the pixelformat field is set back to JPEG FORMAT (and the colorspace too) and so, I don't get raw data, but compressed jpeg data.
I know that the VIDIOC_S_FMT try to change these fields but if the driver don't authorise them,
it will put the originals back.
But, I really need to get the
uncompressed data of the captured picture,
so is there by any chance, another solution to 'force' and capture the images in an Uncompressed format ? Or is it really set by the driver and so,
no chance to have the raw ?
So, in my InitDevice I'm doing that :
//Get FMT
Clear( &mFmt, sizeof( mFmt ) );
mFmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if ( -1 == Xioctl ( mFd, VIDIOC_G_FMT, &mFmt ) )
return false;
//Set FMT A LA RESOLUTION CHOISIE
:Clear( &mFmt, sizeof( mFmt ) );
mFmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
mFmt.fmt.pix.width = iInfo.Width;
mFmt.fmt.pix.height = iInfo.Height;//I want to capture raw data
in YUYV, no JPEG compressed stuff
mFmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
mFmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
if ( -1 == Xioctl ( mFd, VIDIOC_S_FMT, &mFmt ) )
return false;
//JPEG - set yuyv failedprintf("%d\n",mFmt.fmt.pix.pixelformat);
//JPEG - always jpeg, but i don't
want this
printf("%d\n",mFmt.fmt.pix.colorspace); To be clear, I want the uncompressed pixels of the capture. I already succeeded in converting from JPEG to BGR, but the data are compressed.
So now, I don't want to do that conversion.
Actually, I want to save the
uncompressed data for quality directly!
But I don't know if that is possible because
the driver of the webcam (VF0420 Live! Cam Vista IM - ov519)
specified only JPEG format when I'm doing a 'V4l-info'.
I really looked for answers everywhere on the web, so I'm losing hope and that's why I'm asking you that today. I'm sorry if my comment is misplaced or if the answer has already been posted.
Thank you all,
Regards.
Guillaume.
Hi Guillaume,
Quoted 8 lines · On Friday 15 May 2009 15:03:11 Guillaume wrote:
Hello,
I'm a French student and I'm doing an intern ship in a French image processing software company, and I've got some questions about V4L2 and more precisely, the video formats.
In the application, I just need to capture frames of webcams and display the result. After research, I found the capture example on the
http://v4l2spec.bytesex.org/ website. So now, I capture correctly the frames.
Quoted 10 lines
During the initialisation of the device, I'm doing a
VIDIOC_G_FMTin order to get the format description of the webcam. Then, I tried to change the pixelformat. Indeed, I wanted the YUYV FORMAT because I need to get the raw data in order to get the best quality possible.My problem is, after the
VIDIOC_S_FMT, the pixelformat field is set back to JPEG FORMAT (and the colorspace too) and so, I don't get raw data, but compressed jpeg data.
Quoted 7 lines
I know that the
VIDIOC_S_FMTtry to change these fields but if the driver don't authorise them, it will put the originals back.But, I really need to get the uncompressed data of the captured picture, so is there by any chance, another solution to 'force' and capture the images in an Uncompressed format ? Or is it really set by the driver and so, no chance to have the raw ?
It depends on the camera. If the camera can deliver uncompressed data, you should be able to get that out of the driver. Otherwise you're stuck.
[snip]
Quoted 9 lines
To be clear, I want the uncompressed pixels of the capture. I already succeeded in converting from JPEG to BGR, but the data are compressed.
So now, I don't want to do that conversion. Actually, I want to save the uncompressed data for quality directly!
But I don't know if that is possible because the driver of the webcam (VF0420 Live! Cam Vista IM - ov519) specified only JPEG format when I'm doing a 'V4l-info'.
That probably means that the camera can't deliver uncompressed data, although you should ask the driver's author to make sure. If the camera indeed supports (M)JPEG only, you will probably have to get another camera.
Quoted 3 lines
I really looked for answers everywhere on the web, so I'm losing hope and that's why I'm asking you that today.I'm sorry if my comment is misplaced or if the answer has already been posted.
This is the right place for such questions, don't worry.
Best regards,
Laurent Pinchart
Quoted 5 lines · Laurent Pinchart <laurent.pinchart <at> skynet.be> writes:
It depends on the camera. If the camera can deliver uncompressed data, you should be able to get that out of the driver. Otherwise you're stuck.
[snip]
Ok, it's what I was afraid of.
Quoted 4 lines
That probably means that the camera can't deliver uncompressed data, although you should ask the driver's author to make sure. If the camera indeed supports (M)JPEG only, you will probably have to get another camera.
I'll tell that to my internship supervisor and I'll be back at you if I have more questions.
Quoted 6 lines
This is the right place for such questions, don't worry.
Best regards,
Laurent Pinchart
Thank you for the cordial welcome, I didn't know how mailing lists worked.
Have a good day !
Guillaume.
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo <at> vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 3 lines · Laurent Pinchart
Hi Guillaume,
On Friday 15 May 2009 15:03:11 Guillaume wrote:
[snip]
Quoted 7 lines
Quoted 7 lines
My problem is, after the
VIDIOC_S_FMT, the pixelformat field is set back to JPEG FORMAT (and the colorspace too) and so, I don't get raw data, but compressed jpeg data.I know that the
VIDIOC_S_FMTtry to change these fields but if the driver don't authorise them, it will put the originals back.
Quoted 6 lines
Quoted 4 lines
But, I really need to get the uncompressed data of the captured picture, so is there by any chance, another solution to 'force' and capture the images in an Uncompressed format ? Or is it really set by the driver and so, no chance to have the raw ?
It depends on the camera.
...and the driver. I don't know much about various _web_cameras and their drivers, but I could well imagine, that you're asking for an unsupported YUV variation, whereas some other format would be supported. Why don't you use VIDIOC_ENUM_FMT to list all supported formats? Or even look in the driver source - it's open:-)
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
Quoted 9 lines
Quoted 2 lines
It depends on the camera.
...and the driver. I don't know much about various
_web_camerasand their drivers, but I could well imagine, that you're asking for an unsupported YUV variation, whereas some other format would be supported. Why don't you useVIDIOC_ENUM_FMTto list all supported formats? Or even look in the driver source - it's open
Hi,
Thanks for your answer. I didn't try ENUM_FMT but I tried to set every available format of V4L2 (that we can found in the "videodev2.h"), but the only one possible is the compressed JPEG Format.
You said to look in the driver source, but where exactly do I have to look for ?
Thank you for your time,
Regards,
Guillaume.
Guillaume <Kowaio <at> gmail.com> writes:
I just tried the ENUM_FMT, and there is only 1 format, the JPEG one.
But I don't understand one thing. The webcam displays compressed Jpeg data. OK.
But before that compression, the data aren't in uncompressed data ?
It's the driver or something which is doing that compression directly during the capture, but there really are no chance to get that uncompressed data before compression in JPEG ?
Hi Guillaume,
Quoted 11 lines · On Monday 18 May 2009 09:32:53 Guillaume wrote:
Guillaume <Kowaio <at> gmail.com> writes:
I just tried the
ENUM_FMT, and there is only 1 format, the JPEG one.But I don't understand one thing. The webcam displays compressed Jpeg data. OK.
But before that compression, the data aren't in uncompressed data ? It's the driver or something which is doing that compression directly during the capture, but there really are no chance to get that uncompressed data before compression in JPEG ?
The video stream is compressed directly by the webcam and sent to the host in compressed form.
Best regards,
Laurent Pinchart
Quoted 6 lines · Laurent Pinchart <laurent.pinchart <at> skynet.be> writes:
The video stream is compressed directly by the webcam and sent to the host in compressed form.
Best regards,
Laurent Pinchart
I spoke with my supervisor. He'll try to get a camera which allow uncompressed format.
In the meantime, and in order to do stop-motion
in the application, I need to get the best quality possible of the webcam in one 'shot' (not video, just picture). Is there any way to get the value of compression of the jpeg by the V4L2 in order to do a software extrapolation after.
For instance, with some webcams (1.3 millions pixels), you can capture a 640*480 resolution in video mode but some allow pictures in 800*600 by extrapolation.
So in order to do that extrapolation, I need the value
of compression of the JPEG use by V4L2. Is it always the same, or it depends on the camera ? And can v4l2 get and modify this value ?