Spaces:
Sleeping
Sleeping
Update Counting_Columns_2_1.py
Browse files- Counting_Columns_2_1.py +6 -4
Counting_Columns_2_1.py
CHANGED
|
@@ -137,8 +137,9 @@ def distance(point1, point2):
|
|
| 137 |
|
| 138 |
def getNearestText(point_list, p):
|
| 139 |
nearbyy = []
|
| 140 |
-
selected_clm_point = [] #save the clmn for drawing cirlce on it
|
| 141 |
dis = []
|
|
|
|
| 142 |
for i in range(len(p)):
|
| 143 |
nearest_point = min(point_list, key=lambda point: distance(point, p[i]))
|
| 144 |
dist = distance(nearest_point, p[i])
|
|
@@ -146,7 +147,8 @@ def getNearestText(point_list, p):
|
|
| 146 |
if dist < 44:
|
| 147 |
nearbyy.append(nearest_point)
|
| 148 |
selected_clm_point.append(p[i])
|
| 149 |
-
|
|
|
|
| 150 |
|
| 151 |
|
| 152 |
def getColumnsTypes(nearbyy, x):
|
|
@@ -259,7 +261,7 @@ def mainfun(pdf_name,pdfpath,planname):
|
|
| 259 |
|
| 260 |
if len(column_points) > 10:
|
| 261 |
# BROWN COLUMNS
|
| 262 |
-
nearby, slctd_clm = getNearestText(text_points, column_points)
|
| 263 |
columns_types_v = getColumnsTypesKeyValue(nearby, txtpts_ky_vlu)
|
| 264 |
legend = generate_legend(columns_types_v)
|
| 265 |
huge_list_clmn_clr_loc = get_drawing_info(txt_clmn,txtpts_ky_vlu,key_colors)
|
|
@@ -270,7 +272,7 @@ def mainfun(pdf_name,pdfpath,planname):
|
|
| 270 |
imgResult = segment_blue(img_blue)
|
| 271 |
outsu = threshold(imgResult)
|
| 272 |
column_points,mask_clmns, mask_walls = get_columns_info(outsu, img)
|
| 273 |
-
nearby, slctd_clm = getNearestText(text_points, column_points)
|
| 274 |
columns_types_v = getColumnsTypesKeyValue(nearby, txtpts_ky_vlu)
|
| 275 |
legend = generate_legend(columns_types_v)
|
| 276 |
huge_list_clmn_clr_loc = get_drawing_info(txt_clmn,txtpts_ky_vlu,key_colors)
|
|
|
|
| 137 |
|
| 138 |
def getNearestText(point_list, p):
|
| 139 |
nearbyy = []
|
| 140 |
+
selected_clm_point = [] #save the clmn for drawing cirlce on it
|
| 141 |
dis = []
|
| 142 |
+
txt_clmn = []
|
| 143 |
for i in range(len(p)):
|
| 144 |
nearest_point = min(point_list, key=lambda point: distance(point, p[i]))
|
| 145 |
dist = distance(nearest_point, p[i])
|
|
|
|
| 147 |
if dist < 44:
|
| 148 |
nearbyy.append(nearest_point)
|
| 149 |
selected_clm_point.append(p[i])
|
| 150 |
+
txt_clmn.append((nearest_point, p[i]))
|
| 151 |
+
return nearbyy, selected_clm_point, txt_clmn
|
| 152 |
|
| 153 |
|
| 154 |
def getColumnsTypes(nearbyy, x):
|
|
|
|
| 261 |
|
| 262 |
if len(column_points) > 10:
|
| 263 |
# BROWN COLUMNS
|
| 264 |
+
nearby, slctd_clm, txt_clmn = getNearestText(text_points, column_points)
|
| 265 |
columns_types_v = getColumnsTypesKeyValue(nearby, txtpts_ky_vlu)
|
| 266 |
legend = generate_legend(columns_types_v)
|
| 267 |
huge_list_clmn_clr_loc = get_drawing_info(txt_clmn,txtpts_ky_vlu,key_colors)
|
|
|
|
| 272 |
imgResult = segment_blue(img_blue)
|
| 273 |
outsu = threshold(imgResult)
|
| 274 |
column_points,mask_clmns, mask_walls = get_columns_info(outsu, img)
|
| 275 |
+
nearby, slctd_clm, txt_clmn = getNearestText(text_points, column_points)
|
| 276 |
columns_types_v = getColumnsTypesKeyValue(nearby, txtpts_ky_vlu)
|
| 277 |
legend = generate_legend(columns_types_v)
|
| 278 |
huge_list_clmn_clr_loc = get_drawing_info(txt_clmn,txtpts_ky_vlu,key_colors)
|