init
This commit is contained in:
parent
53dca80f0f
commit
49cf8fd5d6
@ -311,9 +311,6 @@ if __name__ == "__main__":
|
|||||||
cv2.rectangle(sub_im2, (p['x'], p['y']), (p['x'] + p['width'], p['y'] + p['height']), (0, 0, 255), 2)
|
cv2.rectangle(sub_im2, (p['x'], p['y']), (p['x'] + p['width'], p['y'] + p['height']), (0, 0, 255), 2)
|
||||||
# 写编号
|
# 写编号
|
||||||
cv2.putText(sub_im2, str(i), (p['x'], p['y']), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
|
cv2.putText(sub_im2, str(i), (p['x'], p['y']), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
|
||||||
if (i == 15):
|
|
||||||
print("=========15=======")
|
|
||||||
print(p)
|
|
||||||
cv2.imshow("sub_im_before_filter", sub_im2)
|
cv2.imshow("sub_im_before_filter", sub_im2)
|
||||||
# 过滤点
|
# 过滤点
|
||||||
cnts = filter_points("data_sub/test_1/wide_image.png",cnts)
|
cnts = filter_points("data_sub/test_1/wide_image.png",cnts)
|
||||||
@ -520,8 +517,5 @@ if __name__ == "__main__":
|
|||||||
cv2.rectangle(sub_im, (p['x'], p['y']), (p['x']+p['width'],p['y']+p['height']), (0, 0, 255), 2)
|
cv2.rectangle(sub_im, (p['x'], p['y']), (p['x']+p['width'],p['y']+p['height']), (0, 0, 255), 2)
|
||||||
# 写编号
|
# 写编号
|
||||||
cv2.putText(sub_im, str(i), (p['x'], p['y']), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
|
cv2.putText(sub_im, str(i), (p['x'], p['y']), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
|
||||||
if(i == 15):
|
|
||||||
print("=========15=======")
|
|
||||||
print(p)
|
|
||||||
cv2.imshow("sub_im_after_filter", sub_im)
|
cv2.imshow("sub_im_after_filter", sub_im)
|
||||||
cv2.waitKey(0)
|
cv2.waitKey(0)
|
4
utils.py
4
utils.py
@ -16,9 +16,7 @@ def filter_points(image_path,points):
|
|||||||
image_height = image.shape[0]
|
image_height = image.shape[0]
|
||||||
image_width = image.shape[1]
|
image_width = image.shape[1]
|
||||||
image_x_min = image_width * left_x_cut_rate
|
image_x_min = image_width * left_x_cut_rate
|
||||||
print(f"image_x_min====={image_x_min}")
|
|
||||||
image_x_max = image_width * (1 - right_x_cut_rate)
|
image_x_max = image_width * (1 - right_x_cut_rate)
|
||||||
print(f"image_x_max====={image_x_max}")
|
|
||||||
|
|
||||||
#开始过滤点
|
#开始过滤点
|
||||||
bad_point_index = []
|
bad_point_index = []
|
||||||
@ -44,13 +42,13 @@ def filter_points(image_path,points):
|
|||||||
if x_max > image_x_max:
|
if x_max > image_x_max:
|
||||||
bad_point_index.append(index)
|
bad_point_index.append(index)
|
||||||
continue
|
continue
|
||||||
print(f'过滤点结束,过滤之后的点数为{len(points)}')
|
|
||||||
|
|
||||||
# 删除bad_point_index
|
# 删除bad_point_index
|
||||||
filtered_points = []
|
filtered_points = []
|
||||||
for i, point in enumerate(points):
|
for i, point in enumerate(points):
|
||||||
if i not in bad_point_index:
|
if i not in bad_point_index:
|
||||||
filtered_points.append(point)
|
filtered_points.append(point)
|
||||||
|
print(f'过滤点结束,过滤之后的点数为{len(filtered_points)}')
|
||||||
return filtered_points
|
return filtered_points
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user