LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-10-2008, 08:25 AM   #1
c0deland
LQ Newbie
 
Registered: Dec 2008
Posts: 5

Rep: Reputation: 0
V4L2 image capture problem


Hello.

I want to make a program to capture the frames from a security cam. I have the following hardware components:
- CCD security cam
- AV-RF modulator
- TV Tuner (Hauppauge HVR-900 hybrid TV stick - usb)
To make this program I used the capture.c example from video4linux2. The problem is that the captured image is a green/pink image. I don't know what settings should I apply in order to get the correct image. The pixelformat is:
Code:
        fmt.type                = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        fmt.fmt.pix.width       = 640;
        fmt.fmt.pix.height      = 480;
        fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; 
        fmt.fmt.pix.field       = V4L2_FIELD_INTERLACED;
        fmt.fmt.pix.colorspace  = V4L2_COLORSPACE_470_SYSTEM_BG;
where fmt is struct v4l2_format. The video standard is set to V4L2_STD_PAL_B.
I tried to change the CID values (hue, saturation, brightness, etc) but still no effect

I need to mention that everything is ok if use a player (like mplayer). The frames are displayed as they should be.

Any idea what can cause this?

Thank you
 
Old 12-11-2008, 03:47 AM   #2
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
until you get a better reply why not pipe thru mplayer first into a capture device

mplayer or vlc may allow capture first off?

2) how do you know the cam is a v4l2 device and not just a v4l1 device?

there are capture apps called guvcview and luvcview that might provide terminal output that could assist?
 
Old 12-11-2008, 07:05 AM   #3
c0deland
LQ Newbie
 
Registered: Dec 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by aus9 View Post
until you get a better reply why not pipe thru mplayer first into a capture device

mplayer or vlc may allow capture first off?

2) how do you know the cam is a v4l2 device and not just a v4l1 device?

there are capture apps called guvcview and luvcview that might provide terminal output that could assist?
Thanks for your answer.

The device is a v4l2 one. I think I'm going to solve the problem.
The frame I get into the buffer is YUYV format. I managed to convert it to RGB24 and imagemagik displays it correctly. What I was doing until now was to display a raw YUYV image with a wrong viewer.
Now I'm trying to convert the RGB stream to BMP format... hopefully with positive results this time. In the end I should have something like this:

(camera image) -> (v4l2 buffer YUYV raw) -> (my RGB24 buffer) -> (BMP file)

Thank you.
 
Old 12-11-2008, 11:25 AM   #4
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
v4l-info

There's generally several input modes.

v4l-info:

video capture
VIDIOC_ENUM_FMT(0,VIDEO_CAPTURE)
index : 0
type : VIDEO_CAPTURE
flags : 0
description : "8 bpp, gray"
pixelformat : 0x59455247 [GREY]
VIDIOC_ENUM_FMT(1,VIDEO_CAPTURE)
index : 1
type : VIDEO_CAPTURE
flags : 0
description : "15 bpp RGB, le"
pixelformat : 0x4f424752 [RGBO]
VIDIOC_ENUM_FMT(2,VIDEO_CAPTURE)
index : 2
type : VIDEO_CAPTURE
flags : 0
description : "15 bpp RGB, be"
pixelformat : 0x51424752 [RGBQ]
VIDIOC_ENUM_FMT(3,VIDEO_CAPTURE)
index : 3
type : VIDEO_CAPTURE
flags : 0
description : "16 bpp RGB, le"
pixelformat : 0x50424752 [RGBP]
VIDIOC_ENUM_FMT(4,VIDEO_CAPTURE)
index : 4
type : VIDEO_CAPTURE
flags : 0
description : "16 bpp RGB, be"
pixelformat : 0x52424752 [RGBR]
VIDIOC_ENUM_FMT(5,VIDEO_CAPTURE)
index : 5
type : VIDEO_CAPTURE
flags : 0
description : "24 bpp RGB, le"
pixelformat : 0x33524742 [BGR3]
VIDIOC_ENUM_FMT(6,VIDEO_CAPTURE)
index : 6
type : VIDEO_CAPTURE
flags : 0
description : "32 bpp RGB, le"
pixelformat : 0x34524742 [BGR4]
VIDIOC_ENUM_FMT(7,VIDEO_CAPTURE)
index : 7
type : VIDEO_CAPTURE
flags : 0
description : "32 bpp RGB, be"
pixelformat : 0x34424752 [RGB4]
VIDIOC_ENUM_FMT(8,VIDEO_CAPTURE)
index : 8
type : VIDEO_CAPTURE
flags : 0
description : "4:2:2, packed, YUYV"
pixelformat : 0x56595559 [YUYV]
VIDIOC_ENUM_FMT(9,VIDEO_CAPTURE)
index : 9
type : VIDEO_CAPTURE
flags : 0
description : "4:2:2, packed, UYVY"
pixelformat : 0x59565955 [UYVY]
VIDIOC_G_FMT(VIDEO_CAPTURE)
type : VIDEO_CAPTURE
fmt.pix.width : 320
fmt.pix.height : 240
fmt.pix.pixelformat : 0x33524742 [BGR3]
fmt.pix.field : INTERLACED
fmt.pix.bytesperline : 960
fmt.pix.sizeimage : 230400
fmt.pix.colorspace : unknown
fmt.pix.priv : 0

-----

capture for me:

mencoder tv://3 -audio-delay 0.164 -aspect 4:3 -oac pcm -ovc lavc -lavcopts vcodec=mjpeg:autoaspect=1 -o tvcapture.avi

With some settings in /etc/mplayer/mencoder.conf

fps=60000/1001
ofps=30000/1001
oac=lavc=yes
ovc=lavc=yes
lavcopts=vcodec=mjpeg:acodec=pcm
tv=driver=v4l2:input=0utfmt=uyvy:chanlist=us-cable:norm=NTSC-M:width=720:height=480:brightness=8:contrast=4:amode=1:audiorate=48000:quality=100
vf=yadif,scale,eq2

note input= and outfmt=, which have a direct relationship to v4l-info specs.
 
Old 12-12-2008, 04:19 AM   #5
c0deland
LQ Newbie
 
Registered: Dec 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks Shadow 7.

I finally figured what was the problem.
The video standard was set to PAL_B and the frame had two colors only. I changed it to PAL and now I get the coloured frame.

Thank you.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to capture picture from V4L2 webcam? weiweif Programming 10 08-06-2013 03:17 AM
How to write a V4L2 driver for CMOS image sensor? homn Linux - Newbie 1 05-02-2008 12:33 AM
fc4: video capture image is jittery and shaky bkahler Fedora 1 03-20-2006 05:23 AM
Terminal Program to Capture an image from a Firewire camers naysan Linux - Software 0 05-17-2005 04:41 PM
when i press printscreen, it doens´t happen anything(do not capture image ) sagi7ario Mandriva 2 03-15-2004 03:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration