当前位置:网站首页>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
边栏推荐
- Dangbei projection 4K laser projection X3 Pro received unanimous praise: 10000 yuan projector preferred
- Fabric.js 缩放画布
- Packet capturing tool Fiddler learning
- Solving the longest subsequence with linear DP -- three questions
- 博睿数据一体化智能可观测平台入选中国信通院2022年“云原生产品名录”
- How many knowledge points can a callable interface have?
- uni-app中使用computed解决了tab切换中data()值显示的异常
- Quarkus学习四 - 项目开发到部署
- Whole house Wi Fi: a pain point that no one can solve?
- 关于Flink框架窗口(window)函数最全解析
猜你喜欢
快解析:轻松实现共享上网
途家木鸟美团夏日折扣对垒,门槛低就一定香吗?
[deep learning] simple implementation of neural network forward propagation
MySQL 45 lecture - learning from the actual battle of geek time MySQL 45 Lecture Notes - 04 | easy to understand index (Part 1)
In 2021, the global revenue of structural bolts was about $796.4 million, and it is expected to reach $1097.6 million in 2028
没有从远程服务器‘‘映射到本地用户‘(null)/sa‘的远程用户‘sa‘及服务主密码解密错误的解决办法
MQ tutorial | exchange (switch)
C crystal report printing
跨服务器数据访问的创建链接服务器方法
每日学习3
随机推荐
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
Fabric.js 缩放画布
2022家用投影仪首选!当贝F5强悍音画效果带来极致视听体验
PHP linked list creation and traversal
没有从远程服务器‘‘映射到本地用户‘(null)/sa‘的远程用户‘sa‘及服务主密码解密错误的解决办法
卷积神经网络(入门)
Thymeleaf dependency
Solving the longest subsequence with linear DP -- three questions
Analysis of CPU surge in production environment service
途家木鸟美团夏日折扣对垒,门槛低就一定香吗?
Go operation redis
A white hole formed by antineutrons produced by particle accelerators
篇9:XShell免费版安装
Chinese science and technology from the Winter Olympics (III): the awakening and evolution of digital people
数据湖(十一):Iceberg表数据组织与查询
NLA自然语言分析,让数据分析更智能
Pycharm连接远程服务器
The most complete analysis of Flink frame window function
Pychart connects to the remote server
[to be continued] [UE4 notes] l5ue4 model import