Open cj1ne opened 6 years ago
Hi cj1ne! well these magic numbers are, as you can see in the return, the coefficients of the model a e ^ (b x) + c e ^ (d x). This is the model I used to map the widths of the detection boxes (in pixels) to some approximation to the distance of the car in front (in meters). I got this approximation by taking a dataset with the ground truth distances to different cars and then simply adjust the model to map the detections to the ground truth distances. Probably not the best way to do it haha. Best, Alfonso
Thanks for your reply, Alfonso!
Can you describe the way of getting magic number by taking a dataset. If it's not best way to do, it's really helpful to me.
Hi, no problem, essentially spend some days taking pictures from the rare of cars and measuring the distance between them and me, that was my "ground truth". Afterwards I ran my classifier on those very same pictures and got the detection boxes for each car. The goal was to give an estimation of the ground truth distances only based on the size of the detection boxes. The simplest thing i could imagine was then to dump all these <box size, distance> pairs in a MatLab vector and try to fit different models to it. This exponential model was the one that could better fit the data.
You can imagine many reasons why this approach would not be remotely precise in a real world scenario. First, it all depends on how good is your classifier and how consistent is the relative size of the detection boxes at different scales. Second, different cars have different widths therefore making this approximation car-dependent. Third, it is camera dependent, you can not use the same model with different cameras.
As a prove of concept I guess this is a good enough approach but you might want to check real solutions to this problem in the scientific community
Thanks a lot Alfonso and sorry for late reply.
I drew a line in the road per meter and take a photo at the car's hood. In the image, I found correlation between pixel size and the real distance per meter. Then, I got an exponential function using non-linear regression from this dataset. I demonstrated this model in real road and it works well.
Your comment was very helpful to try this measure. Thank you!
Hi alfonsoros88!
I'm really thanks to your open source project.
In your project, I had a question. That's formula for calculating distance. You used this function
public static double pixels_to_meters(double x) { double a = 286.2713350528750; double b = -75.44461973326037; double c = 36.00759908705765; double d = -8.988638172976206; return a Math.exp(b x) + c Math.exp(d x); }
Can you describe about variable(a,b,c,d) and the formula(return)? Thanks a lot!