opencv视频采集和虚拟机上的摄像头访问
opencv video capture and camera access on virtual machine
我正试图使用电脑上的网络摄像头实时捕捉图像。我正在使用虚拟盒子运行Ubuntu,我知道我需要设置USB设置才能使用网络摄像头,但我还需要安装网络摄像头驱动程序吗?如果是的话,我该怎么做!!
我安装了virtualbox 5.0.6ubuntu 14.04.3
我正在运行一个windows 10机器
这是我正在运行的代码,我得到"错误:无法访问相机!"。。
你能帮忙吗!
// Get access to the webcam.
void initWebcam(VideoCapture &videoCapture, int cameraNumber)
{
// Get access to the default camera.
try {
videoCapture.open(cameraNumber);
} catch (Exception &e) {}
if ( !videoCapture.isOpened() ) {
cerr << "ERROR: Could not access the camera!" << endl;
exit(1);
}
cout << "Loaded camera " << cameraNumber << "." << endl;
}
int main(int argc, char** argv)
{
const int DESIRED_CAMERA_WIDTH = 640;
const int DESIRED_CAMERA_HEIGHT = 480;
int cameraNumber = 0;
// Get access to the camera.
VideoCapture camera;
initWebcam(camera, cameraNumber);
camera.set(CV_CAP_PROP_FRAME_WIDTH, DESIRED_CAMERA_WIDTH);
camera.set(CV_CAP_PROP_FRAME_HEIGHT, DESIRED_CAMERA_HEIGHT);
while (true) {
// Grab the next camera frame. Note that you can't modify camera frames.
Mat cameraFrame;
camera >> cameraFrame;
if( cameraFrame.empty() ) {
cerr << "ERROR: Couldn't grab the next camera frame." << endl;
exit(1);
}
Mat displayedFrame = Mat(cameraFrame.size(), CV_8UC3);
// DO SOME PROCESSING
return 0;
}
我得到了同样的错误。发生这种情况是因为我的虚拟机没有检测到我的网络摄像头。我已经安装了cheese(一个使用网络摄像头的程序)并确认了这一点。所以,我已经打开了虚拟机配置上的USB控制器。然后,在运行虚拟机时,我在"设备"菜单中查看了我的网络摄像头,一切都开始工作了!。希望能有所帮助。
这似乎是一个授权问题。尝试从命令行使用sudo运行。另一个问题可能是你选择了错误的摄像头(例如,你有一台笔记本电脑,上面也有集成摄像头),你可以使用"dmesg|grep-usb"在连接到vm的设备上得到一些提示
相关文章:
- 通过方法访问结构
- Qt小部件中的摄像头访问
- 媒体基金会可以允许多个客户端同时访问单个网络摄像头设备吗?
- 使用OpenCV访问摄像头(通过GSTREAMER)
- 我如何访问IP摄像机错误(摄像头 /型号:Grundig / GCI-K1505B)
- systemd无法通过opencv访问摄像头
- EasyAr访问摄像头框架作为OpenCV垫子
- IP摄像头使用OpenCV访问
- 如何访问OpenCV中UDEV与UDEV相关的网络摄像头
- 使用USB编程访问多个网络摄像头
- 如何使用android ndk访问摄像头
- 如何访问MacBook上的网络摄像头
- cv::VideoCapture:从两个线程访问同一个网络摄像头
- 在Windows 10/OpenCV下访问网络摄像头时出现问题
- 无法访问我的网络摄像头opencv ubuntu
- opencv视频采集和虚拟机上的摄像头访问
- 我如何使用OpenCV访问外部网络摄像头?
- 通过Cortex-M3访问USB摄像头
- 如何在visual C++2010或2008中使用OpenCV 2.1访问ip摄像头(compro IP50W)
- FFMPEG与c++访问一个网络摄像头