From f68b161269ee75fab9cab1fdd1a913f841c96433 Mon Sep 17 00:00:00 2001 From: Nuzhny007 Date: Thu, 3 Sep 2026 18:13:00 +0300 Subject: [PATCH] Fix bug with a Haversine distance --- example/CarsCounting.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/example/CarsCounting.h b/example/CarsCounting.h index 92967286..904abad9 100644 --- a/example/CarsCounting.h +++ b/example/CarsCounting.h @@ -18,8 +18,9 @@ T Haversine(const cv::Point_& from, const cv::Point_& to) lat_h *= lat_h; T lon_h = sin(lon_arc * static_cast(0.5)); lon_h *= lon_h; - T tmp = cos(from.x * Deg2Rad) * cos(to.y * Deg2Rad); - return static_cast(2.0) * asin(sqrt(lat_h + tmp * lon_h)); + T tmp = cos(from.x * Deg2Rad) * cos(to.x * Deg2Rad); + T a = lat_h + tmp * lon_h; + return static_cast(2.0) * atan2(sqrt(a), sqrt(static_cast(1.0) - a)); } ///