本文整理汇总了Python中PostProcessing.bounding_box_mask方法的典型用法代码示例。如果您正苦于以下问题:Python PostProcessing.bounding_box_mask方法的具体用法?Python PostProcessing.bounding_box_mask怎么用?Python PostProcessing.bounding_box_mask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PostProcessing
的用法示例。
在下文中一共展示了PostProcessing.bounding_box_mask方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apply
# 需要导入模块: import PostProcessing [as 别名]
# 或者: from PostProcessing import bounding_box_mask [as 别名]
def apply(self, cur_image):
"""
apply the algorithm for running average in color
:param cur_image: numpy array; a color image (RGB)
:return new_objects_box: array consists of new object squares
:return new_fg: binary image consists of image (black and white)
"""
cur_image_gray = cv2.cvtColor(cur_image, cv2.COLOR_BGR2GRAY)
if self.prev_image is not None:
threshold_array = np.multiply(np.ones_like(cur_image_gray, 'uint8'), self.threshold)
diff = np.absolute(np.subtract(cur_image_gray, self.prev_frame))
fg_raw = np.multiply(
np.ones_like(cur_image_gray, 'uint8'),
np.where(
np.less(diff, threshold_array),
0,
255
)
)
raw_boxes, new_fg = PostProcessing.foreground_process(fg_raw)
new_objects_box = PostProcessing.bounding_box_mask(raw_boxes, new_fg)
else:
new_fg = np.zeros_like(cur_image_gray)
new_objects_box = []
self.prev_image = np.copy(cur_image_gray)
return new_objects_box, new_fg