MATLAB调用USB摄像机采集图像代码段

利用在MATLAB上调用USB摄像机,用于实时输出图像

 

话不多说上代码

%%%Command Window窗口下(注释)


>> info=imaqhwinfo


info = 


    InstalledAdaptors: {'gentl'  'gige'  'matrox'  'winvideo'}
        MATLABVersion: '8.2 (R2013b)'
          ToolboxName: 'Image Acquisition Toolbox'
       ToolboxVersion: '4.6 (R2013b)'


>>  win_info = imaqhwinfo('winvideo')


win_info = 


       AdaptorDllName: 'C:\Program Files\MATLAB\R2013b\toolbox\imaq\imaqadaptors\win32\mwwinvideoimaq.dll'
    AdaptorDllVersion: '4.6 (R2013b)'
          AdaptorName: 'winvideo'
            DeviceIDs: {[1]}
           DeviceInfo: [1x1 struct]


>> win_info.DeviceInfo(1)


ans = 


             DefaultFormat: 'YUY2_720x480'
       DeviceFileSupported: 0
                DeviceName: 'OEM Device'
                  DeviceID: 1
     VideoInputConstructor: 'videoinput('winvideo', 1)'
    VideoDeviceConstructor: 'imaq.VideoDevice('winvideo', 1)'
          SupportedFormats: {'YUY2_720x480'  'YUY2_720x576'}


>> inputCamera = videoinput('winvideo',1,'YUY2_720x480')    (注释)%%%inputCamera = videoinput('AdaptorName',DeviceID,'DefaultFormat') 


Summary of Video Input Object Using 'OEM Device'.


   Acquisition Source(s):  composite and tuner are available.


  Acquisition Parameters:  'composite' is the current selected source.
                           10 frames per trigger using the selected source.
                           'YUY2_720x480' video data to be logged upon START.
                           Grabbing first of every 1 frame(s).
                           Log data to 'memory' on trigger.


      Trigger Parameters:  1 'immediate' trigger(s) on START.


                  Status:  Waiting for START.
                           0 frames acquired since starting.
                           0 frames available for GETDATA.

>> preview(inputCamera)

 

 

后采集到的动态图像,如图


MATLAB调用USB摄像机采集图像代码段_第1张图片

 

当然,在知道USB摄像机参数的情况下,也可以直接在editor下直接运行代码,如下所示

 

info=imaqhwinfo;
 win_info = imaqhwinfo('winvideo');
win_info.DeviceInfo(1);
inputCamera = videoinput('winvideo',1,'YUY2_720x480');
preview(inputCamera)

 

其中上面几行代码段里面,尤其是第三行,有USB相机的参数内容,只有知道下才可以直接右键运行,否则将会出现错误。

 

(有迷惑的可以参考下面)

MATLAB调用USB摄像机采集图像代码段_第2张图片

想get更多有趣知识?请加微信公众号“小白算法”,谢谢

MATLAB调用USB摄像机采集图像代码段_第3张图片

 

你可能感兴趣的:(MATLAB调用USB摄像机采集图像代码段)