【发布时间】:2012-11-07 06:16:14
【问题描述】:
我正在尝试使用 videoInput 库、OpenCV 2.4.3 和 VS2010 Express 从两个或多个 MSFT LifeCam HD-3000 将视频捕获为 Mat 类型。
我按照Most efficient way to capture and send images from a webcam in a network 的示例进行操作,效果很好。
现在我想用 c++ Mat 类型替换 IplImage 类型。我尝试按照以下示例进行操作:opencv create mat from camera data
这给了我以下信息:
VI = new videoInput;
int CurrentCam = 0;
VI->setupDevice(CurrentCam,WIDTH,HEIGHT);
int width = VI->getWidth(CurrentCam);
int height = VI->getHeight(CurrentCam);
unsigned char* yourBuffer = new unsigned char[VI->getSize(CurrentCam)];
cvNamedWindow("test",1);
while(1)
{
VI->getPixels(CurrentCam, yourBuffer, false, true);
cv::Mat image(width, height, CV_8UC3, yourBuffer, Mat::AUTO_STEP);
imshow("test", image);
if(cvWaitKey(15)==27) break;
}
输出是一个带线条的图像(即,第一行看起来是正确的,但第二行似乎是关闭的,第三行是正确的,第四行是关闭的,等等)。这表明步骤部分是错误的,或者 IplImage 类型和我没有得到的 Mat 类型之间存在一些差异。我已尝试查看/更改所有参数,但找不到任何东西。
希望答案能帮助那些面临从 videoInput 库加载图像到 Mat 类型的相当常见问题的人。
提前致谢!
【问题讨论】: