JunshengFu / driving-lane-departure-warning

Built a real-time lane departure warning system with a monocular camera, using OpenCV.
GNU General Public License v3.0
221 stars 103 forks source link

Error in calculation of the center offset #8

Open Mojzaar opened 5 years ago

Mojzaar commented 5 years ago

I'm using your code for my camera's output in a simulator but I noticed that the calculated offset from the middle line is wrong. Have I messed something? I checked one of the camera's image and it seems that the algorithm does not recognize the lanes, correctly. In the picture, the car virtually is in the middle of the lanes and lane's distance is 3.3 meter and it is a straight road. my pic0

JunshengFu commented 5 years ago

Calibrate your camera. I use hard-coded values for my camera setup. And my transformation is not suitable for yours, see your bird-view as an example: if your camera is calibrated, you should see two parallel lanes.

Mojzaar commented 5 years ago

Thanks for your prompt answer.

I saw that there is a camera_cal folder in your source code. I have to put the camera's outputs there and run the code. Will the transformation be updated automatically or I should change it inside the code?

Actually, I'm using the simulator's camera. Should I take image inside the simulator's environment or is there any other way to calibrate the camera?

JunshengFu commented 5 years ago

please read https://github.com/JunshengFu/driving-lane-departure-warning#3-how-to-run-the-code and https://github.com/JunshengFu/driving-lane-departure-warning#3-use-perspective-transform-to-see-the-image-in-bird-view

Mojzaar commented 5 years ago

I read the document and also I calibrated the camera with calibration.py. But the calculated offset is still wrong. Have I forgotten another thing?

Thanks for your guidance.

my

JunshengFu commented 5 years ago

https://github.com/JunshengFu/driving-lane-departure-warning#3-use-perspective-transform-to-see-the-image-in-bird-view If you did above step right, you should already see the correct bird view.