当前位置:网站首页>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
边栏推荐
- Using computed in uni app solves the abnormal display of data () value in tab switching
- Data Lake (11): Iceberg table data organization and query
- Contrôleur pour threejs cube Space Basic Controller + Inertial Control + Flight Control
- Dangbei projection 4K laser projection X3 Pro received unanimous praise: 10000 yuan projector preferred
- Design of non main lamp: how to make intelligent lighting more "intelligent"?
- 2022家用投影仪首选!当贝F5强悍音画效果带来极致视听体验
- 3. Function pointers and pointer functions
- Solve the problem that openocd fails to burn STM32 and cannot connect through SWD
- Teamtalk source code analysis win client
- [deep learning] simple implementation of neural network forward propagation
猜你喜欢

YOLOv3&YOLOv5输出结果说明

Fabric. JS zoom canvas

MQ教程 | Exchange(交换机)

Systemserver process

Tujia muniao meituan has a discount match in summer. Will it be fragrant if the threshold is low?

每日学习2

Daily learning 2

Fabric.js 自由绘制圆形

Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022

QT new project
随机推荐
途家木鸟美团夏日折扣对垒,门槛低就一定香吗?
Use of swagger
2022 home projector preferred! Dangbei F5 brings the ultimate audio-visual experience with its powerful audio-visual effect
Fabric. JS dynamically set font size
一般来讲,如果频繁出现inconsistent tab and space的报错
《可供方案开发》口算训练机/数学宝/儿童口算宝/智能数学宝 LCD液晶显示驱动IC-VK1622(LQFP64封装),原厂技术支持
自定义事件,全局事件总线,消息订阅与发布,$nextTick
Fabric.js 手动加粗文本iText
OpenHarmony笔记-----------(四)
Use of freemaker
软件测试的方法
Go operation redis
Fabric. Keep the original level when JS element is selected
threejs的控制器 立方体空间 基本控制器+惯性控制+飞行控制
Custom events, global event bus, message subscription and publishing, $nexttick
PHP linked list creation and traversal
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 '
Multi rotor aircraft control using PID and LQR controllers
Development and design of animation surrounding mall sales website based on php+mysql
kaggle如何使用utility script