如何在Matlab中同时使用多个USB网络摄像头?

问题描述 投票:1回答:1

我想用两个USB网络摄像头(飞利浦SPC 900NC)拍摄现场视频,但我发现他们无法在我的笔记本电脑上同时工作。两个USB网络摄像头中的任何一个都可以单独工作或与另一个网络摄像头一起工作(最初安装在我的笔

当我使用simulink模块“来自视频设备”时,Matlab给出的错误信息是“多个VIDEOINPUT对象无法同时访问同一设备”。然后我用命令'imaqhwinfo'检查了视频输入设备,只能检测到一个USB飞利浦网络摄像头。

我想知道,

  1. 这种情况的原因是什么?是因为硬件限制(USB总线带宽)还是仅仅是matlab视频对象不支持相同的多个视频设备?
  2. 这是什么解决方案?有人能给我一些建议吗?
matlab webcam
1个回答
-2
投票

您可能对此链接感兴趣:

http://opencv.willowgarage.com/wiki/faq#How_to_use_2_cameras_.28multiple_cameras.29_with_cvCam_library

其中包含:

首先,启动cvcam库并获取凸轮数量:

int ncams = cvcamGetCamerasCount( );    //returns the number of available cameras in the system

显示对话框以选择正在使用的摄像机

int* out; int nselected = cvcamSelectCamera(&out);

获取选定的凸轮并启用它们。

int cam1 = out[0];
int cam2 = out[1];

cvcamSetProperty(cam1, CVCAM_PROP_ENABLE, CVCAMTRUE);
cvcamSetProperty(cam1, CVCAM_PROP_RENDER, CVCAMTRUE);  //We'll render stream from this source
cvNamedWindow("Cam1", 1);
cvcamWindow MyWin1 = (cvcamWindow)cvGetWindowHandle("Cam1");
cvcamSetProperty(cam1, CVCAM_PROP_WINDOW, &MyWin1);   // Selects a window for  video rendering
//Same code for camera 2
cvcamSetProperty(cam2, CVCAM_PROP_ENABLE, CVCAMTRUE);
cvcamSetProperty(cam2, CVCAM_PROP_RENDER, CVCAMTRUE);
cvNamedWindow("Cam2", 1);
cvcamWindow MyWin2 = (cvcamWindow)cvGetWindowHandle("Cam2");
cvcamSetProperty(cam2, CVCAM_PROP_WINDOW, &MyWin1);

//If you want to open the property dialog for setting the video format parameters, uncomment this line
//cvcamGetProperty(cam1, CVCAM_VIDEOFORMAT, NULL);
//cvcamGetProperty(cam2, CVCAM_VIDEOFORMAT, NULL);

启用立体声模式(2个摄像头同时工作)

cvcamSetProperty(cam1, CVCAM_STEREO_CALLBACK , stereocallback); //stereocallback is the function running to process every frames

cvcamInit();
cvcamStart();

//Your app is working
while (1)
{
     int key = cvWaitKey(5);
     if (key == 27) break;
}
cvcamStop( );
cvcamExit( );

在上面的函数之外定义stereocallback函数。

void stereocallback(IplImage* image1, IplImage* image2) {

//Process 2 images here
}
© www.soinside.com 2019 - 2024. All rights reserved.