Replaced the built round method to custom one

This commit is contained in:
esimov
2019-11-01 07:47:39 +02:00
parent 120801b0e5
commit d4bf7526ef

View File

@@ -112,7 +112,7 @@ func FindFaces(pixels []uint8) uintptr {
dist1 := math.Sqrt(math.Pow(float64(p2.y-p1.y), 2) + math.Pow(float64(p2.x-p1.x), 2))
dist2 := math.Sqrt(math.Pow(float64(p4.y-p3.y), 2) + math.Pow(float64(p4.x-p3.x), 2))
mar := int(math.Round((dist1 / dist2) * 0.19))
mar := int(round((dist1 / dist2) * 0.19))
dets[i] = append(dets[i], flp.Row, flp.Col, int(flp.Scale), int(results[i].Q), 3, mar)
}
@@ -200,3 +200,12 @@ func clusterDetection(pixels []uint8, rows, cols int) []pigo.Detection {
return dets
}
// round returns the nearest integer, rounding ties away from zero.
func round(x float64) float64 {
t := math.Trunc(x)
if math.Abs(x-t) >= 0.5 {
return t + math.Copysign(1, x)
}
return t
}