설명 :이 코드는 전체 코드의 한 부분으로, 주요 기능은 mask_info (bool 유형 2 차원 벡터)를 레이블링이 필요한 분할로 변환하는 것입니다.
contours, hierarchy = cv2.findContours(mask_info.astype(np.uint8),cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
xy_list = []
for contour in contours:
xy = contour[:,0,:].ravel().tolist()
xy_list.append(xy)
obj_info['area'] = (x2-x1)*(y2-y1)
obj_info['bbox'] = [float(x1), float(y1), float(x2-x1), float(y2-y1)]
obj_info['cate'] = cate
obj_info['segmentation'] = xy_list
참조 기사 : 블로그