我在ubuntu 11.04上使用opencv 2.3。编译时,为了完整起见,我将WITH_OPENNI = ON。 (现在很遗憾,因为我不打算很快使用kinect,并且openni给我带来了正常的opencv程序带来的麻烦)openNI干扰cvCreateCameraCapture()
无论如何,我测试了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
中止
已有人面临吨他同样的问题?任何想法来解决这个问题将不胜感激。