|
|
|
@ -194,7 +194,7 @@ def fun(x,cameraModel,corners):
|
|
|
|
|
error_y = 0
|
|
|
|
|
error_x = 0
|
|
|
|
|
f = cameraModel.focal_length
|
|
|
|
|
H = x[3] - 9
|
|
|
|
|
H = x[3] -0
|
|
|
|
|
gamma = math.atan(1 / (math.tan(x[0]) * math.tan(x[1])))
|
|
|
|
|
seta = math.atan(1 / math.sqrt(pow(math.tan(x[1]), 2) + 1 / pow(math.tan(x[0]), 2)))
|
|
|
|
|
column = 0
|
|
|
|
@ -231,11 +231,11 @@ def fun(x,cameraModel,corners):
|
|
|
|
|
|
|
|
|
|
def get_result(cameraModel, corners):
|
|
|
|
|
params = cameraModel, corners
|
|
|
|
|
bounds = [(0.1, 1.7), (0.1, 1.7), [-0.5, 0.5],[1000,1020]]
|
|
|
|
|
bounds = [(0.1, 1.7), (0.1, 1.7), [-0.5, 0.5],[1000-9,1020-9]]
|
|
|
|
|
# bounds = [(0.1, 1.7), (0.1, 1.7)]
|
|
|
|
|
result = minimize(
|
|
|
|
|
fun,
|
|
|
|
|
x0=[cameraModel.rotation_alpha, cameraModel.rotation_beta, 0, cameraModel.height],
|
|
|
|
|
x0=[cameraModel.rotation_alpha, cameraModel.rotation_beta, 0, 998],
|
|
|
|
|
args=params,
|
|
|
|
|
# method='Nelder-Mead', # 或 'trust-constr'
|
|
|
|
|
method='L-BFGS-B', bounds=bounds,
|
|
|
|
@ -347,6 +347,7 @@ def check_Extrinsic_Parameters(image_path, output_path, config):
|
|
|
|
|
# image_path = r"C:\Users\Administrator\Desktop\BYD\Visual measurement_model\Visual measurement\img\calibration\origin_img\*.jpg"
|
|
|
|
|
# output_fold =r"C:\Users\Administrator\Desktop\BYD\Visual measurement_model\Visual measurement\img\calibration\undistor_img"
|
|
|
|
|
# config = r"updated_config.json"
|
|
|
|
|
# find_corners(r"C:\Users\Administrator\Desktop\BYD\7.15\)
|
|
|
|
|
# calibrate_and_undistort(image_path,output_fold,config,11,8,60)
|
|
|
|
|
# calibrate_Extrinsic_Parameters("corrected.jpg", config, 11, 8)
|
|
|
|
|
# check_Extrinsic_Parameters("corrected.jpg", "output.jpg", config)
|
|
|
|
@ -361,3 +362,9 @@ def check_Extrinsic_Parameters(image_path, output_path, config):
|
|
|
|
|
# img = cv2.imread(r"C:\Users\Administrator\Desktop\BYD\0718\new415.379489173224.jpg")
|
|
|
|
|
# cv2.line(img, (int(229.67793558711742), 960-int(151.71034206841367)), (result[3],result[4]), (0, 255, 255), 3)
|
|
|
|
|
# cv2.imwrite(r"test.jpg", img)
|
|
|
|
|
|
|
|
|
|
# image_path = r"C:\Users\Administrator\Desktop\BYD\8.5\*.jpg"
|
|
|
|
|
# output_fold = r"C:\Users\Administrator\Desktop\BYD\8.5\undistor_img"
|
|
|
|
|
# config = r"updated_config.json"
|
|
|
|
|
# # find_corners(image_path,7,6)
|
|
|
|
|
# calibrate_and_undistort(image_path,output_fold,config,9,8,100)
|