From 297cc939e2cc1e733df684cd3a9b748e9fa0a08f Mon Sep 17 00:00:00 2001 From: Quentin Bolsee <quentinbolsee@hotmail.com> Date: Thu, 14 Dec 2023 13:32:38 -0500 Subject: [PATCH] skeleton code --- host/filtering.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/host/filtering.py b/host/filtering.py index 7b40c84..5c7ce0b 100644 --- a/host/filtering.py +++ b/host/filtering.py @@ -1,6 +1,11 @@ import cv2 import numpy as np -import trace_skeleton +try: + import trace_skeleton + use_swig = True +except ImportError: + import trace_skeleton_old + use_swig = False import skimage.morphology import random @@ -29,8 +34,11 @@ def stroke(img): im = skimage.morphology.skeletonize(img_binary).astype(np.uint8) - rects = [] - polys = trace_skeleton.traceSkeleton(im, 0, 0, im.shape[1], im.shape[0], 10, 999, rects) + if use_swig: + polys = trace_skeleton.from_numpy(im) + else: + rects = [] + polys = trace_skeleton_old.traceSkeleton(im, 0, 0, im.shape[1], im.shape[0], 10, 999, rects) for l in polys: # c = (200 * random.random(), 200 * random.random(), 200 * random.random()) -- GitLab