diff --git a/py/__pycache__/get_data.cpython-312.pyc b/py/__pycache__/get_data.cpython-312.pyc index bb13740..170e9f1 100644 Binary files a/py/__pycache__/get_data.cpython-312.pyc and b/py/__pycache__/get_data.cpython-312.pyc differ diff --git a/py/get_data.py b/py/get_data.py index 3317c8e..30078b0 100644 --- a/py/get_data.py +++ b/py/get_data.py @@ -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)): diff --git a/py/measure_lib.py b/py/measure_lib.py index bc67698..7c2244f 100644 --- a/py/measure_lib.py +++ b/py/measure_lib.py @@ -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) \ No newline at end of file +# 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) \ No newline at end of file diff --git a/py/readme.txt b/py/readme.txt new file mode 100644 index 0000000..9bee04d --- /dev/null +++ b/py/readme.txt @@ -0,0 +1,14 @@ +函数说明:vs_measurement(txt_name, position ) +txt_name:路沿数据文件路径 +position:车上某点P与摄像头在X轴(行驶方向)上的偏移量,车头为正,车位为负。 + 若不输入该参数默认为900,指向前车轮中心位置。 + +返回值 state , Zw_pos, distance_pos + +state为-1:txt_name所传输的数据无法使用或数据为空 +state为0:文件路径不存在 +以上两种Zw_pos, distance_pos都为none + +state = 1 : +Zw_pos返回P点或者默认点对应路沿的高度值 +distance_pos返回P点或者默认点与路沿的距离 \ No newline at end of file