本文整理汇总了Python中cv2.CHAIN_APPROX_TC89_L1属性的典型用法代码示例。如果您正苦于以下问题:Python cv2.CHAIN_APPROX_TC89_L1属性的具体用法?Python cv2.CHAIN_APPROX_TC89_L1怎么用?Python cv2.CHAIN_APPROX_TC89_L1使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cv2
的用法示例。
在下文中一共展示了cv2.CHAIN_APPROX_TC89_L1属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _findContours
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import CHAIN_APPROX_TC89_L1 [as 别名]
def _findContours(self):
contours = []
masks = self.masks.detach().numpy()
for mask in masks:
mask = cv2.UMat(mask)
contour, hierarchy = cv2.findContours(
mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_TC89_L1
)
reshaped_contour = []
for entity in contour:
assert len(entity.shape) == 3
assert entity.shape[1] == 1, "Hierarchical contours are not allowed"
reshaped_contour.append(entity.reshape(-1).tolist())
contours.append(reshaped_contour)
return contours
示例2: _findContours
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import CHAIN_APPROX_TC89_L1 [as 别名]
def _findContours(self):
contours = []
masks = self.masks.detach().numpy()
for mask in masks:
mask = cv2.UMat(mask)
contour, hierarchy = cv2_util.findContours(
mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_TC89_L1
)
reshaped_contour = []
for entity in contour:
assert len(entity.shape) == 3
assert (
entity.shape[1] == 1
), "Hierarchical contours are not allowed"
reshaped_contour.append(entity.reshape(-1).tolist())
contours.append(reshaped_contour)
return contours