Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

角度容差设置问题 #49

Open
xushaolei123 opened this issue Oct 22, 2023 · 2 comments
Open

角度容差设置问题 #49

xushaolei123 opened this issue Oct 22, 2023 · 2 comments

Comments

@xushaolei123
Copy link

您好,想请教一下使用实例图片Src1.bmp测试时,当角度容差允许值非零时,就会出现程序崩溃的情况,崩溃的程序位于MathToolDlg.cpp 1064行

@DennisLiu1993
Copy link
Owner

可能是Windows造成的exception
試試這個解法
https://github.com/DennisLiu1993/Fastest_Image_Pattern_Matching/blob/main/README.md#special-note

@xushaolei123
Copy link
Author

谢谢博主,已经解决了,在types.hpp大致1847行添加下面代码,确实是windows的原因
inline
RotatedRect::RotatedRect(const Point2f& _point1, const Point2f& _point2, const Point2f& _point3)
{
Point2f _center = 0.5f * (_point1 + _point3);
Vec2f vecs[2];
vecs[0] = Vec2f(_point1 - _point2);
vecs[1] = Vec2f(_point2 - _point3);
double x = std::max(norm(_point1), std::max(norm(_point2), norm(_point3)));
double a = std::min(norm(vecs[0]), norm(vecs[1]));
// check that given sides are perpendicular
// this is the line you need to modify
CV_Assert(std::fabs(vecs[0].ddot(vecs[1])) * a <= FLT_EPSILON * 9 * x * (norm(vecs[0]) * norm(vecs[1])));

// wd_i stores which vector (0,1) or (1,2) will make the width
// One of them will definitely have slope within -1 to 1
int wd_i = 0;
if (std::fabs(vecs[1][1]) < std::fabs(vecs[1][0])) wd_i = 1;
int ht_i = (wd_i + 1) % 2;

float _angle = std::atan(vecs[wd_i][1] / vecs[wd_i][0]) * 180.0f / (float)CV_PI;
float _width = (float)norm(vecs[wd_i]);
float _height = (float)norm(vecs[ht_i]);

center = _center;
size = Size2f(_width, _height);
angle = _angle;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants