fix
This commit is contained in:
parent
304d9422e3
commit
520cb9ed15
26
search.py
26
search.py
@ -335,11 +335,11 @@ if __name__ == "__main__":
|
||||
# _im_edge_sobel = _sobel(sub_zero)
|
||||
# _, _im_thresh = cv2.threshold(_im_edge_sobel, 5, 255, cv2.THRESH_BINARY)
|
||||
# cnts = _findContours(_im_thresh)
|
||||
original_rectangle = read_from_json("data_sub/test_2/data_sub.json")
|
||||
original_rectangle = read_from_json("data_sub/test_3/data_sub.json")
|
||||
# 过滤矩形
|
||||
# cnts 过滤之后的矩形
|
||||
# sub_im 裁剪之后的图像
|
||||
cnts,sub_im = filter_rectangle("data_sub/test_2/wide_image.png", original_rectangle)
|
||||
cnts,sub_im = filter_rectangle("data_sub/test_3/wide_image.png", original_rectangle)
|
||||
sub_zero = np.zeros_like(sub_im)
|
||||
for contour in cnts:
|
||||
# x, y, w, h = cv2.boundingRect(contour)
|
||||
@ -453,7 +453,6 @@ if __name__ == "__main__":
|
||||
polar_list.append([r, theta])
|
||||
sum_r /= count * sub_roi_w_base_len
|
||||
sum_theta /= count
|
||||
print(count, sum_r, sum_theta)
|
||||
print(f"[所有点到该预埋件左上点的个数] ====== [{count}]")
|
||||
print(f"[所有点到该预埋件左上点的平均极半径] ====== [{sum_r}]")
|
||||
print(f"[所有点到该预埋件左上点的平均极角] ====== [{sum_theta}]")
|
||||
@ -522,7 +521,12 @@ if __name__ == "__main__":
|
||||
sc1 = compute_shape_context(cartesian_points1)
|
||||
sc2 = compute_shape_context(cartesian_points2)
|
||||
match_score = match_shapes(sc1, sc2)
|
||||
print(score, match_score, tmp_count, tmp_sum_r, tmp_sum_theta)
|
||||
print("score>0.6")
|
||||
print(f"[score] ====== [{score}]")
|
||||
print(f"[match_score] ====== [{match_score}]")
|
||||
print(f"[tmp_count] ====== [{tmp_count}]")
|
||||
print(f"[tmp_sum_r] ====== [{tmp_sum_r}]")
|
||||
print(f"[tmp_sum_theta] ====== [{tmp_sum_theta}]")
|
||||
if match_score < 5.0: #????
|
||||
param["start_point"] = (tmp_roi_start_x, tmp_roi_start_y)
|
||||
param["end_point"] = (tmp_roi_end_x, tmp_roi_end_y)
|
||||
@ -551,7 +555,7 @@ if __name__ == "__main__":
|
||||
print(f"起始预埋件ID:{id},置信度为:{score[0]},点数量:{score[1]},平均长度为:{score[2]},平均角度为:{score[3]}")
|
||||
print(f"match_sscore为:{match_score}")
|
||||
bim_im = cv2.rectangle(bim_im, param["start_point"], \
|
||||
param["end_point"], 100 * (i+1), 6)
|
||||
param["end_point"], 100 * (i+1), 50)
|
||||
|
||||
elapsed_time = time.time() - start_time
|
||||
print(f"Execution time: {elapsed_time:.4f} seconds")
|
||||
@ -559,10 +563,10 @@ if __name__ == "__main__":
|
||||
# sub_im = cv2.resize(sub_im, (int(sub_im.shape[1]/10), int(sub_im.shape[0]/10)))
|
||||
cv2.imshow("2", img_matches)
|
||||
# cnts的矩形画在sub_im 上
|
||||
for i in range(len(cnts)):
|
||||
p = cnts[i]
|
||||
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.imshow("sub_im_after_filter", sub_im)
|
||||
# for i in range(len(cnts)):
|
||||
# p = cnts[i]
|
||||
# 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.imshow("sub_im_after_filter", sub_im)
|
||||
cv2.waitKey(0)
|
Loading…
Reference in New Issue
Block a user