OpenCV:从usb相机捕获的黑色图像 [英] OpenCV: black image captured from usb camera

查看:351
本文介绍了OpenCV:从usb相机捕获的黑色图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用opencv从USB相机捕获图像帧。但我总是得到一个黑框。

I am trying to capture an image frame from a USB camera using opencv. However I am always getting a black frame. I have read many posts with this issue and tried all the suggestions but nothing worked for me.

我开始使用这里讨论的代码:
http://opencv-users.1802565.n2.nabble.com/Using -USB-Camera-td6786148.html

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

我试过在许多'关键'句子后包括方法cvWaitKey(1000)。正如你可以看到的等待价值非常高(1000)。

I have tried including the method cvWaitKey(1000) after many 'critical' sentences. As you can see the waiting value is very high (1000).

我也尝试保存图片框架,同样,它是一个黑色图片。

I have also tried to save the image frame and, equally, it is a black image.

我使用以下系统:


  • OpenCV 2.2.0

  • Windows 7,32位

  • Visual Studio 2010(C ++)

  • 一个电路板usb相机(我不知道制造商)

usb相机可与AMCAP.EXE 1.00配合使用。

The usb camera works well with AMCAP.EXE 1.00.

这可能是因为Windows ?

Could it be because of the camera drivers being used by Windows? Could I change to other drivers that work better for OpenCV 2.2.0?

感谢

推荐答案

好的。正如我答应你的要求在评论,对不起,让你等待,真的很忙。很少有时间张贴这个答案。但这里是:

Ok. As I promised to your request in the comments, and sorry to keep you waiting, really been busy. Barely had time to post this answer too. But here it is:

这是我模拟opencv捕获黑色图像。在输出窗口,我已经在你的评论中问过它是什么,显示有一个错误。

This is me simulating that opencv is capturing black image. On the output window, which I had asked you in the comments about what it says, shows that there is an error.

调查后,我意识到这是由于相机的可用格式:

After investigating, I realised that it is due to the camera's available format:

cuz,这是一个糟糕的相机。如果你有一个更好的相机,如罗技一个,你可以看到,可用的格式是这么多。

Of cuz, this is a lousier camera. If you have a better camera like the logitech one, you can see that the format available is so much more.

是很多方法,你可以尝试像

There are lots of methods, you can try some thing 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 snap. This webcam is bit faulty, hence the image snapped is not that beautiful.

希望这是你的问题。但也可能不是这样。我喜欢调试问题,但我不能放下所有可能的原因,这是为你发生,因为我真的很忙,正如你要求一个例子,这是其中之一。干杯。如果你能告诉我你输出的窗口错误说,我可能可以帮助更多。

Hope this is your problem. but it may not be the case too. I like debugging problems, but I can't put down all the possible causes that this happen for you as I am really busy, as you asked for an example, this is one of them. Cheers. If you could tell me what you output window error says, I probably can help more.


EDIT(to answer more in your comments):

好,我想让您尝试以下几件事:

Ok, I want you to try a few things:

1 )首先,我不想使用 cvQueryFrame 或类似的捕获方法,而是尝试使用网络摄像头捕获视频。等待也许说10秒钟,看看它是否成功。原因是,一些相机(质量较差的)需要相当长的时间来热身,他们捕获的前几帧可能是空的。

1)First, instead of using cvQueryFrame, or similar capturing methods, I want you to try use that webcam to capture a video instead. Wait up to maybe say 10 secs to see if it's successful. Reason being, some cameras(lower quality ones) take quite a while to warm up and the first few frames they capture may be an empty one.

2)如果第一步不起作用,请尝试键入

2) If the step one doesn't work, try typing

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

并粘贴媒体I / O和视频I / O的结果?我想看看结果。我也怀疑你的库依赖关系,但由于你说它与一个罗技相机,我怀疑是这样的情况。当然,总有一个机会,这是因为相机不兼容OpenCV。相机有没有任何品牌的方式?

and paste the results for media I/O and Video I/O? I want to see the results. I would suspect your library dependencies too, but since you said it works with a logitech camera, I doubt that's the case. Of course, there's always a chance it's due to that the camera is not compatible to OpenCV. Does the camera have any brands by the way?

3)或者,只是在线搜索usb驱动程序并安装它,我有一个朋友为一个类似的问题,但不确定的过程。

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

这篇关于OpenCV:从usb相机捕获的黑色图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆