title: Raspberry pi - Tensorflow How to detect in real time only people and counting?
body: <p>I try to make a camera with a raspberry pi that counts and sends on firebase the number of person exat in the pieces.</p>
  
  <p>I followed the tutorial of <a href="https://github.com/EdjeElectronics/TensorFlow-Object-Detection-on-the-Raspberry-Pi" rel="nofollow noreferrer">https://github.com/EdjeElectronics/TensorFlow-Object-Detection-on-the-Raspberry-Pi</a>
  but I can not limit detection only to the person and count the number of people to detect in the room. I can send to firebase but I do not have the right number of people.</p>
  
  <p>i tried several answers on stackeoverflow but its not working as <a href="https://stackoverflow.com/questions/45543154/how-to-count-objects-in-tensorflow-object-detection-api">How to count objects in Tensorflow Object Detection API</a>
  because they do not have the problem of just counting people.</p>
  
  <p>How can I count only people in a room ?
  Here is my code : </p>
  
  <pre><code>    for frame1 in camera.capture_continuous(rawCapture, format="bgr",use_video_port=True):
      totalcount=0
      t1 = cv2.getTickCount()
  
      # Acquire frame and expand frame dimensions to have shape: [1, None, None, 3]
      # i.e. a single-column array, where each item in the column has the pixel RGB value
      frame = np.copy(frame1.array)
      frame.setflags(write=1)
      frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
      frame_expanded = np.expand_dims(frame_rgb, axis=0)
  
      # Perform the actual detection by running the model with the image as input
      (boxes, scores, classes, num) = sess.run(
          [detection_boxes, detection_scores, detection_classes, num_detections],
          feed_dict={image_tensor: frame_expanded})
      boxes = np.squeeze(boxes)
      scores = np.squeeze(scores)
      classes = np.squeeze(classes)
  
  
      indices = np.argwhere(classes == 1)
      boxes = np.squeeze(boxes[indices])
      scores = np.squeeze(scores[indices])
      classes = np.squeeze(classes[indices])
  
  
  
      # Draw the results of the detection (aka 'visulaize the results')
      vis_util.visualize_boxes_and_labels_on_image_array(
          frame,
          boxes,
          classes,
          scores,
          category_index,
          use_normalized_coordinates=True,
          line_thickness=8,
          min_score_thresh=0.70)
  
      cv2.putText(frame,"FPS: {0:.2f}".format(frame_rate_calc),(30,50),font,1,(255,255,0),2,cv2.LINE_AA)
      #print(category_index)
  
      try:
          app = firebase_admin.get_app()
      except ValueError as e:
          cred = credentials.Certificate("./ServiceAccountKey.json")
          app = firebase_admin.initialize_app(cred)
  
      store = firestore.client()
      #doc_ref = store.collection(u'users').limit(2)
  
      print(len(boxes.shape))
  
      totalcount= boxes.shape[1]
  
      #x = re.search('[\w]', str(totalcount))
  
      #totalcount = x.group()
      print("Il y'a {0} personne dans la salle".format(totalcount))            
      # All the results have been drawn on the frame, so it's time to display it.
      store.collection(u'Piece').document(u'Cuisine').set({u'nbrPers': int(totalcount)})
  
      cv2.putText(frame,"NbrPerson"+str(totalcount) ,(50, 45),font,0.8,(0, 0xFF, 0xFF),2,cv2.FONT_HERSHEY_SIMPLEX,)
  
      cv2.imshow('Object detector', frame)
  
      t2 = cv2.getTickCount()
      time1 = (t2-t1)/freq
      frame_rate_calc = 1/time1
  
      # Press 'q' to quit
      if cv2.waitKey(1) == ord('q'):
          break
  
      rawCapture.truncate(0)
  
  camera.close()
  </code></pre>