OpenCV: black image taken from a USB camera

I am trying to capture an image frame from a USB camera using opencv. However, I always get a black border. I read a lot of posts with this problem and tried all the suggestions, but nothing worked for me.

I started using the code here: http://opencv-users.1802565.n2.nabble.com/Using-USB-Camera-td6786148.html

I tried to include the cvWaitKey (1000) method after many "critical" sentences. As you can see, the expected value is very large (1000).

I also tried to keep the image frame and, equally, a black image.

I am using the following system:

  • OpenCV 2.2.0
  • Windows 7 32 bit
  • Visual Studio 2010 (C ++)
  • onboard USB camera (which I do not know the manufacturer)

The USB camera works well with AMCAP.EXE 1.00.

Maybe due to the fact that the camera drivers are used by Windows? Can I upgrade to other drivers that work better for OpenCV 2.2.0?

thank

+6
opencv camera usb
Feb 18 '14 at 9:28
source share
4 answers

Ok Since I promised your request in the comments, and sorry to keep you waiting, was really busy. I barely managed to publish this answer. But here it is:

I imitate that opencv captures a black image. In the output window, which I asked you in the comments about what it says, shows that there is an error.

enter image description here

After research, I realized that this is due to the available camera format: enter image description here

Because it is a more lousier camera. If you have a better camera like logitech, you can see that the format available is much larger. enter image description here

There are many methods, you can try something like

capture.set(CV_CAP_PROP_FRAME_WIDTH , 640); capture.set(CV_CAP_PROP_FRAME_HEIGHT , 480); capture.set (CV_CAP_PROP_FOURCC, CV_FOURCC('B', 'G', 'R', '3'));//diff from mine, using as example 

then the webcam will be able to click. This webcam is a bit wrong, so the image taken is not so pretty. enter image description here

Hope this is your problem. but this may not be so. I like debugging problems, but I canโ€™t give up all the possible reasons why this happens to you, since I'm really busy, since you asked for an example, this is one of them. Greetings. If you could tell me what the window error says, I can probably help more.

EDIT (answer your comments in more detail):

Ok, I want you to try a few things:

1) First, instead of using cvQueryFrame or similar capture methods, I want you to try using this webcam to capture video. Wait, maybe say 10 seconds to make sure it is successful. The reason is that some cameras (better ones) take quite a long time to warm up, and the first few frames that they capture may be empty.

2) If the first step does not work, try entering

 cout << cv::getBuildInformation() << endl; 

and insert results for media input / output and video input / output? I want to see the results. I would also suspect your library dependencies, but since you said that this works with a Logitech camera, I doubt it. Of course, there is always a chance that the camera is not compatible with OpenCV. By the way, does the camera have any brands?

3) Alternatively, just find the usb drivers online and install it, I had a friend who did this for a similar problem, but not sure about it.

+4
Feb 25 '14 at 17:04
source share

The first thing I would suggest is to visit this link and check if your camera is working or not.

http://www.youronlinemirror.com/

if yes, then follow the link below to get started with things, you will also find good opencv C ++ code, the code you use is opencv1 api c code, I would prefer you to go C ++ than the old version opencv.

http://opencv-srf.blogspot.in/2011/09/capturing-images-videos.html

if you want to get an answer for your code, then itโ€™s simple, because you say that it gives a black screen, which happened in my case when I started working with opencv, it cannot take data from the device, so try this, it can work as it does for me.

add

 cvQueryFrame( capture ); 

before

 IplImage* frame = cvQueryFrame( capture ); 
+1
Feb 18 '14 at 10:11
source share

I went through the same problem as yours. Then I just changed the version from 3.1.0 to 2.4.13, then my webcam is working! More black images. I assume version 3 is not compatible with vs15. I think that you have solved the problem a long time ago. But just a message to let others know if they have the same problem.

+1
Oct 19 '16 at 19:09
source share

Even when running into OpenCV related programs, I ran into the same black screen issue. So instead of using a USB camera, I used a mobile camera that worked perfectly. Use Google apps such as DroidCam (install DroidCam on your mobile as well as on your laptop / PC) to connect your mobile camera to your laptop via Wi-Fi.

0
Jun 19 '15 at 15:30
source share



All Articles