虚拟机上使用 opecnv 读取USB摄像头无法显示
使用opecv读取USB摄像头时候,无法显示图像。
设置
首先查看虚拟机Ubuntu检测摄像头是否已正常插入:
ls /dev/video*
结果为:

设置虚拟机USB属性:

USB的兼容性设置为USB3.0。

将USB连接到虚拟机上。
程序
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <time.h>
#include <math.h>
#include <sys/ioctl.h>
#include <linux/fb.h>
#include <iostream>
#include <signal.h>
#include <string>
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main()
{
VideoCapture capture(1);
if(capture.isOpened())
{
cout<<"success"<<endl;
}
Mat frame;
while (capture.isOpened())
{
capture >> frame;
if (!frame.empty())
{
//imshow("edges", frame);
imwrite("test.bmp",frame);
imshow("capture", frame);
//cout<<"can get ";
}
else
{
//cout<<"can not get";
}
if(waitKey(10) == 27)
break;
}
return 0;
}
Makefile
LIBS += -L /usr/lib/ -lstdc++
LIBS += `pkg-config --libs opencv`
TARGET = test
target:
$(CC) $(CFLAGS) -o $(TARGET) $(SRCS) $(INC) $(LIBS)
#*****************finished building*****************
clean:
rm -f $(TARGET)
成功打开:

注意
capture(0)是笔记本摄像头,capture(1)是USB摄像头。
虚拟机上使用 opecnv 读取USB摄像头无法显示的更多相关文章
- python opencv 读取USB摄像头的像素问题
问题描述 每次调用capture读取video的时候,还回的像素都是640x480,不管是笔记本的摄像头还是USB摄像头,明明我的摄像头是支持130万读取的功能的呀. 问题分析 一番查找,关于用ope ...
- ubuntu-Linux系统读取USB摄像头数据(gspca)
将摄像头图像保存为jpg格式.摄像头需要是gspca免驱的.uvc若用uvc格式的需要在图像中插入Huffman表.否则无法正常显示. 程序代码: #include <stdio.h> # ...
- ubuntu-Linux系统读取USB摄像头数据(uvc)
这几天在做小车的过程中,需要用到图像采集.我想现在用的摄像头是UVC免驱的.根据国嵌的教程中有一个gspca摄像头的程序.我发现把gspca的采集程序用到uvc上时,在显示图像的时候提示没有huffm ...
- unity3d 读取usb摄像头
using UnityEngine; using System.Collections; public class C : MonoBehaviour { private WebCamTexture ...
- USB摄像头无法正常读取问题
opencv读取摄像头或者视频一种是早期版本的IplImage结构体,图片就存在结构体指针IplImage*中,另一种是Mat类,两者在操作上略有差异,且opencv2都兼容这两个版本,前面的博客也说 ...
- [运维] 如何访问虚拟机上的 Tomcat ?
环境: 虚拟机: VMware 15 pro 操作系统 Linux CentOS 7 64 物理机: Windows 7 事先准备: 1: 下载 Tomcat 的压缩包 apache-t ...
- 在linux下玩转usb摄像头
硬件平台:PC机一台 .usb摄像头 操作系统:Linux3.0.8 交叉编译环境:arm-none-Linux-gnueabi-gcc 4.5.1 调试步骤: 一.linux 内核解压 1.1使用 ...
- 25、写一个USB摄像头驱动程序(有ioctrl分析)
videobuf2-core.h中的vb2_buffer,记录了v4l2_buffer ,驱动可以对vb2_buffer的v4l2_buffer进行操控, vb2_buffer是v4l2框架层的代码, ...
- 在Windows Azure虚拟机上开发Windows 8 应用
前提条件 Windows Azure开发者账号:如果您拥有微软MSDN Subscription账户,那么意味着您可免费申请Windows Azure开发者账号. 创建虚拟机 点击Windows Az ...
随机推荐
- 3-为什么很多 对 1e9+7(100000007)取模
首先有很多题目的答案是很大的,然而出题人的本意也不是让选手写高精度或者Java,所以势必要让答案落在整型的范围内.那么怎么做到这一点呢,对一个很大的质数取模即可(自行思考为什么不是小数).那么如果您学 ...
- 关于super关键字
1.在Java中,有时会遇到子类中的成员变量或方法与父类中的成员变量或方法同名.此时父类的成员变量或方法就会被隐藏(可以理解为重写),如果还想要使用父类中的这个成员变量或方法,就需要用到super. ...
- [c++] How many bytes do pointers take up?
How many bytes do pointers take up? on 16 bit systems take up 2 bytes on 32 bit systems take up 4 by ...
- code1085 数字游戏
划分dp 把环变链(读入4 3 -1 2变成4 3 -1 2 4 3 -1 2) 设dp[i][j][k]为把i~j分成k份,各部分内的数字相加,相加所得的k个结果对10取模后再相乘,最终得到的一个数 ...
- [Jenkins] Jenkins 执行 Composite 模式的 SoapUI Project
cd %WORKSPACE% cmd /c call "D:\Program Files\SmartBear\ReadyAPI-1.3.1\bin\testrunner.bat" ...
- CSS3 圆环状进度条
HTML: <div class="wrap"> <div class="progress-radial progress-25"> & ...
- 扩展JPA方法,重写save方法
为什么要重构save? jpa提供的save方法会将原有数据置为null,而大多数情况下我们只希望跟新自己传入的参数,所以便有了重写或者新增一个save方法. 本着解决这个问题,网上搜了很多解决方案, ...
- SpringMVC错误集中营
1.eclipse里的错误提示为The import javax.servlet.http.HttpServletRequest cannot be resolved 1.这是因为工程里面web-in ...
- “undefined reference to JNI_GetCreatedJavaVM”和“File format not recognized”错误原因分析
"undefined reference to JNI_GetCreatedJavaVM"和"File format not recognized"错误原因分析 ...
- RegularExpression
目录 文章背景 目录 概述 基本概念 目的 特点 符号 实例 说明 参考文章 版本记录 layout: default title: RegularExpression category: [Tech ...