added parameter row_tol for box sorting
This commit is contained in:
@@ -27,6 +27,7 @@ class Stitcher:
|
||||
self.nominal_ov_pos=config_stitcher["nominal_ov_pos"]
|
||||
self.margin=config_stitcher["margin"]
|
||||
self.bound=self.nominal_ov_pos - self.margin
|
||||
self.row_tol = config_stitcher["row_tol"]
|
||||
|
||||
if self.verbose:
|
||||
print(f"Stitcher initialized with config: {self.config_stitcher}")
|
||||
@@ -110,7 +111,7 @@ class Stitcher:
|
||||
def find_stitch_boxes(self,img_src,show = False):
|
||||
|
||||
img_corr = self.__correct_edge_bloom(img_src)
|
||||
self.__detect_nonblack_regions(img_corr,show = show)
|
||||
self.__detect_nonblack_regions(img_corr,show = show, row_tol = self.row_tol)
|
||||
return len(self.boxes), self.boxes
|
||||
|
||||
# return self.boxes
|
||||
@@ -431,7 +432,7 @@ class Stitcher:
|
||||
return pos_list
|
||||
|
||||
# Computation Functions
|
||||
def __detect_nonblack_regions(self, img, morph_k=3, n_boxes_target=15, bk_thresh_step=10, bk_thresh_max=100,show = False):
|
||||
def __detect_nonblack_regions(self, img, morph_k=3, n_boxes_target=15, bk_thresh_step=10, bk_thresh_max=100,show = False, row_tol = 0.4):
|
||||
"""
|
||||
Return binary mask of non-black regions and list of bounding boxes (x,y,w,h).
|
||||
Uses adaptive thresholding on grayscale + small morphology to be robust to illumination.
|
||||
@@ -509,7 +510,7 @@ class Stitcher:
|
||||
heights = [b[3] - b[1] for b in cropped_boxes]
|
||||
median_height = np.median(heights) if heights else target_h
|
||||
# Use a fraction of the box height as tolerance (e.g., 20% of box height)
|
||||
row_tolerance = max(1, int(median_height * 0.4))
|
||||
row_tolerance = max(1, int(median_height * row_tol))
|
||||
|
||||
# Quantize y-coordinates to group boxes into rows
|
||||
def get_row_key(box):
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
"index": [1,2,3,6,7,8,11,12,13],
|
||||
"margin": 10,
|
||||
"nominal_ov_pos": 100,
|
||||
"n": [3,3]
|
||||
"n": [3,3],
|
||||
"row_tol": 0.4
|
||||
},
|
||||
"tracker": {
|
||||
"adaptive": true,
|
||||
|
||||
Reference in New Issue
Block a user