how to detect a car entred parking lot and leaving it
    4 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
source = videoinput('winvideo',1); thresh = 25; im=getsnapshot(source); %(Remove this) bg = im;
% read in 1st frame as background frame(change this) %
bg = imread('C:\Users\Aatif\Desktop\Thesis\A2.PNG'); 
bg_bw = rgb2gray(bg); 
% convert background to greyscale %fg1 = bg_bw;
% ----------------------- set frame size variables ----------------------- %fr_size = size(bg);
width = size(bg_bw,2); height = size(bg_bw,1); fg = zeros(height, width);
% --------------------- process frames -----------------------------------
for i = 2:100
fr = getsnapshot(source);       % read in frame
    fr_bw = rgb2gray(fr);       % convert frame to grayscale
    fr_diff = abs(double(fr_bw) - double(bg_bw));  % cast operands as double to avoid negative overflow
    for j=1:width                 % if fr_diff > thresh pixel in foreground
        for k=1:height
            if ((fr_diff(k,j) > thresh))
                fg(k,j) = 1;
            else
                fg(k,j) = 0;
            end
        end
    end
    %bg_bw = fr_bw;
    figure(1),subplot(2,1,1),imshow(fr)
    %subplot(3,1,2),imshow(fr_bw)
    subplot(2,1,2),imshow(fg)
    M(i-1)  = im2frame(uint8(fg),gray);           % put frames into movie
        if ((bg_bw) ~= (fr_bw))
            textIn = ('Car has left the parking lot');
            ha = actxserver('SAPI.SpVoice');
            invoke(ha,'speak',textIn);
            h = msgbox('Car has left the parking lot');
       else
            textIn = ('Car is in the parking lot');
            ha = actxserver('SAPI.SpVoice');
            invoke(ha,'speak',textIn);
            h = msgbox('Car is in the the parking lot');
        end
end
above is my code 
i cant read if statment 
its just reading else statment
can please some on help to solve this issue
0 commentaires
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
