Skip to content

Commit f2186b7

Browse files
committed
Process completed requests after main cycle
1 parent 59f9a4d commit f2186b7

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

demos/python_demos/common/pipelines/async_pipeline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ def get_result(self, id):
6969
def is_ready(self):
7070
return len(self.empty_requests) != 0
7171

72+
def has_completed_request(self):
73+
return len(self.completed_request_results) != 0
74+
7275
def await_all(self):
7376
for request in self.exec_net.requests:
7477
request.wait()

demos/python_demos/object_detection_demo/object_detection_demo.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,25 @@ def main():
291291
detector_pipeline.await_any()
292292

293293
detector_pipeline.await_all()
294+
# Process completed requests
295+
while detector_pipeline.has_completed_request():
296+
results = detector_pipeline.get_result(next_frame_id_to_show)
297+
if results:
298+
objects, frame_meta = results
299+
frame = frame_meta['frame']
300+
start_time = frame_meta['start_time']
301+
302+
if len(objects) and args.raw_output_message:
303+
print_raw_results(frame.shape[:2], objects, model.labels, args.prob_threshold)
304+
305+
presenter.drawGraphs(frame)
306+
frame = draw_detections(frame, objects, palette, model.labels, args.prob_threshold, has_landmarks)
307+
metrics.update(start_time, frame)
308+
if not args.no_show:
309+
cv2.imshow('Detection Results', frame)
310+
next_frame_id_to_show += 1
311+
else:
312+
break
294313

295314
metrics.print_total()
296315
print(presenter.reportMeans())

0 commit comments

Comments
 (0)