本文整理汇总了Python中PostProcessing.is_new_square方法的典型用法代码示例。如果您正苦于以下问题:Python PostProcessing.is_new_square方法的具体用法?Python PostProcessing.is_new_square怎么用?Python PostProcessing.is_new_square使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PostProcessing
的用法示例。
在下文中一共展示了PostProcessing.is_new_square方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import PostProcessing [as 别名]
# 或者: from PostProcessing import is_new_square [as 别名]
def run(self):
vid_src = cv2.VideoCapture(self.filename)
_, frame = vid_src.read()
prev_frame = None
object_box = None
# applying background detection
while frame is not None:
_, frame = vid_src.read()
if frame is None:
break
new_object_box, fg = self.algorithm.apply(frame, object_box)
if self.tracking.is_object_empty():
if object_box is not None:
for box in object_box:
self.tracking.add_object(box, frame)
else:
# cek dalam new object box apakah ada yang baru # nanti
if new_object_box is not None:
for new_box in new_object_box:
if PostProcessing.is_new_square(new_box, self.tracking.objects()):
self.tracking.add_object(new_box, frame)
if object_box is not None:
for box in object_box:
x, y, w, h = box
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 1)
if prev_frame is not None:
self.tracking.run(prev_frame, frame)
object_box = new_object_box
# showing
cv2.imshow('img', frame)
prev_frame = np.copy(frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cv2.destroyAllWindows()
vid_src.release()