当前位置:网站首页>捡起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
边栏推荐
- C language self compiled string processing function - string segmentation, string filling, etc
- Metalife established a strategic partnership with ESTV and appointed its CEO Eric Yoon as a consultant
- Codejock Suite Pro v20.3.0
- Implement default page
- Why disable foreign key constraints
- Read the meaning of serial port and various level signals
- Import address table analysis (calculated according to the library file name: number of imported functions, function serial number and function name)
- Multi level cache usage
- Spark 算子之partitionBy
- Named in pytoch_ parameters、named_ children、named_ Modules function
猜你喜欢
5 minutes, turn your excel into an online database, the magic cube net table Excel database
Coalesce and repartition of spark operators
时序模型:门控循环单元网络(GRU)
多生成树MSTP的配置
一刷314-剑指 Offer 09. 用两个栈实现队列(e)
C language --- advanced pointer
多线程原理和常用方法以及Thread和Runnable的区别
负载均衡器
Redis master-slave replication process
基于 TiDB 的 Apache APISIX 高可用配置中心的最佳实践
随机推荐
c语言---字符串+内存函数
Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
WPS brand was upgraded to focus on China. The other two domestic software were banned from going abroad with a low profile
大厂技术实现 | 行业解决方案系列教程
【现代电子装联期末复习要点】
怎么看基金是不是reits,通过银行购买基金安全吗
Spark 算子之sortBy使用
Spark 算子之groupBy使用
Import address table analysis (calculated according to the library file name: number of imported functions, function serial number and function name)
Multi level cache usage
布隆过滤器在亿级流量电商系统的应用
PHP operators
Accumulation of applet knowledge points
One brush 312 - simple repetition set - Sword finger offer 03 Duplicate number in array (E)
幂等性的处理
负载均衡器
String sorting
Unity shader learning
PHP function
Application case of GPS Beidou high precision satellite time synchronization system