Display person count
Change-Id: I82c5282f50ac062043840d3b5ee238baf9d6b714
diff --git a/person_detection/person_detection.py b/person_detection/person_detection.py
index 7cdfd9f..8d8597f 100644
--- a/person_detection/person_detection.py
+++ b/person_detection/person_detection.py
@@ -124,6 +124,9 @@
initial_h = 480
frame = cv2.resize(frame, (initial_w, initial_h))
+ obj_count = 0
+ red = (0, 0, 255)
+ black = (0, 0, 0)
for obj in res[0][0]:
# Draw only objects when probability more than specified threshold
if obj[2] > self.prob_threshold:
@@ -131,16 +134,16 @@
ymin = int(obj[4] * initial_h)
xmax = int(obj[5] * initial_w)
ymax = int(obj[6] * initial_h)
- class_id = int(obj[1])
- # Draw box and label\class_id
- color = (0, 0, 255)
- cv2.rectangle(frame, (xmin, ymin), (xmax, ymax), color, 2)
- det_label = str(class_id)
- cv2.putText(frame, det_label + ' ' + str(round(obj[2] * 100, 1)) + ' %', (xmin, ymin - 7),
- cv2.FONT_HERSHEY_COMPLEX, 0.6, color, 1)
+ # Draw box and prob
+ cv2.rectangle(frame, (xmin, ymin), (xmax, ymax), red, 2)
+ cv2.putText(frame, str(round(obj[2] * 100, 1)) + ' %', (xmin, ymin - 7),
+ cv2.FONT_HERSHEY_COMPLEX, 0.6, black, 1)
+ obj_count += 1
- cv2.putText(frame, self.device, (10, int(initial_h - 20)),
- cv2.FONT_HERSHEY_COMPLEX, 0.5, (10, 10, 200), 1)
+ cv2.putText(frame, "persons: {}".format(str(obj_count)), (10, 20),
+ cv2.FONT_HERSHEY_COMPLEX, 0.6, black, 1)
+ cv2.putText(frame, "camera: {}".format(self.device), (10, int(initial_h - 20)),
+ cv2.FONT_HERSHEY_COMPLEX, 0.6, black, 1)
yield cv2.imencode('.jpg', frame)[1].tobytes()