我使用opencv 2.4.3访问网络摄像头时遇到问题.
我的系统:
惠普Probook 4530s - 惠普固定高清网络摄像头
Ubuntu 12.10
OpenCV 2.4.3
如果我想捕获我的内置摄像头我得到错误:捕获是NULL
我正在使用http://opencv.willowgarage.com/wiki/CameraCapture示例代码.
示例代码是:
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
// A Simple Camera Capture Framework
int main() {
CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
if ( !capture ) {
fprintf( stderr, "ERROR: capture is NULL \n" );
getchar();
return -1;
}
// Create a window in which the captured images will be presented
cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
// Show the image captured from the camera in the window and repeat
while ( 1 ) {
// Get one frame
IplImage* frame = cvQueryFrame( capture );
if ( !frame ) {
fprintf( stderr, "ERROR: frame is null...\n" );
getchar();
break;
}
cvShowImage( "mywindow", frame );
// Do not release the frame!
//If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
//remove higher bits using AND operator
if ( (cvWaitKey(10) & 255) == 27 ) break;
}
// Release the capture device housekeeping
cvReleaseCapture( &capture );
cvDestroyWindow( "mywindow" );
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我也尝试使用输入终端xawtv -hwscan.我得到这个输出:
looking for available devices
port 129-144
type : Xvideo, image scaler
name : Intel(R) Textured Video`
/dev/video0: OK
[ -device /dev/video0 ]
type : libv4l
name : HP HD Webcam [Fixed]
flags: capture
Run Code Online (Sandbox Code Playgroud)
然后我可以访问我的网络摄像头输入xawtv video0.我想我的网络摄像头没问题.我在使用opencv时遇到了麻烦.
几分钟前我解决了我的问题.我决定为处理类似错误的人分享我的解决方案.
首先我没有安装下面的一些数据包(我不记得它们中的哪一个,所以我粘贴了所有这些数据包)
中的libjpeg62-dev的
的libtiff4-dev的
的zlib1g-dev的
libjasper-dev的
使用libavcodec-dev的
libdc1394-22-dev的
libgstreamer0.10-dev的
libgstreamer-插件 - base0.10-dev的
了libavformat-dev的
libv4l-dev的
libswscale-dev的
然后,您应该使用此代码配置您的cmake进程
cmake -D CMAKE_BULD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON USE_V4L=ON WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON USE_GStreamer=ON ..
Run Code Online (Sandbox Code Playgroud)
请注意USE_V4L = ON此代码..
我希望你在阅读我的解决方案后解决.
归档时间: |
|
查看次数: |
14697 次 |
最近记录: |