当前位置:网站首页>捡起MATLAB的第(10)天
捡起MATLAB的第(10)天
2022-04-23 15:54:00 【Sola_Ex】
Matlab摄像头照片获取
摄像头开启代码
摄像头开启的语句:
obj =videoinput('DeviceName',1,'YUY2_640*480');
-
DeviceName是你的可用的音视频输入设备。
-
“1”表示打开的设备。
-
YUY2_640*480表示一种格式。
格式配置
set(obj,'ReturnedColorSpace','rgb')
配置格式为RGB格式。
preview(obj);
获取图像
getphoto = getsnapshot(obj);
filename = int2str(1);
filename = [filename,'jpg']
inwrite(getphoto,filename);
关掉摄像头
stop(obj);
closepreview(obj);
delete(obj);
clear;
关于问题
1、使用obj =videoinput(‘DeviceName’,1,‘YUY2_640*480’);后
错误使用 videoinput (line 217)
Invalid ADAPTORNAME specified. Type ‘imaqhwinfo’ for a list of available ADAPTORNAMEs. Image acquisition adaptors may be available as downloadable support packages. Open Support
Package Installer to install additional vendors.
出现这个问题的原因可能是你使用的DeviceName不对,或者是安装的Matlab版本缺少插件。所以首先先查找对应的设备名,使用:
info=imaqhwinfo
将会出现一下信息:
info =
InstalledAdaptors: {
}
MATLABVersion: '8.3 (R2014a)'
ToolboxName: 'Image Acquisition Toolbox'
ToolboxVersion: '4.7 (R2014a)'
在InstalledAdaptors里面本来应该有设备名字,但是现在没有,证明其实是因为缺少插件。因此再次看上面的错误提示,
Support Package Installer
这句话是画了下划线的,点击它,就会出现插件下载界面,下载安装即可。最后在运行就可以看到设备了
info =
InstalledAdaptors: {
'dcam'}
MATLABVersion: '8.3 (R2014a)'
ToolboxName: 'Image Acquisition Toolbox'
ToolboxVersion: '4.7 (R2014a)'
我的设备名字是dcam
最后给出一个摄像头0.5s拍一次图像的代码:
clear;
clc;
obj =videoinput('winvideo',1);
set(obj,'ReturnedColorSpace','rgb');
preview(obj);
for i=1:10
getphoto = getsnapshot(obj);
filename = int2str(i);
filename = [filename,'.jpg']
imwrite(getphoto,filename);
pause(0.5);
end
stop(obj);
closepreview(obj);
delete(obj);
clear;
版权声明
本文为[Sola_Ex]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_42312125/article/details/108333041
边栏推荐
- 糖尿病眼底病变综述概要记录
- Go language, condition, loop, function
- Import address table analysis (calculated according to the library file name: number of imported functions, function serial number and function name)
- s16. One click installation of containerd script based on image warehouse
- leetcode-396 旋转函数
- Sortby use of spark operator
- C语言自编字符串处理函数——字符串分割、字符串填充等
- Calculate the number of occurrences of a character
- Spark 算子之groupBy使用
- js正則判斷域名或者IP的端口路徑是否正確
猜你喜欢
API IX JWT auth plug-in has an error. Risk announcement of information disclosure in response (cve-2022-29266)
Partitionby of spark operator
Temporal model: long-term and short-term memory network (LSTM)
Unity shader learning
C, calculation method and source program of bell number
多级缓存使用
How can poor areas without networks have money to build networks?
Load Balancer
The principle and common methods of multithreading and the difference between thread and runnable
一刷314-剑指 Offer 09. 用两个栈实现队列(e)
随机推荐
Temporal model: long-term and short-term memory network (LSTM)
腾讯Offer已拿,这99道算法高频面试题别漏了,80%都败在算法上
Codejock Suite Pro v20.3.0
PHP classes and objects
The length of the last word of the string
[AI weekly] NVIDIA designs chips with AI; The imperfect transformer needs to overcome the theoretical defect of self attention
MySQL - MySQL查询语句的执行过程
Basic greedy summary
String sorting
计算某字符出现次数
pywintypes. com_ Error: (- 2147221020, 'invalid syntax', none, none)
API IX JWT auth plug-in has an error. Risk announcement of information disclosure in response (cve-2022-29266)
PS为图片添加纹理
北京某信护网蓝队面试题目
新动态:SmartMesh和MeshBox的合作新动向
Pgpool II 4.3 Chinese Manual - introductory tutorial
Intersection, union and difference sets of spark operators
Accumulation of applet knowledge points
Redis主从复制过程
基于 TiDB 的 Apache APISIX 高可用配置中心的最佳实践