2011-05-07 51 views
2

任何人都可以指出我的一些在Matlab實時攝像頭處理的例子嗎?網上有一些關於如何從網絡攝像頭獲取圖片的教程/示例,然後處理該圖片,但我正在尋找從網絡攝像頭實時處理視頻源的操作。在Matlab中實時攝像頭處理

回答

5

http://www.mathworks.com/videos/solving-a-sudoku-puzzle-using-a-webcam-68773.html

關於該視頻:使用USB網絡攝像頭 的數獨題和圖像處理 讀從中提取數據。 然後,使用簡單的 數值算法解決難題,並在原始視頻供稿上覆蓋 解決方案。

「數獨」是 NIKOLI有限公司的註冊商標(日本)

[編輯 - 更新鏈接到視頻]

+0

這很有幫助。謝謝。 – 2011-05-11 21:21:22

+0

多數民衆贊成超級有用! – twerdster 2011-06-11 11:19:45

+0

網站已關閉?備用鏈接? – aaronsnoswell 2012-10-29 13:35:11

1

阿希什給不面面俱到的例子你得知道。

這是這個例子的一個子集,只是視頻的東西。基本上你應該做的是一個帶有try catch的循環。循環從obj(視頻對象)獲取幀,通過直接在imshow畫布上「繪畫」來處理和顯示它。

在try-catch有當用戶關閉圖窗口,從而導致其觸發的catch子句的例外 - 停止捕獲和釋放相機(所以其他程序可以使用它)

function sudokuvideo_fn() 
% Reset everything, and start capturing 
imaqreset 
% The format need to fit to your camera. The easiest way to check this is 
% to check out the Image Aquisition app 
obj = videoinput('winvideo',1,'MJPG_640x480'); 

try 
    %Initialize various parameters, and load in the template data 
    set(obj,'framesperTrigger',10,'TriggerRepeat',Inf); 
    start(obj); 

    % h is a handle to the canvas 
    h = imshow(zeros(480,640)); 
    hold on; 

    figure(1); 

    while islogging(obj);    
     colorImage = getdata(obj,1); 
     %Icam = imread('sample.bmp'); %<--- For debugging 

     % This line depends on the format you're using (YUV/RGB) 
     %Icam = IcamColor(:,:,1); 
     Icam = rgb2gray(colorImage);  
     flushdata(obj); 

     bwthresh = 1.2; 
     %% Processing comes here - Do whatever you wish 
%   %Block processed threshhold 
%   makebw2 = @(I) im2bw(I.data,median(double(I.data(:)))/bwthresh/255); 
%   IBW = ~blockproc(I0,[blksize blksize],makebw2);  
     IBW = im2bw(Icam, bwthresh/255); 

     % Noise reduction and border elimination 
     I = IBW; 
%   IBW = imclose(IBW,[1 1; 1 1]); 
%   I = IBW; 
     I = bwareaopen(I, blobthresh); 
%   I = imclearborder(I); 

     %% This is what paints on the canvas 
     set(h,'Cdata',I); 
     drawnow; 
    end 

catch err 
    % This attempts to take care of things when the figure is closed 
    stop(obj); 
    imaqreset 
    disp('Cleaned up') 
    rethrow(err); 
end