当前位置:网站首页>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
边栏推荐
- [to be continued] [UE4 notes] l5ue4 model import
- Codeforces Round #803 (Div. 2)(A~D)
- 什么是 eRDMA?丨科普漫画图解
- <口算練習機 方案開發原理圖>口算練習機/口算寶/兒童數學寶/兒童計算器 LCD液晶顯示驅動IC-VK1621B,提供技術支持
- 数据湖(十一):Iceberg表数据组织与查询
- Delete element (with transition animation)
- PyQt5_QScrollArea内容保存成图片
- kaggle如何使用utility script
- Yolov3 & yolov5 output result description
- Basic knowledge of QT original code
猜你喜欢

In 2021, the global revenue of structural bolts was about $796.4 million, and it is expected to reach $1097.6 million in 2028

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

Codeforces Round #803 (Div. 2)(A~D)

MySQL 45 lecture - learning from the actual battle of geek time MySQL 45 Lecture Notes - 04 | easy to understand index (Part 1)

Daily learning 2

Analysis of CPU surge in production environment service

Daily learning 3

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 '

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%

Essential elements of science fiction 3D scenes - City
随机推荐
2022 home projector preferred! Dangbei F5 brings the ultimate audio-visual experience with its powerful audio-visual effect
Go operation redis
freemarker的使用
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
[development environment] Dell computer system reinstallation (download Dell OS recovery tool | use Dell OS recovery tool to make USB flash disk system | install system)
Word frequency statistics & sorting
<口算练习机 方案开发原理图>口算练习机/口算宝/儿童数学宝/儿童计算器 LCD液晶显示驱动IC-VK1621B,提供技术支持
Design of non main lamp: how to make intelligent lighting more "intelligent"?
Thymeleaf dependency
Daily learning 2
PHP linked list creation and traversal
NLA natural language analysis makes data analysis more intelligent
Fabric. JS dynamically set font size
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 '
Launcher startup process
关于Flink框架窗口(window)函数最全解析
Analysis of CPU surge in production environment service
STM32标准固件库函数名(一)
一般来讲,如果频繁出现inconsistent tab and space的报错
博睿数据一体化智能可观测平台入选中国信通院2022年“云原生产品名录”