|
@@ -267,11 +267,11 @@ def cluster_and_anti_abnormal(image, xml_path, digital_list, chars_list,
|
|
|
arr[i] = np.array([ele["loc"][-2], ele["loc"][-1]])
|
|
|
|
|
|
if choice_s_height != 0:
|
|
|
- eps = int(choice_s_height * 2)
|
|
|
+ eps = int(choice_s_height * 2.5)
|
|
|
else:
|
|
|
- eps = int(mean_height * 2.5)
|
|
|
+ eps = int(mean_height * 3)
|
|
|
print("eps: ", eps)
|
|
|
- db = DBSCAN(eps=eps, min_samples=2, metric='chebyshev').fit(arr)
|
|
|
+ db = DBSCAN(eps=eps, min_samples=1, metric='chebyshev').fit(arr)
|
|
|
|
|
|
labels = db.labels_
|
|
|
# print(labels)
|
|
@@ -402,7 +402,7 @@ def cluster_and_anti_abnormal(image, xml_path, digital_list, chars_list,
|
|
|
current_row_choice_m_d = sorted(current_row_choice_m_d, key=lambda x: x["loc"][0])
|
|
|
# current_row_choice_m_d.append(choice_m_numbers_list[random_index])
|
|
|
split_pix = sorted([ele["loc"][0] for ele in current_row_choice_m_d]) # xmin排序
|
|
|
- split_index = get_split_index(split_pix)
|
|
|
+ split_index = get_split_index(split_pix, dif=choice_s_width*0.8)
|
|
|
split_pix = [split_pix[ele] for ele in split_index[:-1]]
|
|
|
|
|
|
block_list = []
|
|
@@ -444,9 +444,9 @@ def cluster_and_anti_abnormal(image, xml_path, digital_list, chars_list,
|
|
|
|
|
|
# split_index.append(row_chars_xmax) # 边界
|
|
|
split_pix.append(round(split_pix[-1] + choice_s_width * 1.2))
|
|
|
- for i in range(0, len(split_index) - 1):
|
|
|
- left_limit = split_index[i]
|
|
|
- right_limit = split_index[i + 1]
|
|
|
+ for i in range(0, len(split_pix) - 1):
|
|
|
+ left_limit = split_pix[i]
|
|
|
+ right_limit = split_pix[i + 1]
|
|
|
block_chars = [ele for ele in current_row_chars
|
|
|
if left_limit < (ele["location"]["left"] + ele["location"]["width"] // 2) < right_limit]
|
|
|
|
|
@@ -504,6 +504,7 @@ def cluster_and_anti_abnormal(image, xml_path, digital_list, chars_list,
|
|
|
|
|
|
tmp_w, tmp_h = location['xmax'] - location['xmin'], location['ymax'] - location['ymin'],
|
|
|
numbers = current_row_choice_m_d[i]["numbers"]
|
|
|
+
|
|
|
direction = current_row_choice_m_d[i]["direction"]
|
|
|
if direction == 180:
|
|
|
choice_m = dict(class_name='choice_m',
|
|
@@ -584,7 +585,7 @@ def cluster_and_anti_abnormal(image, xml_path, digital_list, chars_list,
|
|
|
for ele in tmp:
|
|
|
loc = ele["bounding_box"]
|
|
|
w, h = loc['xmax'] - loc['xmin'], loc['ymax'] - loc['ymin']
|
|
|
- if w*h < choice_s_width*choice_s_height:
|
|
|
+ if 2*w*h < choice_s_width*choice_s_height:
|
|
|
choice_m_list.remove(ele)
|
|
|
return choice_m_list
|
|
|
|