OpenCV Seting and working with a camera
Working in opencv with cameras is very easy, we only need a camera and our opencv libraries.
The structure that we store the camera link is CvCapture, here we store this link, then to get this link we need call to cvCaptureFromCAM function, this function need only one param, the index of the camera to be used. If there is only one camera or it does not matter what camera to use -1 may be passed.
Then this is our basic line to retrive our camera link
CvCapture* capture = cvCaptureFromCAM( 0 );
Then we only need get each frame we can capture with cam, to do this we can use the cvQuetyFrame passing as param our camera link and it return a IplImage* struct that we can show.
IplImage* frame = cvQueryFrame( capture );
With this easy lines we can get all frames we need from our camera.
55 Comments + Add Comment
Got anything to say? Go ahead and leave a comment!
Category
- blenderocv (1)
- books (2)
- Personal (3)
- Tutorials (26)
- ActionScript (1)
- Blender (2)
- CSS (1)
- Java and Netbeans (1)
- Linux/Unix (7)
- OpenCV (16)
- OpenGL (1)
- other (5)
- Web Server (1)
- Uncategorized (2)
- Works (2)
Last comments
- Valeriy Van on Mastering OpenCV with Practical Computer Vision Projects
- Valeriy Van on Segmentation & object detection by color.
- Valeriy Van on Mastering OpenCV with Practical Computer Vision Projects
- Valeriy Van on Mastering OpenCV with Practical Computer Vision Projects
- Valeriy Van on Mastering OpenCV with Practical Computer Vision Projects
Tag cloud
Twitter: damiles3D
- Could not connect to Twitter




Posted under: 
[...] was get an error same like U, then I try dan_s's suggestion at http://blog.damiles.com/?p=61. [...]
I’m using windows 7 with visual studio 2010.
The Microsoft lifecam vx-7000 is working under windows.
I’m using your standard code without any modifications.
Getting this error “Cant set width property”
The life video is displaying on the screen and no frames get captured.
Please help
If you see on CamShiftFrame window the video, there are no problems, only that your camera has no support for set porperties from opencv. But you can retrieve the frames and work with its, but can’t change the camera resolution for example.
Regards.
Hi damiles
I’m using OpenCV2.3 at ubuntu11.04
But the camera fails to open when I try both my code and yours.
The camera works well on cheese.
I also install the v4lucp
The /usr/lib/libv4l/v4l2convert.so is also exist!
What should I try now? Please any suggestion would be appreciated!
I got this. But I don’t know how to do.
http://stackoverflow.com/questions/5974882/opencv-2-2-ubuntu11-04-webcam-not-detected-solved