简体   繁体   English

Opencv无法通过视频捕获设备连接相机

[英]Opencv cant access camera connected through video capture device

I have a analog camera connected to EasyCap video capture device. 我有一个模拟摄像头连接到EasyCap视频捕捉设备。 When I run a basic code which opens webcam video using OPENCV, I can access my in-built webcam but not the other analog camera. 当我运行使用OPENCV打开网络摄像头视频的基本代码时,我可以访问我内置的网络摄像头,但不能访问其他模拟摄像头。

How would you connect any other camera (FPV, IR, etc) to the PC such that OPENCV can access it. 如何将任何其他相机(FPV,IR等)连接到PC,以便OPENCV可以访问它。

Thanks. 谢谢。

i struggled with the same problem and hope it helps! 我挣扎着同样的问题,希望它有所帮助!

the original thread + ANSWER 原始线程+答案

also relevant XKCD 也是相关的XKCD

one more observation: from your description it looks like you already have a webcam running on the laptop (in-built webcam maybe?) you might want to disable it in system manager so as to guarantee that your analog camera cam_index is zero for certain. 还有一个观察:从您的描述中看起来您已经在笔记本电脑上运行了网络摄像头(可能是内置网络摄像头?)您可能希望在系统管理器中禁用它,以确保您的模拟摄像头cam_index为零。 Otherwise if you leave the webcam enabled as a device, then your analog cam will most likely be incremented to cam_index=1 which amusingly enough seems to be confirmed by it crashing on cam_index=1. 否则,如果您将网络摄像头作为设备启用,那么您的模拟摄像头很可能会增加到cam_index = 1,这似乎可以通过它在cam_index = 1上崩溃来确认。 Arguable not a great method to find your camera's index but there you have it! 争论不是一个很好的方法来找到你的相机的索引,但你有它!

You can set which camera to connect to open by changing the following deviceID to the desired device you want: 您可以通过将以下deviceID更改为所需的所需设备来设置要连接的相机以进行打开:

CvCapture* capture = cvCaptureFromCAM(deviceID);  

or new API: 或新的API:

VideoCapture cap(deviceID);

Check out documenation for more info. 查看文档以获取更多信息。

使用模拟摄像机的deviceID而不是内置摄像机。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM