I am doing a project on detecting vehicles in real time video using googlenet. But I am unsure how do I apply googlenet to a real time video.
    4 views (last 30 days)
  
       Show older comments
    
Here is the code that I have came up with recently,
clear
camera = webcam; % Connect to the camera
net = googlenet;   % Load the neural net
net.Layers
while true   
   labelType ='' 
%     char labelcar
    trafficVid = VideoReader('C:\Users\syafiqah\Desktop\project\traffic.avi')
    get(trafficVid)
    implay('C:\Users\syafiqah\Desktop\project\traffic.avi');
      picture = camera.snapshot;              % Take a picture    
      sz = net.Layers(1).InputSize ;
      picture = picture(1:sz(1),1:sz(2),1:sz(3));% Resize the picture
      label = classify(net, picture);        % Classify the picture
       if (label == 'ambulance')
           labelType = 'Vehicle Recognised'
       else if (label == 'moped')
               labelType = 'Vehicle Recognised'
           end
       end
        if (label == 'tank')
               labelType = 'Vehicle Recognised'
        else if (label == 'sports car')
               labelType = 'Vehicle Recognised'
            end
        end   
             if (label == 'moving van')
               labelType = 'Vehicle Recognised'
        else if (label == 'trailer truck')
               labelType = 'Vehicle Recognised'
            end
             end
            if (label == 'garbage truck')
               labelType = 'Vehicle Recognised'
        else if (label == 'trailer truck')
               labelType = 'Vehicle Recognised'
             end
       end
  %     image(picture);     % Show the picture
  %     result = insertShape(frame, 'Rectangle', bbox, 'Color', 'red');
      frameRate = trafficVid.FrameRate;
      title(implay(char(labelType), frameRate)); % Show the label
      drawnow;   
  end
But I am able to play the video, however no vehicle recognition is being executed. I am also using the latest version of matlab which is matlab r2018a.
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!