Paul597 4 months ago
commit 561ad866d9

@ -54,10 +54,10 @@ def get_data(txt_name):
with open(txt_name, 'r', encoding='utf-8') as f:
lines = f.readlines()
data = []
if not data:
return None, None, None, None
for i, line in enumerate(lines, 1):
data.append(line.split())
if not data:
return None, None, None, None
x = []
y = []
for i in range(len(data)):

@ -236,7 +236,7 @@ def vs_measurement(txt_name, position = 900):
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)
# print(Xw_intersection, Yw_intersection)
# #位置修正
# Yw_intersection = Yw_intersection + model.y
Xw_bot = []
@ -268,19 +268,19 @@ def vs_measurement(txt_name, position = 900):
return 1, Zw_pos, distance_pos
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()
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)
# 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()
# 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}")
# print( Zw_pos, distance_pos)

@ -0,0 +1,14 @@
函数说明vs_measurement(txt_name, position )
txt_name路沿数据文件路径
position车上某点P与摄像头在X轴行驶方向上的偏移量车头为正车位为负。
若不输入该参数默认为900指向前车轮中心位置。
返回值 state Zw_pos, distance_pos
state为-1txt_name所传输的数据无法使用或数据为空
state为0文件路径不存在
以上两种Zw_pos, distance_pos都为none
state = 1
Zw_pos返回P点或者默认点对应路沿的高度值
distance_pos返回P点或者默认点与路沿的距离
Loading…
Cancel
Save