QTKit没有找到任何连接的视频输入设备。

3
每当我尝试运行一个用于从MacBook Pro 13英寸(内置的iSight)相机中抓取帧的简单应用程序时,就会出现以下错误:

(参考链接)

QTKit didn't find any attached Video Input Devices!
Warning, camera failed to properly initialize!
Cleaned up camera.

我尝试将-1、0作为参数传递给cvCreateCameraCapture()cv::VideoCapture对象,但都没有起作用。需要注意的是,在这台机器上我使用了OpenCV 2.3.1相当长的时间,并且通过传递-1参数可以正常工作。此问题似乎出现在Mac OS X 10.7.5上的OpenCV v2.4.2和v2.4.3版本中。有任何想法吗?
编辑:经过一些研究,我发现QTKit是QuickTime Kit,与Qt无关。因此,下一步的逻辑操作是禁用OpenCV构建中的QTKit,而通过标志-DWITH_QUICKTIME=YES来实现这一点,该标志强制OpenCV使用QuickTime进行视频I/O,而不是QTKit。不幸的是,这种解决方案也没有起作用,因为它引起了几个编译错误,我不想处理。
[ 32%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_qt.cpp.o
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:75: error: ‘Movie’ does not name a type
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp: In functionCvCapture_QT_Movie* icvCaptureFromFile_QT(const char*)’:
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:100: warning: declaration of ‘did_enter_movies’ shadows a global declaration [-Wshadow]
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:67: warning: shadowed declaration is here [-Wshadow]
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:103: error: ‘EnterMovies’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp: In function ‘int icvOpenFile_QT_Movie(CvCapture_QT_Movie*, const char*)’:
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:142: error: ‘ClearMoviesStickyError’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:145: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:161: error: ‘kQTPOSIXPathStyle’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:161: error: ‘QTNewDataReferenceFromFullPathCFString’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:169: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:169: error: ‘newMovieActive’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:169: error: ‘newMovieAsyncOK’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:170: error: ‘NewMovieFromDataRef’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:190: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:190: error: ‘nextTimeMediaSample’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:190: error: ‘nextTimeEdgeOK’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:191: error: ‘GetMovieNextInterestingTime’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:205: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:212: error: ‘GetMoviesError’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:213: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:213: error: ‘GetMovieBox’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:218: error: ‘QTNewGWorld’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:220: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:220: error: ‘SetMovieGWorld’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp: In function ‘int icvClose_QT_Movie(CvCapture_QT_Movie*)’:
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:243: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:247: error: ‘DisposeGWorld’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:248: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:248: error: ‘DisposeMovie’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp: In function ‘double icvGetProperty_QT_Movie(CvCapture_QT_Movie*, int)’:
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:264: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:281: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:281: error: ‘GetMovieTimeScale’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:286: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:286: error: ‘GetMovieDuration’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:300: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:300: error: ‘GetMovieDuration’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:301: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:301: error: ‘GetMovieTimeScale’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp: In function ‘int icvSetProperty_QT_Movie(CvCapture_QT_Movie*, int, double)’:
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:331: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:351: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:351: error: ‘GetMovieTimeScale’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:356: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:356: error: ‘GetMovieDuration’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:370: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:370: error: ‘nextTimeStep’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:371: error: ‘GetMovieNextInterestingTime’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:372: error: ‘GetMoviesError’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:385: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:385: error: ‘nextTimeStep’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:386: error: ‘GetMovieNextInterestingTime’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:387: error: ‘GetMoviesError’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:408: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:408: error: ‘nextTimeStep’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:409: error: ‘GetMovieNextInterestingTime’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:410: error: ‘GetMoviesError’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp: In function ‘int icvGrabFrame_QT_Movie(CvCapture_QT_Movie*)’:
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:441: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:449: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:449: error: ‘SetMovieTimeValue’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:450: error: ‘GetMoviesError’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:458: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:458: error: ‘GetMovieTime’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:462: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:462: error: ‘nextTimeStep’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:462: error: ‘GetMovieNextInterestingTime’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp: In functionconst void* icvRetrieveFrame_QT_Movie(CvCapture_QT_Movie*, int)’:
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:484: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:494: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:494: error: ‘UpdateMovie’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:495: error: ‘GetMoviesError’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:503: error: ‘struct CvCapture_QT_Movie’ has no member named ‘myMovie’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:503: error: ‘MoviesTask’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:515: error: ‘GetGWorldPixMap’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:516: error: ‘LockPixels’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:517: error: ‘GetPixBaseAddr’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:517: error: ‘GetPixRowBytes’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:523: error: ‘UnlockPixels’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp: At global scope:
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:556: error: ‘SeqGrabComponent’ does not name a type
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:557: error: ‘SGChannel’ does not name a type
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:560: error: ‘ImageSequence’ does not name a type
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp: In functionCvCapture_QT_Cam* icvCaptureFromCam_QT(int)’:
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:590: error: ‘EnterMovies’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp: At global scope:
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:609: warning: unused parameter ‘capture’ [-Wunused-parameter]
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:609: warning: unused parameter ‘property_id’ [-Wunused-parameter]
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:616: warning: unused parameter ‘capture’ [-Wunused-parameter]
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:616: warning: unused parameter ‘property_id’ [-Wunused-parameter]
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:616: warning: unused parameter ‘value’ [-Wunused-parameter]
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:853: error: ‘SGChannel’ was not declared in this scope
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:853: error: expected primary-expression before ‘raw_data’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:853: error: expected primary-expression before ‘long’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:853: error: expected primary-expression before ‘long’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:853: error: expected primary-expression before ‘long’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:853: error: expected primary-expression before ‘,’ token
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:853: error: expected primary-expression before ‘short’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:853: error: expected primary-expression before ‘long’
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:853: error: initializer expression list treated as compound expression
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:854: error: expected ‘,’ or ‘;’ before ‘{’ token
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:238: warning: ‘int icvClose_QT_Movie(CvCapture_QT_Movie*)’ defined but not used
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:261: warning: ‘double icvGetProperty_QT_Movie(CvCapture_QT_Movie*, int)’ defined but not used
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:328: warning: ‘int icvSetProperty_QT_Movie(CvCapture_QT_Movie*, int, double)’ defined but not used
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:438: warning: ‘int icvGrabFrame_QT_Movie(CvCapture_QT_Movie*)’ defined but not used
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:481: warning: ‘const void* icvRetrieveFrame_QT_Movie(CvCapture_QT_Movie*, int)’ defined but not used
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:98: warning: ‘CvCapture_QT_Movie* icvCaptureFromFile_QT(const char*)’ defined but not used
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:572: warning: ‘int icvOpenCamera_QT(CvCapture_QT_Cam*, int)’ declared ‘static’ but never defined
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:573: warning: ‘int icvClose_QT_Cam(CvCapture_QT_Cam*)’ declared ‘static’ but never defined
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:609: warning: ‘double icvGetProperty_QT_Cam(CvCapture_QT_Cam*, int)’ defined but not used
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:616: warning: ‘int icvSetProperty_QT_Cam(CvCapture_QT_Cam*, int, double)’ defined but not used
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:576: warning: ‘int icvGrabFrame_QT_Cam(CvCapture_QT_Cam*)’ declared ‘static’ but never defined
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:577: warning: ‘const void* icvRetrieveFrame_QT_Cam(CvCapture_QT_Cam*, int)’ declared ‘static’ but never defined
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:586: warning: ‘CvCapture_QT_Cam* icvCaptureFromCam_QT(int)’ defined but not used
/OpenCV-2.4.3/modules/highgui/src/cap_qt.cpp:853: warning: ‘icvDataProc_QT_Cam’ defined but not used
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_qt.cpp.o] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make: *** [all] Error 2

尝试在没有QT的情况下构建OpenCV并检查。 - ArtemStorozhuk
我尝试过了,但对我没有用。我还强制OpenCV使用QUICKTIME而不是libdc1394,然后出现了编译错误,与*DisposeGWorld* was not declared in this scope有关(这表明OpenCV正在使用已弃用的Mac API)。 - karlphillip
你说的“对我没用”是什么意思?出现了错误吗?如果是,能否把错误信息发出来? - ArtemStorozhuk
我已将此报告为问题(http://code.opencv.org/issues/2726)。 - karlphillip
3个回答

3

我报告了这个问题,但现在我认为可能是我的系统特定的,我会尝试进行更多的测试来澄清。

无论如何,以下是我解决这个问题所需的步骤:

编辑modules/highgui/src/cap_qtkit.mm并跳转到第313行以查看实现:

int CvCaptureCAM::startCaptureDevice(int cameraNum) {

我们将对此方法进行更改,因此请找到以下代码块:
if (cameraNum >= 0) { 
    int nCameras = [devices count];
    if( cameraNum < 0 || cameraNum >= nCameras )   
        return 0;
    device = [devices objectAtIndex:cameraNum] ;
} else {
    device = [QTCaptureDevice defaultInputDeviceWithMediaType:QTMediaTypeVideo]  ;
} 

并将其 替换为:

if (cameraNum >= 0) { 
    int nCameras = [devices count];
    if( cameraNum > nCameras )
        return 0;
    cameraNum--;
    device = [devices objectAtIndex:cameraNum] ;
} else {
    device = [QTCaptureDevice defaultInputDeviceWithMediaType:QTMediaTypeVideo]  ;
} 

重新编译OpenCV,不要忘记在系统上重新安装它。

2

只需重新启动相机即可解决问题。 sudo killall VDCAssistant


0

我曾经遇到同样的问题,但是没有找到任何解决方案。通过试错,我发现我的OpenCV版本已经损坏。因此,我删除了它并安装了一个新的版本。您可以使用以下两种方法之一: 1. 终端 运行 brew uninstall opencv3 命令来卸载 opencv, 然后使用 sudo apt-get install libopencv-dev python-opencv 命令安装它。

2. Anaconda 事实上,我用这种方法解决了自己的问题。

打开Anaconda。 进入环境部分,选择你的环境如下: enter image description here 然后点击已安装并搜索opencventer image description here 选择opencv包并卸载它。然后尝试通过选择未安装并搜索opencv来重新安装opencv。请注意安装正确的版本。 enter image description here

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接