fixed new sample cannot detect boxes due to filter
This commit is contained in:
+11
-5
@@ -8,9 +8,14 @@ class Stitcher:
|
||||
|
||||
def __init__(self,isstitch=False, n=[3,3], index=np.array([1,2,3,6,7,8,11,12,13])):
|
||||
|
||||
# Settings
|
||||
# Settings
|
||||
self.isstitch = isstitch
|
||||
|
||||
# Find Boxes Related
|
||||
self.min_area_frac = 0.01
|
||||
self.max_area_frac = 0.05
|
||||
self.max_aspect_ratio = 100
|
||||
|
||||
# stitch related
|
||||
self.stitch_valid = False
|
||||
self.boxes = self.units = None
|
||||
@@ -21,6 +26,7 @@ class Stitcher:
|
||||
self.nominal_ov_pos=100
|
||||
self.margin=10
|
||||
self.bound=self.nominal_ov_pos - self.margin
|
||||
|
||||
# for sensor 1
|
||||
self.pos_default = [(260, 56), (577, 62), (897, 69), (1214, 75), (1530, 81), (256, 391), (570, 397), (889, 403), (1208, 409), (1523, 416), (248, 724), (563, 730), (882, 738), (1201, 743), (1516, 751)]
|
||||
|
||||
@@ -542,7 +548,7 @@ class Stitcher:
|
||||
|
||||
|
||||
|
||||
def __filter_boxes_by_size(self, boxes, img_shape, min_area_frac=0.018, max_area_frac=0.035):
|
||||
def __filter_boxes_by_size(self, boxes, img_shape):
|
||||
"""
|
||||
Remove boxes that are too small or too large relative to the image.
|
||||
- boxes: list of (x,y,w,h)
|
||||
@@ -552,12 +558,12 @@ class Stitcher:
|
||||
"""
|
||||
h, w = img_shape
|
||||
img_area = h * w
|
||||
min_area = img_area * float(min_area_frac)
|
||||
max_area = img_area * float(max_area_frac)
|
||||
min_area = img_area * float(self.min_area_frac)
|
||||
max_area = img_area * float(self.max_area_frac)
|
||||
filtered = []
|
||||
for (x,y,ww,hh) in boxes:
|
||||
area = ww * hh
|
||||
if area < min_area or area > max_area or (abs(ww - hh) > 20):
|
||||
if area < min_area or area > max_area or (abs(ww - hh) > self.max_aspect_ratio):
|
||||
continue
|
||||
filtered.append((x,y,ww,hh))
|
||||
return filtered
|
||||
Reference in New Issue
Block a user