How to trace a spline in the middle of an irregular curved street?

38 Views Asked by At

I'm creating a program that should drive a car through the middle of a street.

The street, as shown below, is a bitmap with irregular curves.

I would like my program to calculate a central route, that is, that it finds the middle between each side of the street, where would be the orientation for the passage of the car.

enter image description here

The problem is that the algorithm has to identify what a curve is and in addition, know at what angle the curve points, to from there find its center.

Would anyone give me a tip?