Setting video capture properties no longer works in OpenCV 2.2? - c++

Prior OpenCV 2.2, I was able to do
VideoCapture capture(0);
capture.set(CV_CAP_PROP_FRAME_WIDTH, 640);
capture.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
in order to modify the frame size. But after when I compiled my application against OpenCV 2.2, setting the properties no longer works (the video is displayed correctly though). If I do a get of these values, 0 is returned. And if I look at the size of the captured frame, it is 160 x 120.
I searched online but most of the posts were about the problem in Linux whereas I am running Windows 7 64-bit. My webcam is a Logitech QuickCam Ultra Vision.
Is there anyone experiencing the same problem? Or no problem at all?
Thanks in advance!

This problem has been solved in OpenCV 2.3, even with my old Logitech QuickCam Ultra Vision webcam.

May be you should try with VideoInput, which is also supported by OpenCV, and included in OpenCV 2.0.3.
See an example at http://opencv.willowgarage.com/wiki/CameraCapture

Related

OpenCV VideoCapture Partial Frame Corruption

I recently started using OpenCV for a project involving reading videos. I followed tutorials online for video's reading and the video seems to be read with no problems. However, when I display any frame from the video, the far right column appears to be corrupted. Here is the code I used for reading and displaying the first frame.
VideoCapture cap("6.avi");
Mat frame;
cap>>frame;
imshow("test",frame);
waitKey(0);
This resulted in a frame that looks good for the most part except the far right column. See here.
I am making no modifications to the video or frames before displaying it. Can anyone help figure out why this is happening?
Note: I'm running Ubuntu 14.04, OpenCV version 2.4.8
Full video can be found here.
Your code looks fine to me. Are you certain the frame is corrupted? Resize, maximize, minimize the "test" GUI window to see if the right edge is still corrupted. Sometimes while displaying really small images, I've seen the right edge of the GUI window display incorrectly even though the frame is correct. You could also try imwrite("test.png",frame) to see if the saved image is still corrupted.
If this doesn't help, it would seem like a codec problem. Ensure you have the latest version of opencv, ffmpeg.
If this still doesn't help, the video itself may be corrupted. You could try converting it into another format using ffmpeg

Problems accessing web camera under Windows 10 / OpenCV

I'm working on a project requiring real-time access to the webcam, and have problems with getting a suitable camera stream under Windows 10 for processing the frames with OpenCV.
I'm able to access the camera just fine under Windows 8.1. using either
OpenCV 2.4.9 with Evgeny Pereguda's VideoInput
library(http://www.codeproject.com/Articles/776058/Capturing-Live-video-from-Web-camera-on-Windows-an)
for accessing the camera through Windows Media Foundation, or
OpenCV 3.0 without any additional libraries
These allow for capturing the webcam stream with high frame rate (~30fps), and setting the webcam resolution with e.g.
cvCapture.set(CV_CAP_PROP_FRAME_WIDTH, 640);
cvCapture.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
Under Windows 10, however, both solutions above result in problems:
the solution using OpenCV 2.4.9, and the VideoInput library allow
setting the resolution to 640x480, but the frame rate is around 1FPS
(or worse?!), and the picture is very dark
the solution using OpenCV 3.0 gives me a nice 1920x1080 image on a good frame rate, but I'm unable to set the resolution for the stream
I even tried opening the camera stream with:
cv::VideoCapture cvCapture( CV_CAP_DSHOW + camnum );
cv::VideoCapture cvCapture ( CV_CAP_MSMF + camnum );
The first one works (as far as opening the stream, but with the same problems as above), the MSMF (Microsoft Media Foundation) results in cvCapture.isOpened() returning false;
Handling the FullHD stream real-time isn't feasible for the image processing algorithms, nor is resizing down the resulting frame with OpenCV.
The Windows 8.1 version is running on a Surface Pro 3 (Core i7), and the Windows 10 version on a Surface Pro 4 (Core i7). Could this be a hardware / camera driver problem? I tried finding updated drivers for the Surface 4, but to no avail.
Has anyone had similar problems? Is there an obvious solution I'm overlooking?
I think that your problem with videoInput on Windows 10 is related with selecting of the correct mediaType of web cameras. The fact is that OpenCV uses DirectShow by default and videoInput on Media Foundation is only optional.
I advise you correct check variables:
float MF_MT_FRAME_RATE_RANGE_MAX;
float MF_MT_FRAME_RATE;
float MF_MT_FRAME_RATE_RANGE_MIN;
in
// Structure of info MediaType
struct MediaType
Also I can advise to visit on site Capture Manager Topology Editor - this a free software for working with web cameras via Media Foundation. It allows verify accessible features of Media Foundation on your Surface Pro 4 (Core i7).
With best regards,
Evgeny Pereguda

How to capture video from an external camera using opencv on ubuntu

I am a beginner to ubuntu. I am trying to drive a external camera on ubuntu 15.04. I want to know how to combine opencv library with camera driver. So I can capture video use sentences like
VideoCapture cap;
cap.open(0);//0,1,2...
Does anyone have some idea? Looking forward to your reply!
It depends on the camera you use, some cameras you need do nothing, and some cameras give API,you can use the API to get the video then use opencv to do something.

Firewire camera with OpenCv 2.4. not working

I am using OpenCV 2.4 with C++ for image processing and video streaming . I would like to know how we can use fire-wire camera like pixilink to capture frames? I tried the VideoCapture class but it seems to work with only usb cameras unlike firewire one. If some one has done same thing with firewire camera then kindly give some guidance how to do that?
You can capture images using firewire SDK or you can also libdc1394 API. I found libdc1394 to more reliable and easy to use and there are couple of examples available to get start.

OpenCV - Webcam does not work

I'm learning OpenCV because I want to build and program a 3D Scanner over the summer.
I bought three webcams for this purpose (two for the actual stereo images and one for texture [or as a backup]).
I tried to get a webcam's video with OpenCV. However, this does not work, as I ended up with a black screen, instead of video.
I then tried the same code with my grandmother's webcam. It worked fine.
However, I already bought 3 webcams of the type that I was planning on using to build my scanner: http://www.amazon.com/Webcam-Camera-Vision-Meeting-compatible/dp/B0015TJNEY/ref=pd_bxgy_e_img_b
I don't want to buy any new webcams.
Does anybody have any idea of why my webcams don't work with OpenCV (they work with other programs)?
How can I get OpenCV to accept my webcams?
Any suggestions would be appreciated!
Thanks
If your program pass this step , you should try a different number for cvCaptureFromCAM(0); 0 is the first web cam but maybe your's is set as 1, 2 or 3. you can also try -1 and see what happens
CvCapture *capture;
capture = cvCaptureFromCAM(0);
if (!capture)
{
printf("Error at capture");
return 1;
}