|
|
|
@@ -29,6 +29,7 @@ class Operator: |
|
|
|
self.bboxs = [] |
|
|
|
self.bounding_box_messages = 0 |
|
|
|
self.image_messages = 0 |
|
|
|
self.object_detection_logs = [] |
|
|
|
|
|
|
|
def on_event( |
|
|
|
self, |
|
|
|
@@ -69,12 +70,22 @@ class Operator: |
|
|
|
self.image_messages += 1 |
|
|
|
print("received " + str(self.image_messages) + " images") |
|
|
|
|
|
|
|
elif dora_input["id"] == "object_detection_logs": |
|
|
|
logs = dora_input["value"][0].as_py() |
|
|
|
self.object_detection_logs += [logs] |
|
|
|
## Only keep last 10 logs |
|
|
|
self.object_detection_logs = self.object_detection_logs[-10:] |
|
|
|
return DoraStatus.CONTINUE |
|
|
|
|
|
|
|
elif dora_input["id"] == "bbox" and len(self.image) != 0: |
|
|
|
bboxs = dora_input["value"].to_numpy() |
|
|
|
self.bboxs = np.reshape(bboxs, (-1, 6)) |
|
|
|
|
|
|
|
self.bounding_box_messages += 1 |
|
|
|
print("received " + str(self.bounding_box_messages) + " bounding boxes") |
|
|
|
return DoraStatus.CONTINUE |
|
|
|
else: |
|
|
|
return DoraStatus.CONTINUE |
|
|
|
|
|
|
|
for bbox in self.bboxs: |
|
|
|
[ |
|
|
|
@@ -104,6 +115,18 @@ class Operator: |
|
|
|
1, |
|
|
|
) |
|
|
|
|
|
|
|
for i, log in enumerate(self.object_detection_logs): |
|
|
|
cv2.putText( |
|
|
|
self.image, |
|
|
|
log, |
|
|
|
(10, 10 + 20 * i), |
|
|
|
font, |
|
|
|
0.5, |
|
|
|
(0, 255, 0), |
|
|
|
2, |
|
|
|
1, |
|
|
|
) |
|
|
|
|
|
|
|
if CI != "true": |
|
|
|
cv2.imshow("frame", self.image) |
|
|
|
if cv2.waitKey(1) & 0xFF == ord("q"): |
|
|
|
|