diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 35410ca..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# 默认忽略的文件
-/shelf/
-/workspace.xml
-# 基于编辑器的 HTTP 客户端请求
-/httpRequests/
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index 72ad4ef..0000000
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
deleted file mode 100644
index 105ce2d..0000000
--- a/.idea/inspectionProfiles/profiles_settings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/measure_lib.iml b/.idea/measure_lib.iml
deleted file mode 100644
index d0876a7..0000000
--- a/.idea/measure_lib.iml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index db8786c..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 88f8f89..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/py/__pycache__/calc_slope_line.cpython-312.pyc b/py/__pycache__/calc_slope_line.cpython-312.pyc
new file mode 100644
index 0000000..3cc8b44
Binary files /dev/null and b/py/__pycache__/calc_slope_line.cpython-312.pyc differ
diff --git a/py/__pycache__/calc_way.cpython-312.pyc b/py/__pycache__/calc_way.cpython-312.pyc
new file mode 100644
index 0000000..f72039a
Binary files /dev/null and b/py/__pycache__/calc_way.cpython-312.pyc differ
diff --git a/py/__pycache__/get_data.cpython-312.pyc b/py/__pycache__/get_data.cpython-312.pyc
new file mode 100644
index 0000000..bb13740
Binary files /dev/null and b/py/__pycache__/get_data.cpython-312.pyc differ
diff --git a/py/__pycache__/model.cpython-312.pyc b/py/__pycache__/model.cpython-312.pyc
new file mode 100644
index 0000000..8eb3450
Binary files /dev/null and b/py/__pycache__/model.cpython-312.pyc differ
diff --git a/py/get_data.py b/py/get_data.py
index 29ee81e..3317c8e 100644
--- a/py/get_data.py
+++ b/py/get_data.py
@@ -54,6 +54,8 @@ 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())
x = []
@@ -65,7 +67,7 @@ def get_data(txt_name):
x = np.array(x)
y = np.array(y)
slope, intercept, r_2 = calc_slope_line.linear_regression(x, y)
- print(r_2)
+ # print(r_2)
x_bot = []
y_bot = []
x_top = []
@@ -83,7 +85,7 @@ def get_data(txt_name):
y_top = np.array(y_top)
slope_bot, intercept_bot, r2_bot = calc_slope_line.linear_regression(x_bot, y_bot)
slope_top, intercept_top, r2_top = calc_slope_line.linear_regression(x_top, y_top)
- print(f"r2_bot = {r2_bot},r2_top = {r2_top}")
+ # print(f"r2_bot = {r2_bot},r2_top = {r2_top}")
if ((1-r2_bot) > 1e-2) or ((1-r2_bot) > 1e-2):
return None, None, None, None
@@ -91,7 +93,7 @@ def get_data(txt_name):
for i in range(len(x_bot)):
if abs(y_bot[i] - slope_bot * x_bot[i] - intercept_bot) > 10:
delet.append(i)
- print(f"len(x_bot): {len(x_bot)},delet: {delet})")
+ # print(f"len(x_bot): {len(x_bot)},delet: {delet})")
x_bot = np.delete(x_bot, delet)
y_bot = np.delete(y_bot, delet)
# y_pred = slope_bot * x_bot + intercept_bot
diff --git a/py/measure_lib.py b/py/measure_lib.py
index 03c52cf..bc67698 100644
--- a/py/measure_lib.py
+++ b/py/measure_lib.py
@@ -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,7 +265,7 @@ 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__':
@@ -280,7 +280,7 @@ if __name__ == '__main__':
# 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)
+ 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
diff --git a/py/readme.txt b/py/readme.txt
deleted file mode 100644
index 08876d6..0000000
--- a/py/readme.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-函数说明:vs_measurement(txt_name,position)
-txt_name : 路沿数据文件路径
-position :车身某点P距离摄像头在X轴(车行进方向)的偏移,车头为正,车尾为负。
- 如不输入该参数,默认为900,指向前车轮中心位置。
-
-返回值:state,Zw_pos, distance_pos
-
-state : -1 , Zw_pos, distance_pos都为None,表示txt_name 所传输的数据为空或无法使用
-state : 0 , Zw_pos, distance_pos都为None,表示txt_name路径不存在
-state : 1
-Zw_pos返回P点对应路沿的高度,distance_pos返回P点距离路沿的距离
\ No newline at end of file
diff --git a/py/test.py b/py/test.py
index 1ce4189..3e2f443 100644
--- a/py/test.py
+++ b/py/test.py
@@ -221,5 +221,4 @@ def vs_measurement(txt_name,position):
return Zw_intersection, distance, Zw_pos , distance_pos
-
-vs_measurement(txt_name,877)
\ No newline at end of file
+#