title: Python: classify objects in images
body: <pre><code>camera = webcam; % Connect to the camera
  nnet = alexnet;  % Load the neural net
  
  while true   
      picture = camera.snapshot;              % Take a picture    
      picture = imresize(picture,[227,227]);  % Resize the picture
  
      label = classify(nnet, picture);        % Classify the picture
  
      image(picture);     % Show the picture
      title(char(label)); % Show the label
      drawnow;   
  end
  </code></pre>
  
  <p>I found this matlab code in the internet. It displays a window with the picture from a webcam and very quickly also names the things in the picture ("keyboard","bootle","pencil","clock"...). I want to do that in python.
  So far I have this:</p>
  
  <pre><code>import cv2
  import sys
  faceCascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
  video_capture = cv2.VideoCapture(0)
  
  while True:
      ret, frame = video_capture.read()
      gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
  
      faces = faceCascade.detectMultiScale(
          gray,
          scaleFactor=1.1,
          minNeighbors=5,
          minSize=(30, 30),
          flags=cv2.cv.CV_HAAR_SCALE_IMAGE
      )
  
      # Draw a rectangle around the faces
      for (x, y, w, h) in faces:
          cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
      cv2.imshow('Video', frame)
  
      if cv2.waitKey(1) &amp; 0xFF == ord('q'):
          break
  </code></pre>
  
  <p>This is alreay very similar, but only detecting faces. The matlab code uses alexnet. I guess this is a pre-trained network based on imagenet data  (<a href="http://www.image-net.org/" rel="nofollow noreferrer">http://www.image-net.org/</a>). But it is no longer available.
  How would I do this in python?</p>
  
  <p>(There has been a similar question here, but it is 4 yrs. old and I think there are newer techniques now).</p>