From: "Charlie X. Liu" <charlie@sensoray.com>
To: "'Owen O' Hehir'" <oo_hehir@hotmail.com>, <video4linux-list@redhat.com>
Subject: RE: Saving YUVY image from V4L2 buffer to file
Date: Wed, 3 Feb 2010 10:57:03 -0800 [thread overview]
Message-ID: <005801caa502$ad686ca0$083945e0$@com> (raw)
In-Reply-To: <SNT123-W631AD70788CCBA562F2E20EE560@phx.gbl>
Why don't you directly set it with: fmt.fmt.pix.pixelformat =
V4L2_PIX_FMT_BGR24, instead of converting?
Then, save like:
sprintf( ppmheader, "P6\n#ppm image\n%d %d\n255\n", info->width,
info->height);
fwrite( ppmheader, 1, strlen(ppmheader), fptr);
// write out the rows
for ( i=0; i<info->height; i++)
{
//fwrite( &image[info->stride*i], 1, info->stride, fptr);
for ( j=0; j<info->width; j++ ) {
fwrite( &image[info->stride*i+j*3+2], 1, 1, fptr);
fwrite( &image[info->stride*i+j*3+1], 1, 1, fptr);
fwrite( &image[info->stride*i+j*3+0], 1, 1, fptr);
}
}
Charlie X. Liu @ Sensoray Co.
-----Original Message-----
From: video4linux-list-bounces@redhat.com
[mailto:video4linux-list-bounces@redhat.com] On Behalf Of Owen O' Hehir
Sent: Wednesday, February 03, 2010 10:06 AM
To: video4linux-list@redhat.com
Subject: RE: Saving YUVY image from V4L2 buffer to file
Devin,
Many thanks for the quick reply.
Yes I'm getting some sort of an image. When I was experimenting I managed to
get an image but in grayscale & showing multiple copies of the same image
covering the top half of the image. I imagine it was distorted because I was
not converting to RGB correctly.
All the best,
Owen
> Date: Wed, 3 Feb 2010 12:54:02 -0500
> Subject: Re: Saving YUVY image from V4L2 buffer to file
> From: dheitmueller@kernellabs.com
> To: oo_hehir@hotmail.com
> CC: video4linux-list@redhat.com
>
> On Wed, Feb 3, 2010 at 12:40 PM, Owen O' Hehir <oo_hehir@hotmail.com>
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:
>
> Independent of the conversion function, are you sure you are getting a
> valid YUV frame at all? A completely green frame is what you will get
> back if you had a buffer which was memset(0). Hence it's possible
> that the data you are passing *into* your conversion function is
> completely blank.
>
> Devin
>
> --
> Devin J. Heitmueller - Kernel Labs
> http://www.kernellabs.com
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
https://signup.live.com/signup.aspx?id=60969
--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
next prev parent reply other threads:[~2010-02-03 18:57 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 ` Charlie X. Liu [this message]
2010-02-03 19:18 ` Saving YUVY image from V4L2 buffer to file 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
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='005801caa502$ad686ca0$083945e0$@com' \
--to=charlie@sensoray.com \
--cc=oo_hehir@hotmail.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