Closed aiwithshekhar closed 4 years ago
Hi, did you solve this problem?
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
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):
` 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 ].