My app is supposed to estimate the length (in millimeters) of an object using euro coins as reference. This is a screenshot example:
To get the diameter of the photographed coin I first calculate the equation of a the circle passing through those 3 points of the form
x^2 + y^2 + ax + by + c = 0
and then I have the diameter by
2 * square_root((a/2)^2 + (b/2)^2 -c)
.
Finally I can perform the following proportion to get the length of the red pen:
/* length_estimated_pen (mm) : distance_green_pins (points) = real_diameter_coin (mm) : diameter_on_screen (points) */
let distanceGreen:Double = Double(sqrt(pow(self.greenLocationA.center.x - self.greenLocationB.center.x, 2.0) + pow(self.greenLocationA.center.y - self.greenLocationB.center.y, 2.0)))
let estimatedMeasure:Double = (distanceGreen * Double(ChosenMeter.moneyDiameter)) / diameter
where in ChosenMeter.moneyDiameter
there is stored the real diameter of the chosen coin as reference (by clicking one of the 3 buttons below).
I need to work with Double
instead of CGFloat
because this tutorial to solve a system of linear equations (to get a,b,c coefficient of circle equation) works with Double.
The problem is the estimated length of the red pen is always overestimated
of more than 10 mm.
I guess I should apply a correction factor or complicate the calculus taking into consideration other factors, but which? Can you give me some hints? Any help would be useful to me.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…