From: Darren Longhorn <darren.longhorn@redembedded.com>
To: video4linux-list@redhat.com
Subject: Re: Saving YUVY image from V4L2 buffer to file
Date: Thu, 04 Feb 2010 15:58:05 +0000 [thread overview]
Message-ID: <4B6AEE8D.4070507@redembedded.com> (raw)
In-Reply-To: <1265250209.3122.86.camel@palomino.walls.org>
Andy Walls wrote:
> On Wed, 2010-02-03 at 18:38 +0000, Darren Longhorn wrote:
>> 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.
>
> Old-ish C-compilers treated that as a char * in that case. The behavior
> is unreliable of course. This certainly could be a cause of problems.
Ah, yes. Well remembered!
Cheers
Darren
--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
prev parent reply other threads:[~2010-02-04 15:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-03 17:40 Saving YUVY image from V4L2 buffer to file Owen O' Hehir
2010-02-03 17:54 ` Devin Heitmueller
2010-02-03 18:06 ` Owen O' Hehir
2010-02-03 18:18 ` Devin Heitmueller
2010-02-06 20:48 ` Saving YUVY image from V4L2 buffer to file - SOLVED Owen O' Hehir
2010-02-03 18:57 ` Saving YUVY image from V4L2 buffer to file Charlie X. Liu
2010-02-03 19:18 ` Devin Heitmueller
2010-02-03 20:01 ` Charlie X. Liu
2010-02-03 20:12 ` Devin Heitmueller
2010-02-03 18:38 ` Darren Longhorn
2010-02-04 2:23 ` Andy Walls
2010-02-04 15:58 ` Darren Longhorn [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B6AEE8D.4070507@redembedded.com \
--to=darren.longhorn@redembedded.com \
--cc=video4linux-list@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox