segmenter: add contour export

(cherry picked from commit 9329cbf8c9fd6a2e3fd5473896a8d1902acfe627)
This commit is contained in:
Romain Bazile 2021-06-02 18:34:18 +02:00 committed by Romain Bazile
parent 6675b2ebfc
commit ef59fc4ee1

View file

@ -515,7 +515,6 @@ class SegmenterProcess(multiprocessing.Process):
else: else:
self.__global_metadata.update({"objects": [object_metadata]}) self.__global_metadata.update({"objects": [object_metadata]})
# TODO make the TSV for ecotaxa
if self.__save_debug_img: if self.__save_debug_img:
if object_number: if object_number:
for region in regionprops_filtered: for region in regionprops_filtered:
@ -526,26 +525,25 @@ class SegmenterProcess(multiprocessing.Process):
cv2.MARKER_CROSS, cv2.MARKER_CROSS,
) )
tagged_image = cv2.rectangle( tagged_image = cv2.rectangle(
img, tagged_image,
pt1=region.bbox[-3:-5:-1], pt1=region.bbox[-3:-5:-1],
pt2=region.bbox[-1:-3:-1], pt2=region.bbox[-1:-3:-1],
color=(150, 0, 200), color=(150, 0, 200),
thickness=1, thickness=1,
) )
contours, hierarchy = cv2.findContours(
# contours = [region.bbox for region in regionprops_filtered] np.uint8(region.image),
# for contour in contours: mode=cv2.RETR_TREE, # RETR_FLOODFILL or RETR_EXTERNAL
# tagged_image = cv2.rectangle( method=cv2.CHAIN_APPROX_NONE,
# img, pt1=(contours[0][1],contours[0][0]), pt2=(contours[0][3],contours[0][2]), color=(0, 0, 255), thickness=2 )
# ) tagged_image = cv2.drawContours(
# contours = [region.coords for region in regionprops_filtered] tagged_image,
# for contour in contours: contours,
# tagged_image = cv2.drawContours( -1,
# img_erode_2, contour, -1, color=(0, 0, 255), thickness=2 (238, 130, 238),
# ) thickness=1,
offset=(region.bbox[1], region.bbox[0]),
# cv2.imshow("tagged_image", tagged_image.astype("uint8")) )
# cv2.waitKey(0)
self._save_image( self._save_image(
tagged_image, tagged_image,
os.path.join(self.__working_debug_path, "tagged.jpg"), os.path.join(self.__working_debug_path, "tagged.jpg"),