Re: Saving YUVY image from V4L2 buffer to file
Darren Longhorn <[email protected]> Wed, 03 Feb 2010 18:38:19 +0000
| Newsgroups | gmane.comp.video.video4linux |
|---|---|
| Message-ID | <[email protected]> |
Owen O' Hehir wrote:
> Hello All,
>
> I'm trying to save a captured image from a USB camera to a file. The capture is based on V4L2 video capture example from the V4L2 API spec. http://v4l2spec.bytesex.org/spec/a16706.htm
>
> The V4L2 set pointers (via mmap) to to the USB image (in YUV 4:2:2 (YUYV)) and as far as I can see the simplest way to save the image in a recognised format is in RGB format, specifically in PPM (Netpbm color image format).
>
> As such I've expanded the process_image function:
>
>
> static void
> process_image (const void * p)
> {
> static int count = 0;
>
> static int r,g,b;
> static int y1,y2,cb,cr;
>
> int pixel=0;
>
> FILE* fp = fopen("datadump", "w" );
> // Write PNM header
> fprintf( fp, "P6\n" );
> fprintf( fp, "# YUV422 frame -> RGB \n" );
> fprintf( fp, "%d %d\n", userfmt.fmt.pix.width, userfmt.fmt.pix.height );
>
> fprintf( fp, "255\n" );
>
> while(pixel < (userfmt.fmt.pix.width * userfmt.fmt.pix.height)){
>
> y1 = *(p+pixel);
Are you sure that's your real code? I don't think you should dereference
a void pointer like that.
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list