C++ 如何在 OpenCV 中使用相机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4486176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use a camera with OpenCV
提问by Alex
I'm trying to learn OpenCV. I have been playing around with it for an entire day trying to get it to recognize my camera. I just can't get it to work and I can't find any information about it.
我正在尝试学习 OpenCV。我已经玩了整整一天,试图让它识别我的相机。我只是无法让它工作,我找不到任何关于它的信息。
My camera is a usb xbox live webcam, as soon as I connected it to my computer windows recognized it as if it were its own child and installed the drivers.
我的相机是一个 usb xbox 实时网络摄像头,一旦我将它连接到我的电脑 windows 就会识别它,就好像它是它自己的孩子一样并安装了驱动程序。
DISCLAIMERI'm like completely clueless as I have never worked with cameras before in code and I don't know how hard or difficult it would be to use one, nor do I know where to start, what information to look up, or anything like that. :( DISCLAIMER
免责声明我完全一无所知,因为我以前从未在代码中使用过相机,我不知道使用相机会有多难或多困难,也不知道从哪里开始,要查找什么信息或任何其他内容像那样。:(免责声明
I found this example on the opencv website at this url: http://opencv.willowgarage.com/wiki/CameraCapture
我在这个网址的 opencv 网站上找到了这个例子:http: //opencv.willowgarage.com/wiki/CameraCapture
I copy and pasted the first one which says "Here is a simple framework to connect to a camera and show the images in a Window.". I formatted it correctly and got it to compile and run perfectly, but it gives the error "ERROR: capture is NULL" when I execute it(not a compiler error, its an error in the application)
我复制并粘贴了第一个,上面写着“这是一个连接到相机并在窗口中显示图像的简单框架。”。我对其进行了正确格式化并使其能够完美地编译和运行,但是当我执行它时出现错误“错误:捕获为空”(不是编译器错误,它是应用程序中的错误)
回答by karlphillip
I think there are more than enough code on stackoverflow that shows how to do the trick:
我认为 stackoverflow 上有足够多的代码来展示如何做到这一点:
Unable to detect web cam in OpenCV
回答by Utkarsh Sinha
Have a look at VideoInput. Its a library that uses DirectX to get access to your webcam. Here's an article I wrote about using videoInput with OpenCV.
看看视频输入。它是一个使用 DirectX 访问网络摄像头的库。这是我写的一篇关于在 OpenCV 中使用 videoInput的文章。
回答by Juraj Blaho
You may try http://muonics.net/school/spring05/videoInput/. I have used it with OpenCV successfully.
你可以试试http://muonics.net/school/spring05/videoInput/。我已经成功地将它与 OpenCV 一起使用。
回答by Misbah Ul Hassan
as your given link :
作为您给定的链接:
#include "cv.h"
#include "highgui.h"
try this one
试试这个
#include <"opencv\cv.h>
#include <"opencv\highgui.h> //"opencv is the file where cv.h and highgui placed