|
|
|
@ -173,13 +173,13 @@ output_folder = 'C:\\Users\\Administrator\\Desktop\\BYD\\Visual measurement\\pic
|
|
|
|
|
# Y = Y + Yw
|
|
|
|
|
# return Z/len(x_bot),-max_Yw
|
|
|
|
|
|
|
|
|
|
def vs_measurement(txt_name,position):
|
|
|
|
|
def vs_measurement(txt_name, position = 900):
|
|
|
|
|
if not os.path.exists(txt_name):
|
|
|
|
|
return 0, None,None,None,None
|
|
|
|
|
return 0, None,None
|
|
|
|
|
# 获取数据
|
|
|
|
|
x_bot, y_bot, x_top, y_top = get_data.get_data(txt_name)
|
|
|
|
|
if x_bot.any() == None:
|
|
|
|
|
return 0, None, None, None, None
|
|
|
|
|
return -1, None, None
|
|
|
|
|
# x_bot = np.array(x_bot)
|
|
|
|
|
# y_bot = np.array(y_bot)
|
|
|
|
|
# x_top = np.array(x_top)
|
|
|
|
@ -236,7 +236,7 @@ def vs_measurement(txt_name,position):
|
|
|
|
|
x, y = calc_slope_line.find_intersection((k, -1, b), (slope_top, -1, intercept_top))
|
|
|
|
|
Zw_intersection = calc_way.calc_height(x_intersection, y_intersection, x, y, alpha, beta)
|
|
|
|
|
Xw_intersection, Yw_intersection = calc_way.calc_distance(x_intersection, y_intersection, alpha, beta)
|
|
|
|
|
|
|
|
|
|
# print(Xw_intersection, Yw_intersection)
|
|
|
|
|
# #位置修正
|
|
|
|
|
# Yw_intersection = Yw_intersection + model.y
|
|
|
|
|
Xw_bot = []
|
|
|
|
@ -265,22 +265,22 @@ def vs_measurement(txt_name,position):
|
|
|
|
|
distance = - Yw_intersection * math.cos(angle)
|
|
|
|
|
distance_pos = -(Yw_pos + model.y) * math.cos(angle)
|
|
|
|
|
# distance_pos = ((-intercept_Xw / slope_Xw) - position) / ((-intercept_Xw / slope_Xw) - Xw_intersection) * distance
|
|
|
|
|
return 1, Zw_intersection, distance, Zw_pos, distance_pos
|
|
|
|
|
return 1, Zw_pos, distance_pos
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
# if __name__ == '__main__':
|
|
|
|
|
# # t=time.time()
|
|
|
|
|
# # h, w = vs_measurement(r'C:\Users\Administrator\Desktop\BYD\Visual measurement\py\new.txt')
|
|
|
|
|
# # print(h,w)
|
|
|
|
|
# # print(f"time: {time.time() - t}")
|
|
|
|
|
# # x_zero, y_zero = calc_way.calc_zeros()
|
|
|
|
|
# # x_zero = np.array(x_zero)
|
|
|
|
|
# # y_zero = np.array(y_zero)
|
|
|
|
|
# # print(f"x_zero: {x_zero}")
|
|
|
|
|
# # print(f"y_zero: {y_zero}")
|
|
|
|
|
# t = time.time()
|
|
|
|
|
# h, w = vs_measurement(r'C:\Users\Administrator\Desktop\BYD\Visual measurement\py\new.txt')
|
|
|
|
|
# print(h,w)
|
|
|
|
|
# test_name = r'C:\Users\Administrator\Desktop\BYD\error\20250620\20250620\INPUT_MUST_NOT_BE_EMPTY.txt'
|
|
|
|
|
# state, Zw_pos, distance_pos = vs_measurement(test_name, 900)
|
|
|
|
|
# # vs_measurement(txt_name)
|
|
|
|
|
# print(f"time: {time.time() - t}")
|
|
|
|
|
# x_zero, y_zero = calc_way.calc_zeros()
|
|
|
|
|
# x_zero = np.array(x_zero)
|
|
|
|
|
# y_zero = np.array(y_zero)
|
|
|
|
|
# print(f"x_zero: {x_zero}")
|
|
|
|
|
# print(f"y_zero: {y_zero}")
|
|
|
|
|
t = time.time()
|
|
|
|
|
test_name = r'C:\Users\Administrator\Desktop\BYD\error\20250620\20250620\CANNOT_CALCULATE_LINER_REGRESSION_.txt'
|
|
|
|
|
state, Zw_intersection, distance, Zw_pos, distance_pos = vs_measurement(test_name,900)
|
|
|
|
|
# vs_measurement(txt_name)
|
|
|
|
|
print(f"time: {time.time() - t}")
|
|
|
|
|
print(Zw_intersection, distance, Zw_pos, distance_pos)
|
|
|
|
|
# print( Zw_pos, distance_pos)
|