wvangansbeke / LaneDetection_End2End

End-to-end Lane Detection for Self-Driving Cars (ICCV 2019 Workshop)
https://arxiv.org/pdf/1902.00293.pdf
Other
643 stars 216 forks source link

Calculated params don't match the params provided in Curve_parameters.json #75

Closed aiwithshekhar closed 4 years ago

aiwithshekhar commented 4 years ago

For verifying the curve parameters i used one of you parameters and tried to deduce it as shown below. But the params i got didm't matched with the ones provided by you. What mistake am i making?

File used: Curve_parameters.json, raw_file': 'clips/0313-1/6040/20.jpg 'poly_params': [-0.0006496997648889662,0.032857701032923604,0.4660359613854808]


`def homogenous_transformation(Matrix, x, y):

ones = np.ones((1,len(y)))
coordinates = np.vstack((x, y, ones))
trans = np.matmul(Matrix, coordinates)

x_vals = trans[0,:]/trans[2,:]
y_vals = trans[1,:]/trans[2,:]
return x_vals, y_vals`

` 1) Preprocessing prespective cordinates. h_sam=fi['h_samples'] y_orig=np.array(h_sam)

lanes=fi['lanes'] x_orig=np.array(lanes[0])

h = [y for x,y in zip(lanes[0], h_sam) if x!=-2] # only those values where -2 are not present.

if len(h) == 0: minimum, maximum = 250, 710 else: minimum, maximum = np.min(h), np.max(h) #threhold for points defined.

x_new, y_new = zip(*[(x,y) if y >= max(210,minimum) and y <= maximum else (-2,y) for x,y in zip(x_orig, y_orig)]) x_new, y_new =np.array(x_new), np.array(y_new) #based on threshold new x and y values are kept. x_new, y_new = x_new/1279, (y_new-80)/639 #normalising the x,y values between range (0,1)

2) Generating the Transformation matrix y_start = 0.3 y_stop = 1 src = np.float32([[0.45,y_start],[0.55, y_start],[0.1,y_stop],[0.9, y_stop]]) dst = np.float32([[0.45, y_start],[0.55, y_start],[0.45, y_stop],[0.55,y_stop]]) M = cv2.getPerspectiveTransform(src,dst) M_inv = cv2.getPerspectiveTransform(dst,src)

3) transforming to bird eye view cordinates. x_prime, y_prime=homogenous_transformation(M, x_new, y_new)

4) 2nd degree polynomial fit on the transformed cordinates. beta_0=np.polyfit(y_prime, x_prime, deg=2)`

Parameters what i get is [-0.53085094, 1.01749485, -0.0095993 ].

yoga-0125 commented 4 years ago

Hi, did you solve this problem?

wvangansbeke commented 4 years ago

Hi @aiwithshekhar,

These values can change slightly depending on the exact values in the homography matrix. This matrix is defined by 3 points (= 1 point close to the vanishing point at the top and 2 points on the lane lines at the bottom). It seems that the differences are caused by small changes of the point at the top. However, this shouldn't alter the final result much. I would advise to plot the lines on the transformed image and check if it's correct. Otherwise there is an inconsistency between the transformation parameters in the included file and the used transformation matrix in the code snippet above.

Best, Wouter