简体   繁体   中英

Finding the midpoint of two lines and the distance between them with Python OpenCv or Numpy

I'm trying to make a lane tracking system with python opencv and numpy.

1个

I have progressed as far as it appears in the photo and I have 3 lines in my hand like this

Let's just say the code I'm using is like this

import cv2

img = cv2.imread("D:/object_detection/images/siyah.jpg")

cv2.line(img, (778, 519), (957, 693), (255,0,0),6)
cv2.line(img, (218, 632), (445, 477), (255,0,0),6)
cv2.line(img, (137, 485), (17, 516), (255,0,0),6)

cv2.imshow("img",img)
cv2.waitKey(0)
cv2.destroyAllWindows()

now i have two questions

1 - distance between two lines

  • measure the distance between right lane and middle lane
  • measure the distance between the left lane and the middle lane

2 - midpoint between two lines

  • find the right lane and middle lane midpoint
  • find left lane and middle lane midpoint

You are showing a 2d image that represents the projection of a 3d scene though a camera.

If you want to infer information about the 3d scene (lane width, for example) you need to know how the 3d scene was projected to create the 2d image. In order to do that you need to know the camera parameters (how it transforms the scene), as well as its position and orientation. Also, a single image is not (normally) enough to obtain a complete 3D reconstruction.

OpenCV gives the necessary tools for this. You can start by studying the Camera Calibration and 3D Reconstruction section.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM