How to convert pixels to meters in kitti dataset?

136 Views Asked by At

I have checked the related topics but none of them answered my question.I have used kitti dataset for my neural network, I have no problem in detecting objects. The only thing I don't understand is that I have obtained the distance of objects in pixels, but I don't know how to convert them to meters? The values I want to convert to meters:

class 0 class 1 distance  is: 184.33062561920545
class 0 class 2 distance  is: 59.157488166238295
class 1 class 2 distance  is: 241.9236599379254

The values I obtained using the "dist_calculator" code:

0.45786248198605186
0.4417580846368999
0.4642980966255596

I have found the following code, but because it does not use the calibration data file, I think it is wrong.please guide me

def dist_calculator(startX, startY, endX, endY, box_width, box_height, img_w, img_h):

x_3, y_3 = startX, endY - (box_height / 7)  # top left of the triangle
# assumption: camera is rasied above the ground so considering 90% of the height of the image 
height
x_1, y_1 = img_w / 2, 0.9 * img_h  # bottom of the triangle
x_2, y_2 = endX, endY - (box_height / 7)  # top right of the triangle

# find the angle between bottom and right point
angle_x1_x2 = math.degrees(math.atan2(x_1 - x_2, y_1 - y_2))
# find the angle between bottom and left point
angle_x1_x3 = math.degrees(math.atan2(x_1 - x_3, y_1 - y_3))

angle_right = 90 + angle_x1_x2
angle_left = 90 - angle_x1_x3

# total angle of view for the bench from bottom center point of the image.
total_angle = angle_right + angle_left

# Bench length assumed to be 2 metersin millimeters. This value can automated, based on the 
 type of bench used.
 bench_length = 2000

 distance = (bench_length * (1 / total_angle) * 57) / 1000

#print(total_angle)
print(distance)

return total_angle, distance
0

There are 0 best solutions below