Spaces:
Sleeping
Sleeping
Update Counting_Columns_2_1.py
Browse files- Counting_Columns_2_1.py +6 -4
Counting_Columns_2_1.py
CHANGED
|
@@ -135,6 +135,7 @@ def distance(point1, point2):
|
|
| 135 |
|
| 136 |
def getNearestText(point_list, p):
|
| 137 |
nearbyy = []
|
|
|
|
| 138 |
dis = []
|
| 139 |
for i in range(len(p)):
|
| 140 |
nearest_point = min(point_list, key=lambda point: distance(point, p[i]))
|
|
@@ -142,7 +143,8 @@ def getNearestText(point_list, p):
|
|
| 142 |
dis.append(dist)
|
| 143 |
if dist < 44:
|
| 144 |
nearbyy.append(nearest_point)
|
| 145 |
-
|
|
|
|
| 146 |
|
| 147 |
|
| 148 |
def getColumnsTypes(nearbyy, x):
|
|
@@ -184,7 +186,7 @@ def mainfun(plan):
|
|
| 184 |
|
| 185 |
if len(column_points) > 10:
|
| 186 |
# BROWN COLUMNS
|
| 187 |
-
nearby = getNearestText(text_points, column_points)
|
| 188 |
columns_types_v = getColumnsTypesKeyValue(nearby, txtpts_ky_vlu)
|
| 189 |
legend = generate_legend(columns_types_v)
|
| 190 |
|
|
@@ -194,10 +196,10 @@ def mainfun(plan):
|
|
| 194 |
imgResult = segment_blue(img_blue)
|
| 195 |
outsu = threshold(imgResult)
|
| 196 |
column_points,mask_clmns, mask_walls = get_columns_info(outsu, img)
|
| 197 |
-
nearby = getNearestText(text_points, column_points)
|
| 198 |
columns_types_v = getColumnsTypesKeyValue(nearby, txtpts_ky_vlu)
|
| 199 |
legend = generate_legend(columns_types_v)
|
| 200 |
-
return legend
|
| 201 |
|
| 202 |
'''def mainfun(plan):
|
| 203 |
texts_from_pdf = get_text_from_pdf(plan)
|
|
|
|
| 135 |
|
| 136 |
def getNearestText(point_list, p):
|
| 137 |
nearbyy = []
|
| 138 |
+
selected_clm_point = [] #save the clmn for drawing cirlce on it
|
| 139 |
dis = []
|
| 140 |
for i in range(len(p)):
|
| 141 |
nearest_point = min(point_list, key=lambda point: distance(point, p[i]))
|
|
|
|
| 143 |
dis.append(dist)
|
| 144 |
if dist < 44:
|
| 145 |
nearbyy.append(nearest_point)
|
| 146 |
+
selected_clm_point.append(p[i])
|
| 147 |
+
return nearbyy, selected_clm_point
|
| 148 |
|
| 149 |
|
| 150 |
def getColumnsTypes(nearbyy, x):
|
|
|
|
| 186 |
|
| 187 |
if len(column_points) > 10:
|
| 188 |
# BROWN COLUMNS
|
| 189 |
+
nearby, slctd_clm = getNearestText(text_points, column_points)
|
| 190 |
columns_types_v = getColumnsTypesKeyValue(nearby, txtpts_ky_vlu)
|
| 191 |
legend = generate_legend(columns_types_v)
|
| 192 |
|
|
|
|
| 196 |
imgResult = segment_blue(img_blue)
|
| 197 |
outsu = threshold(imgResult)
|
| 198 |
column_points,mask_clmns, mask_walls = get_columns_info(outsu, img)
|
| 199 |
+
nearby, slctd_clm = getNearestText(text_points, column_points)
|
| 200 |
columns_types_v = getColumnsTypesKeyValue(nearby, txtpts_ky_vlu)
|
| 201 |
legend = generate_legend(columns_types_v)
|
| 202 |
+
return legend, slctd_clm
|
| 203 |
|
| 204 |
'''def mainfun(plan):
|
| 205 |
texts_from_pdf = get_text_from_pdf(plan)
|