vector<Point2f> QRDetect::separateVerticalLines(const vector<Vec3d> &list_lines)
{
CV_TRACE_FUNCTION();
-
- for (int coeff_epsilon = 1; coeff_epsilon < 10; coeff_epsilon++)
+ const double min_dist_between_points = 10.0;
+ const double max_ratio = 1.0;
+ for (int coeff_epsilon_i = 1; coeff_epsilon_i < 101; ++coeff_epsilon_i)
{
+ const float coeff_epsilon = coeff_epsilon_i * 0.1f;
vector<Point2f> point2f_result = extractVerticalLines(list_lines, eps_horizontal * coeff_epsilon);
if (!point2f_result.empty())
{
point2f_result, 3, labels,
TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 10, 0.1),
3, KMEANS_PP_CENTERS, centers);
- if (compactness == 0)
+ double min_dist = std::numeric_limits<double>::max();
+ for (size_t i = 0; i < centers.size(); i++)
+ {
+ double dist = norm(centers[i] - centers[(i+1) % centers.size()]);
+ if (dist < min_dist)
+ {
+ min_dist = dist;
+ }
+ }
+ if (min_dist < min_dist_between_points)
+ {
continue;
- if (compactness > 0)
+ }
+ double mean_compactness = compactness / point2f_result.size();
+ double ratio = mean_compactness / min_dist;
+
+ if (ratio < max_ratio)
{
return point2f_result;
}
vector<Point2f> list_lines_y = separateVerticalLines(list_lines_x);
if( list_lines_y.empty() ) { return false; }
- vector<Point2f> centers;
Mat labels;
kmeans(list_lines_y, 3, labels,
TermCriteria( TermCriteria::EPS + TermCriteria::COUNT, 10, 0.1),
fixationPoints(localization_points);
- bool suare_flag = false, local_points_flag = false;
+ bool square_flag = false, local_points_flag = false;
double triangle_sides[3];
double triangle_perim, square_area, img_square_area;
if (localization_points.size() == 3)
if (square_area > (img_square_area * 0.2))
{
- suare_flag = true;
+ square_flag = true;
}
}
else
{
local_points_flag = true;
}
- if ((suare_flag || local_points_flag) && purpose == SHRINKING)
+ if ((square_flag || local_points_flag) && purpose == SHRINKING)
{
localization_points.clear();
bin_barcode = resized_bin_barcode.clone();
}
}
}
+ for (int i = 0; i < NUM_SIDES; i++)
+ {
+ if (spline_lines[i].size() == 0)
+ {
+ return false;
+ }
+ }
return true;
}