【问题标题】:Realtime webcam processing in MatlabMatlab 中的实时网络摄像头处理
【发布时间】:2011-05-07 14:31:04
【问题描述】:

谁能指出一些在 Matlab 中实时网络摄像头处理示例的方向?网上有一些关于如何从网络摄像头获取图片,然后处理该图片的教程/示例,但我正在研究如何实时处理来自网络摄像头的视频源。

【问题讨论】:

    标签: matlab video real-time webcam


    【解决方案1】:

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

    关于此视频:使用 USB 网络摄像头 阅读数独谜题和图像 处理以从中提取数据。 然后,用一个简单的方法解决这个难题 数值算法和覆盖 原始视频源的解决方案。

    “数独”是注册商标 NIKOLI Co., Ltd.(日本)

    [编辑 - 更新了视频的链接]

    【讨论】:

    【解决方案2】:

    Ashish 给出的示例确实涵盖了您需要了解的所有内容。

    这是此示例的一个子集,其中仅包含视频内容。基本上你应该做的是一个带有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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-15
      • 1970-01-01
      • 2018-07-08
      • 1970-01-01
      • 2014-11-24
      • 1970-01-01
      • 2016-07-17
      相关资源
      最近更新 更多