Skip to content

Commit b8e127a

Browse files
committed
added tracking functionality to pipeline
1 parent 12b7fca commit b8e127a

File tree

2 files changed

+30
-280
lines changed

2 files changed

+30
-280
lines changed

scripts/demo.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import argparse
22

33
import cv2 as cv
4+
import numpy as np
45
import glog as log
6+
57
from openvino.inference_engine import IECore
8+
from icecream import ic
69

710
from torchdet3d.utils import draw_kp, Regressor, Detector, OBJECTRON_CLASSES, MultiCameraTracker
811

912

1013
def draw_detections(frame, reg_detections, det_detections, reg_only=True):
1114
"""Draws detections and labels"""
1215
for det_out, reg_out in zip(det_detections, reg_detections):
13-
left, top, right, bottom = det_out[0]
16+
left, top, right, bottom = det_out[:4]
1417
kp = reg_out[0]
1518
label = reg_out[1]
1619
label = OBJECTRON_CLASSES[label]
@@ -34,8 +37,7 @@ def run(params, capture, detector, regressor, write_video=False, resolution = (1
3437
vout = cv.VideoWriter()
3538
vout.open('output_video_demo.mp4',fourcc,fps,resolution,True)
3639
win_name = '3D-object-detection'
37-
tracker = MultiCameraTracker(1, None, visual_analyze=None)
38-
40+
tracker = MultiCameraTracker(1, None)
3941

4042
has_frame, prev_frame = capture.read()
4143
prev_frame = cv.resize(prev_frame, resolution)
@@ -49,13 +51,17 @@ def run(params, capture, detector, regressor, write_video=False, resolution = (1
4951
frame = cv.resize(frame, resolution)
5052
detections = detector.wait_and_grab()
5153
detector.run_async(frame)
52-
53-
tracker.process(prev_frame, detections, None)
54+
ic(detections)
55+
tracker.process(np.expand_dims(prev_frame, 0), [detections], None)
5456
tracked_objects = tracker.get_tracked_objects()
55-
56-
outputs = regressor.get_detections(prev_frame, tracked_objects)
57-
58-
vis = draw_detections(prev_frame, outputs, detections, reg_only=False)
57+
ic(tracked_objects)
58+
if all(tracked_objects):
59+
rectangles = [rect.rect for rect in tracked_objects[0]]
60+
else:
61+
rectangles = detections
62+
outputs = regressor.get_detections(prev_frame, rectangles)
63+
64+
vis = draw_detections(prev_frame, outputs, rectangles, reg_only=False)
5965
cv.imshow(win_name, vis)
6066
if write_video:
6167
vout.write(vis)

0 commit comments

Comments
 (0)