Two cameras work
Change-Id: Ibd6f0454d5d67c57c4a7735b79a854c0d3a9c59f
diff --git a/person_detection/person_detection.py b/person_detection/person_detection.py
index 32d2bc2..cf8b4f7 100644
--- a/person_detection/person_detection.py
+++ b/person_detection/person_detection.py
@@ -43,7 +43,7 @@
class Camera(BaseCamera):
- def __init__(self, port, args):
+ def __init__(self, device, args):
log.basicConfig(format="[ %(levelname)s ] %(message)s", level=log.INFO, stream=sys.stdout)
model_xml = args.model
model_bin = os.path.splitext(model_xml)[0] + ".bin"
@@ -66,8 +66,9 @@
self.input_stream = 0
elif args.input == 'gstreamer':
# gst rtp sink
- self.input_stream = 'udpsrc port=' + port + 'caps = " application/x-rtp, encoding-name=JPEG,payload=26" ! rtpjpegdepay ! decodebin ! videoconvert ! appsink'
+ self.input_stream = 'udpsrc port=500' + device + ' caps = " application/x-rtp, encoding-name=JPEG,payload=26" ! rtpjpegdepay ! decodebin ! videoconvert ! appsink'
#input_stream = 'udpsrc port=5000 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! decodebin ! videoconvert ! appsink'
+ print("input_stream:", self.input_stream)
else:
self.input_stream = args.input
assert os.path.isfile(args.input), "Specified input file doesn't exist"
@@ -78,10 +79,9 @@
else:
self.labels_map = None
- self.port = port
self.args = args
- super(Camera, self).__init__()
+ super(Camera, self).__init__(device)
def __del__(self):
self.cap.release()
@@ -151,7 +151,7 @@
ymax = int(obj[6] * initial_h)
class_id = int(obj[1])
# Draw box and label\class_id
- color = (min(class_id * 12.5, 255), min(class_id * 7, 255), min(class_id * 5, 255))
+ color = (min(class_id * 12.5, 255),min(class_id * 7, 255), min(class_id * 5, 255))
cv2.rectangle(frame, (xmin, ymin), (xmax, ymax), color, 2)
det_label = self.labels_map[class_id] if self.labels_map else str(class_id)
cv2.putText(frame, det_label + ' ' + str(round(obj[2] * 100, 1)) + ' %', (xmin, ymin - 7),
@@ -159,19 +159,8 @@
# print('Object detected, class_id:', class_id, 'probability:', obj[2], 'xmin:', xmin, 'ymin:', ymin,
# 'xmax:', xmax, 'ymax:', ymax)
- # Draw performance stats
- inf_time_message = "Inference time: Not applicable for async mode" if self.is_async_mode else \
- "Inference time: {:.3f} ms".format(det_time * 1000)
- render_time_message = "OpenCV rendering time: {:.3f} ms".format(render_time * 1000)
- if self.is_async_mode:
- async_mode_message = "Async mode is on. Processing request {}".format(cur_request_id)
- else:
- async_mode_message = "Async mode is off. Processing request {}".format(cur_request_id)
-
- cv2.putText(frame, inf_time_message, (15, 15), cv2.FONT_HERSHEY_COMPLEX, 0.5, (200, 10, 10), 1)
- cv2.putText(frame, render_time_message, (15, 30), cv2.FONT_HERSHEY_COMPLEX, 0.5, (10, 10, 200), 1)
- cv2.putText(frame, async_mode_message, (10, int(initial_h - 20)), cv2.FONT_HERSHEY_COMPLEX, 0.5,
- (10, 10, 200), 1)
+ cv2.putText(frame, self.device, (10, int(initial_h - 20)),
+ cv2.FONT_HERSHEY_COMPLEX, 0.5, (10, 10, 200), 1)
render_start = time.time()