我在ubuntu 11.04上使用opencv 2.3。为了完整起见,在编译时,我将WITH_OPENNI = ON设置为。 (现在就后悔,因为我不打算很快使用kinect,而openni让我对普通的opencv程序感到头痛)
无论如何,为了测试opencv的安装,我编译了以下代码,向我展示了我的笔记本电脑网络摄像头的视频:
#include <stdio.h>
#include <string.h>
#include "highgui.h"
#include "cv.h"
int main()
{
cvNamedWindow("Webcam",CV_WINDOW_AUTOSIZE);
CvCapture* capture=cvCaptureFromCAM(0);
IplImage* frame;
while(1)
{
frame=cvQueryFrame(capture);
if(!frame) break;
cvShowImage("Webcam",frame);
char c=cvWaitKey(33);
if(c==27) break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("Webcam");
}
该代码正确地执行,但是执行时出现以下错误:
OpenCV Error: Unspecified error (Failed to enumerate production trees: Can't create any node of the requested type!) in CvCapture_OpenNI, file /home/samarth/OpenCV-2.3.0/modules/highgui/src/cap_openni.cpp, line 188 terminate called after throwing an instance of 'cv::Exception' what(): /home/samarth/OpenCV-2.3.0/modules/highgui/src/cap_openni.cpp:188: error: (-2) Failed to enumerate production trees: Can't create any node of the requested type! in function CvCapture_OpenNI
中止
有人遇到过同样的问题吗?任何解决此问题的想法将不胜感激。
最佳答案
此问题已在OpenCV 2.3.1版本中修复。
有关详细信息,请参见以下链接:
https://code.ros.org/trac/opencv/ticket/1237
关于exception - openNI干扰cvCreateCameraCapture(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7137117/