Skip to content

Commit

Permalink
修改摄像头参数
Browse files Browse the repository at this point in the history
  • Loading branch information
zjn20021020 committed Aug 13, 2023
1 parent 1cb92ef commit 9bc07d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions deploy/infer-onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ class Args:
def main():
model_infer = ONNXInfer(Args.weight_file)

camera_matrix = np.array([[309.90395107, 0.00000000e+00, 300.39021399], [0.00000000e+00, 302.16360458, 246.21441832], [0.00000000e+00, 0.00000000e+00, 1.00000000e+00]])
distortion_coefficients = np.array([-0.32984359, 0.11556734, -0.00545855, 0.00248696, -0.01897801])
camera_matrix = np.array([[654.70620869, 0.00000000e+00, 620.18116133], [0.00000000e+00, 656.66098208, 433.29648979], [0.00000000e+00, 0.00000000e+00, 1.00000000e+00]])
distortion_coefficients = np.array([-0.32841624, 0.10118464, 0.00383333, 0.00071582, -0.01392005])

# cap = cv2.VideoCapture(Args.video)
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 960)
skip_frame = 2 # 每隔 skip_frame 帧进行一次推理
i = 0
try:
Expand All @@ -66,13 +68,15 @@ def main():
crop_h = int(img_w * 0.36) # 0.36 = 288 / 800
# crop_h = 0 # 如果不裁切,可以改成 0

img = cv2.resize(frame, (img_w, img_h))
img=img[200:, :]
# img = cv2.resize(frame, (img_w, img_h))



add_h = img_h - 0
crop_img = img[add_h : img_h, :, :] # 裁切下半部分
img = undistort_image(frame, camera_matrix, distortion_coefficients)
img = img[0: img_h, :600, :] # 裁切下半部分
img = undistort_image(img, camera_matrix, distortion_coefficients)
img = img[:, :1200, :] # 裁切下半部分
# img = color_extraction(img)

infer_result: InferResult = model_infer.infer(img)
Expand Down
4 changes: 2 additions & 2 deletions deploy/utils/base_model_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ def infer(self, img: np.ndarray, is_kalman=False):
if (left_x0 == 0 and right_x0 == 0):
y_offset = np.int32(0)
elif (left_x0 != 0 and right_x0 == 0):
y_offset = np.int32(left_x0 - 20)
y_offset = np.int32(left_x0 - 40)
elif (left_x0 == 0 and right_x0 != 0):
y_offset = np.int32(right_x0 - 580)
y_offset = np.int32(right_x0 - 1160)
else:
y_offset = np.int32(predict_direct[0][0] - forward_direct[0][0])

Expand Down

0 comments on commit 9bc07d8

Please sign in to comment.