Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions deploy/pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,10 +637,12 @@ def predict_image(self, input):
if self.cfg['visual']:
self.visualize_image(batch_file, batch_input, self.pipeline_res)

def capturevideo(self, capture, queue):
def capturevideo(self, capture, queue, capture_end):
frame_id = 0
while (1):
if queue.full():
if capture_end.is_set():
return
elif queue.full():
time.sleep(0.1)
else:
ret, frame = capture.read()
Expand Down Expand Up @@ -728,9 +730,10 @@ def predict_video(self, video_file, thread_idx=0):
cars_count = 0
retrograde_traj_len = 0
framequeue = queue.Queue(10)
capture_end = threading.Event()

thread = threading.Thread(
target=self.capturevideo, args=(capture, framequeue))
target=self.capturevideo, args=(capture, framequeue, capture_end))
thread.start()
time.sleep(1)

Expand Down Expand Up @@ -812,7 +815,7 @@ def predict_video(self, video_file, thread_idx=0):
pushstream.pipe.stdin.write(im.tobytes())
else:
writer.write(im)
if self.file_name is None: # use camera_id
if type(self.file_name) == int: # use camera_id
cv2.imshow('Paddle-Pipeline', im)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
Expand Down Expand Up @@ -1084,11 +1087,12 @@ def predict_video(self, video_file, thread_idx=0):
pushstream.pipe.stdin.write(im.tobytes())
else:
writer.write(im)
if self.file_name is None: # use camera_id
if type(self.file_name) == int: # use camera_id
cv2.imshow('Paddle-Pipeline', im)
if cv2.waitKey(1) & 0xFF == ord('q'):
break

capture_end.set()
if self.cfg['visual'] and len(self.pushurl) == 0:
writer.release()
print('save result to {}'.format(out_path))
Expand Down
3 changes: 2 additions & 1 deletion ppdet/data/shm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def _parse_size_in_M(size_str):
num, unit = size_str[:-1], size_str[-1]
assert unit in SIZE_UNIT, \
"unknown shm size unit {}".format(unit)
return float(num) * \
num_dot = num.replace(',', '.') # To handle cases where the integer part is separated from the floating point part by a comma
return float(num_dot) * \
(1024 ** (SIZE_UNIT.index(unit) - 1))


Expand Down