Matlab擷取網路攝影機資訊並開啟網路攝影機

來源:互聯網
上載者:User

1、開啟網路攝影機的代碼如下:

source.vid = videoinput('winvideo', 1,'YUY2_320x240');

set(source.vid,'ReturnedColorSpace','grayscale');
vidRes = get(source.vid, 'VideoResolution');
nBands = get(source.vid, 'NumberOfBands');
hImage = image( zeros(vidRes(2), vidRes(1), nBands) );
preview(source.vid, hImage);

2、擷取網路攝影機相關資訊如下:

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
% >> win_info=imaqhwinfo('winvideo')%我們看看第二適配器的具體參數
%
% win_info =
%
%        AdaptorDllName: [1x81 char]%適配器dll檔案絕對路徑
%     AdaptorDllVersion: '3.1 (R2008a)'%適配器dll檔案版本
%           AdaptorName: 'winvideo'%適配器名稱
%             DeviceIDs: {[1]}%裝置ID號,這個我們經常需要用到
%            DeviceInfo: [1x1 struct]%裝置資訊,這裡主要是映像擷取裝置的一些參數,比較重要
%
% %====================下面我們瞭解下,這個映像擷取裝置到底有哪些的詳細資料吧====================
%
% >> win_info.DeviceIDs
%
% ans =
%
%     [1]
%
% >> dev_win_info=win_info.DeviceInfo
%
% dev_win_info =
%
%           DefaultFormat: 'RGB24_320x240'%擷取圖片的預設格式
%     DeviceFileSupported: 0
%              DeviceName: 'USB PC CAMERA P227'%裝置名稱
%                DeviceID: 1%裝置號
%       ObjectConstructor: 'videoinput('winvideo', 1)'%對象構建方式,這個絕大部分都是一樣的
%        SupportedFormats: {1x12 cell}%擷取的映像支援格式,一般都有好多種,上面的DefaultFormat只是預設格式而已
%
% %==================================看看映像擷取裝置支援的映像格式==================================
%
% >> dev_win_info.SupportedFormats%可以看到我的PC上的網路攝影機支援下面12中圖片格式
%
% ans =
%
%   Columns 1 through 5
%
%     'I420_160x120'    'I420_176x144'    'I420_320x240'    'I420_352x288'    'I420_640x480'
%
%   Columns 6 through 9
%
%     'RGB24_1280x960'    'RGB24_160x120'    'RGB24_176x144'    'RGB24_320x240'
%
%   Columns 10 through 12
%
%     'RGB24_352x288'    'RGB24_640x480'    'RGB24_800x600'
%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.