diff --git a/Visual measurement-straight/.idea/.name b/Visual measurement-straight/.idea/.name new file mode 100644 index 0000000..8fdfb52 --- /dev/null +++ b/Visual measurement-straight/.idea/.name @@ -0,0 +1 @@ +model.py \ No newline at end of file diff --git a/Visual measurement-straight/.idea/vcs.xml b/Visual measurement-straight/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Visual measurement-straight/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Visual measurement-straight/py/Calibration.py b/Visual measurement-straight/py/Calibration.py index 3acf218..32e0a1b 100644 --- a/Visual measurement-straight/py/Calibration.py +++ b/Visual measurement-straight/py/Calibration.py @@ -109,6 +109,7 @@ def fun_test(x,cls,corners): # print(corners) error = 0 error_y = 0 + error_x = 0 model = cls() f = model.f H = model.H - 9 @@ -116,12 +117,15 @@ def fun_test(x,cls,corners): seta = math.atan(1 / math.sqrt(pow(math.tan(x[1]), 2) + 1 / pow(math.tan(x[0]), 2))) column = 0 k = 0 + k1 = 0 for index, value in enumerate(corners): if index % 11 == 10: column += 1 index += 1 k += 1 + k1 = 0 continue + k1 += 1 Xw, Yw = calc_way.calc_distance(value[0], value[1], x[0], x[1]) Xw1, Yw1 = calc_way.calc_distance(corners[index+1][0], corners[index+1][1], x[0], x[1]) print(f"第{index}个点") @@ -130,11 +134,13 @@ def fun_test(x,cls,corners): d2 = math.sqrt((Xw1 - Xw) ** 2 + (Yw1 - Yw) ** 2) print(f"两点距离为:{d2:.2f}") error = error + abs(d2 - 60) - d_y = abs(570-60*k-50+Yw) + d_y = abs(570-60*k-77+Yw) error_y = error_y + d_y + d_x = abs(488 + 760-60*k-Xw ) + error_x = error_x + d_x print(f"平均误差为:{error/80:.2f}") print(f"errpr_y:{error/80:.2f}") - return error/80 + error_y/80 + return error/80 + error_y/80 + error_x/80 def get_result_test(cls,corners): params = cls,corners @@ -185,7 +191,7 @@ def undistort_image(image_path, camera_matrix, dist_coeffs): # result = get_result_test(model.Model,find_corners("corrected.jpg",11,8)) # print(result) # find_corners("corrected.jpg",11,8) -# x_zeros,y_zeros = calc_way.calc_zeros_yto0(-200) +# x_zeros,y_zeros = calc_way.calc_zeros_yto0(-90) # print(x_zeros,y_zeros) # # 读取图像 # img = cv2.imread("corrected.jpg") diff --git a/Visual measurement-straight/py/__pycache__/model.cpython-312.pyc b/Visual measurement-straight/py/__pycache__/model.cpython-312.pyc index de20a22..4695bc7 100644 Binary files a/Visual measurement-straight/py/__pycache__/model.cpython-312.pyc and b/Visual measurement-straight/py/__pycache__/model.cpython-312.pyc differ diff --git a/Visual measurement-straight/py/model.py b/Visual measurement-straight/py/model.py index eb1b4db..12cced4 100644 --- a/Visual measurement-straight/py/model.py +++ b/Visual measurement-straight/py/model.py @@ -39,8 +39,8 @@ class Model: # 外参 # self.alpha = 8.749e-01 # self.beta = 7.664e-01 - self.alpha = 9.478e-01 - self.beta = 8.111e-01 + self.alpha = 9.951e-01 + self.beta = 7.263e-01 # 位置修正 self.y = -50 self.x = 22 diff --git a/Visual measurement-straight/py/output.jpg b/Visual measurement-straight/py/output.jpg index 02ebaa1..4e1e027 100644 Binary files a/Visual measurement-straight/py/output.jpg and b/Visual measurement-straight/py/output.jpg differ