当前位置:网站首页>OpenCV调用USB摄像头的点滴
OpenCV调用USB摄像头的点滴
2022-07-02 11:21:00 【thequitesunshine007】
1 前言
一般项目中使用的相机多为工业相机,其厂商均配备了完善的二次开发SDK,含有丰富的接口。
但本人最近遇到了一款相机,最大的优点就是便宜(是同等工业相机价格的几分之一),遗憾的是没有任何的SDK提供(只有一个amcap.exe),对于使用者而言这就尴尬了。
OpenCV中的vediocapture类含有访问并控制USB相机的功能(前提是相机本身支持,并不是所有的USB相机都支持被vediocapture直接访问)。
2 VideoCapture打开相机时间过久
如果以cv::VideoCapture capture(device_index);打开相机设备,程序运行异常缓慢,在输出窗口输出大量加载pdb符号的信息,大概需要等30s才能成功打开设备,这显然是让人抓狂的。
2.1 分析原因
CV_WRAP explicit VideoCapture(int index, int apiPreference = CAP_ANY);
cv::VideoCapture在逐个轮询到底哪个后台驱动合适,这个遍历显然是耗时的。
我们没有指定apiPreference参数时,它默认便是逐个遍历,可能就很耗时。
2.2 解决办法
直接指定apiPreference参数,指定启动相机所使用的后台API。可以指定为CAP_DSHOW或者其他(因地制宜).
cv::VideoCapture capture(device_index, cv::CAP_DSHOW);
打开设备的时间瞬间从30s降为不到200ms.
3 曝光时间设置
capture.set(cv::CAP_PROP_EXPOSURE, -5);
这里的-5是什么含义呢&#x
边栏推荐
- 3. Function pointers and pointer functions
- Fabric. JS manual bold text iText
- Qt新建项目
- Available solution development oral arithmetic training machine / math treasure / children's oral arithmetic treasure / intelligent math treasure LCD LCD driver ic-vk1622 (lqfp64 package), original te
- Who is better, Qianyuan projection Xiaoming Q1 pro or Jimi new play? Which configuration is higher than haqu K1?
- There is no solution to the decryption error of the remote user 'sa' and the service master password mapped from the remote server 'to the local user' (null) /sa '
- OpenHarmony笔记-----------(四)
- Analysis of CPU surge in production environment service
- Tujia muniao meituan has a discount match in summer. Will it be fragrant if the threshold is low?
- The global special paper revenue in 2021 was about $27 million, and it is expected to reach $35 million in 2028. From 2022 to 2028, the CAGR was 3.8%
猜你喜欢

Certik released the defi security report in 2021, disclosing key data of industry development (PDF download link attached)

关于Flink框架窗口(window)函数最全解析

千元投影小明Q1 Pro和极米NEW Play谁更好?和哈趣K1比哪款配置更高?

Who is better, Qianyuan projection Xiaoming Q1 pro or Jimi new play? Which configuration is higher than haqu K1?

< schematic diagram of oral arithmetic exercise machine program development> oral arithmetic exercise machine / oral arithmetic treasure / children's math treasure / children's calculator LCD LCD driv

腾讯云 TStor 统一存储通过信通院首批文件存储基础能力评测

Fabric. JS upper dash, middle dash (strikethrough), underline

MQ教程 | Exchange(交换机)

当贝投影4K激光投影X3 Pro获得一致好评:万元投影仪首选

There is no solution to the decryption error of the remote user 'sa' and the service master password mapped from the remote server 'to the local user' (null) /sa '
随机推荐
Chinese science and technology from the Winter Olympics (III): the awakening and evolution of digital people
Fabric.js 动态设置字号大小
In 2021, the global TCB adapter revenue was about $93 million, and it is expected to reach $315.5 million in 2028
threejs的控制器 立方體空間 基本控制器+慣性控制+飛行控制
Fabric. JS free draw circle
Fabric.js 元素被选中时保持原有层级
Available solution development oral arithmetic training machine / math treasure / children's oral arithmetic treasure / intelligent math treasure LCD LCD driver ic-vk1622 (lqfp64 package), original te
Launcher startup process
途家木鸟美团夏日折扣对垒,门槛低就一定香吗?
QT new project
Default slot, named slot, scope slot
Data consistency between redis and database
当贝投影4K激光投影X3 Pro获得一致好评:万元投影仪首选
[development environment] Dell computer system reinstallation (download Dell OS recovery tool | use Dell OS recovery tool to make USB flash disk system | install system)
数据湖(十一):Iceberg表数据组织与查询
自定义事件,全局事件总线,消息订阅与发布,$nextTick
PHP linked list creation and traversal
博睿数据一体化智能可观测平台入选中国信通院2022年“云原生产品名录”
2、const 型指针
How kaggle uses utility script