mirror of
https://github.com/opencv/opencv.git
synced 2026-01-18 17:21:42 +01:00
Merge pull request #28157 from dkurt:normalize_vec_qrdetect
Remove floating point arithmetic from angle computation in QR codes #28157 ### Pull Request Readiness Checklist resolves https://github.com/opencv/opencv/issues/24646 See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -83,8 +83,10 @@ static Point2f intersectionLines(Point2f a1, Point2f a2, Point2f b1, Point2f b2)
|
||||
// / |
|
||||
// a/ | c
|
||||
|
||||
static inline double getCosVectors(Point2f a, Point2f b, Point2f c)
|
||||
static inline double getCosVectors(Point a, Point b, Point c)
|
||||
{
|
||||
CV_DbgCheckNE(a, b, "Angle between vector and point is undetermined");
|
||||
CV_DbgCheckNE(b, c, "Angle between vector and point is undetermined");
|
||||
return ((a - b).x * (c - b).x + (a - b).y * (c - b).y) / (norm(a - b) * norm(c - b));
|
||||
}
|
||||
|
||||
@@ -825,7 +827,11 @@ vector<Point2f> QRDetect::getQuadrilateral(vector<Point2f> angle_list)
|
||||
Point intrsc_line_hull =
|
||||
intersectionLines(hull[index_hull], hull[next_index_hull],
|
||||
angle_list[1], angle_list[2]);
|
||||
double temp_norm = getCosVectors(hull[index_hull], intrsc_line_hull, angle_closest_pnt);
|
||||
double temp_norm = min_norm;
|
||||
if (intrsc_line_hull != angle_closest_pnt)
|
||||
{
|
||||
temp_norm = getCosVectors(hull[index_hull], intrsc_line_hull, angle_closest_pnt);
|
||||
}
|
||||
if (min_norm > temp_norm &&
|
||||
norm(hull[index_hull] - hull[next_index_hull]) >
|
||||
norm(angle_list[1] - angle_list[2]) * 0.1)
|
||||
@@ -863,7 +869,11 @@ vector<Point2f> QRDetect::getQuadrilateral(vector<Point2f> angle_list)
|
||||
Point intrsc_line_hull =
|
||||
intersectionLines(hull[index_hull], hull[next_index_hull],
|
||||
angle_list[0], angle_list[1]);
|
||||
double temp_norm = getCosVectors(hull[index_hull], intrsc_line_hull, angle_closest_pnt);
|
||||
double temp_norm = min_norm;
|
||||
if (intrsc_line_hull != angle_closest_pnt)
|
||||
{
|
||||
temp_norm = getCosVectors(hull[index_hull], intrsc_line_hull, angle_closest_pnt);
|
||||
}
|
||||
if (min_norm > temp_norm &&
|
||||
norm(hull[index_hull] - hull[next_index_hull]) >
|
||||
norm(angle_list[0] - angle_list[1]) * 0.05)
|
||||
|
||||
Reference in New Issue
Block a user