Opencv无法访问我的网络摄像头 [英] Opencv cannot access my webcam

查看:173
本文介绍了Opencv无法访问我的网络摄像头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用opencv 2.4.3访问网络摄像头.

I have trouble with accessing webcam using opencv 2.4.3.

我的系统:

Hp Probook 4530s-HP固定高清网络摄像头

Hp Probook 4530s - HP Fixed HD Webcam

Ubuntu 12.10

Ubuntu 12.10

OpenCV 2.4.3

OpenCV 2.4.3

İf我想捕获我的内置相机时出现错误:捕获为NULL

İf I want to capture my built-in camera i get ERROR: capture is 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;
}

我还尝试通过键入终端对 xawtv -hwscan 进行了尝试.我得到以下输出:

I also tried with xawtv -hwscan using typing terminal. I get this output:

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

然后我可以输入 xawtv video0 来访问我的网络摄像头.我想我的网络摄像头没有问题. 我在使用opencv时遇到麻烦.

then I can access my webcam typing xawtv video0. I think I have no trouble with my webcam. I have trouble with opencv.

推荐答案

几分钟前,我解决了我的问题.我决定将我的解决方案分享给处理类似错误的人.

I solved my problem few minutes ago. And I decided share my solution for people who handling similar error.

首先,我没有安装下面的某些包装(我不记得是哪个包装,所以我将它们全部粘贴了)

First I didnt install some of below packets ( I dont remember which of them, so I paste all of them)

libjpeg62-dev

libjpeg62-dev

libtiff4-dev

libtiff4-dev

zlib1g-dev

zlib1g-dev

libjasper-dev

libjasper-dev

libavcodec-dev

libavcodec-dev

libdc1394-22-dev

libdc1394-22-dev

libgstreamer0.10-dev

libgstreamer0.10-dev

libgstreamer-plugins-base0.10-dev

libgstreamer-plugins-base0.10-dev

libavformat-dev

libavformat-dev

libv4l-dev

libv4l-dev

libswscale-dev

libswscale-dev

然后,您应该使用此代码配置cmake进程

Then You should configure your cmake process with this code

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 ..

请注意USE_V4L = ON此代码.

Please notice USE_V4L=ON this code..

希望您阅读我的解决方案后能解决.

I hope you solve after reading my solution.

这篇关于Opencv无法访问我的网络摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆