Skip to content

Commit 0792588

Browse files
committed
Merge pull request #3389 from alalek:build_warnings_msvc
2 parents d6102ef + bf4dd56 commit 0792588

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

modules/ximgproc/src/find_ellipses.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,11 @@ float EllipseDetectorImpl::getMedianSlope(std::vector<Point2f> &med, Point2f &ce
310310
// centers : centroid of the points in med
311311
// slopes : vector of the slopes
312312

313-
unsigned pointCount = med.size();
313+
size_t pointCount = med.size();
314314
// CV_Assert(pointCount >= 2);
315315

316-
unsigned halfSize = pointCount >> 1;
317-
unsigned quarterSize = halfSize >> 1;
316+
size_t halfSize = pointCount >> 1;
317+
size_t quarterSize = halfSize >> 1;
318318

319319
std::vector<float> xx, yy;
320320
slopes.reserve(halfSize);
@@ -333,7 +333,7 @@ float EllipseDetectorImpl::getMedianSlope(std::vector<Point2f> &med, Point2f &ce
333333
float den = (p2.x - p1.x);
334334
float num = (p2.y - p1.y);
335335

336-
if (den == 0) den = 0.00001f;
336+
den = (std::fabs(den) >= 1e-5) ? den : 0.00001f; // FIXIT: algorithm is not reliable
337337

338338
slopes.push_back(num / den);
339339
}
@@ -1341,7 +1341,7 @@ void EllipseDetectorImpl::preProcessing(Mat1b &image, Mat1b &dp, Mat1b &dn) {
13411341
}
13421342

13431343
const int CANNY_SHIFT = 15;
1344-
const float TAN22_5 = 0.4142135623730950488016887242097; // tan(22.5) = sqrt(2) - 1
1344+
const float TAN22_5 = 0.4142135623730950488016887242097f; // tan(22.5) = sqrt(2) - 1
13451345
const int TG22 = (int) (TAN22_5 * (1 << CANNY_SHIFT) + 0.5);
13461346

13471347
// #define CANNY_PUSH(d) *(d) = (uchar)2, *stack_top++ = (d)
@@ -1723,8 +1723,8 @@ void EllipseDetectorImpl::findEllipses(Point2f &center, VP &edge_i, VP &edge_j,
17231723
}
17241724

17251725
// find peak in N and K accumulator
1726-
int iN = std::distance(accN, std::max_element(accN, accN + ACC_N_SIZE));
1727-
int iK = std::distance(accR, std::max_element(accR, accR + ACC_R_SIZE)) + 90;
1726+
int iN = (int)std::distance(accN, std::max_element(accN, accN + ACC_N_SIZE));
1727+
int iK = (int)std::distance(accR, std::max_element(accR, accR + ACC_R_SIZE)) + 90;
17281728

17291729
// recover real values
17301730
auto fK = float(iK);
@@ -1767,7 +1767,7 @@ void EllipseDetectorImpl::findEllipses(Point2f &center, VP &edge_i, VP &edge_j,
17671767
}
17681768

17691769
// find peak in A accumulator
1770-
int A = std::distance(accA, std::max_element(accA, accA + ACC_A_SIZE));
1770+
int A = (int)std::distance(accA, std::max_element(accA, accA + ACC_A_SIZE));
17711771
auto fA = float(A);
17721772

17731773
// find B value. See Eq [23] in the paper

modules/ximgproc/test/test_find_ellipses.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ TEST(FindEllipsesTest, EllipsesOnly)
2323

2424
// position check
2525
// target centers
26-
Point2f center_1(226.9, 57.2);
27-
Point2f center_2(393.1, 187.0);
28-
Point2f center_3(208.5, 307.5);
26+
Point2f center_1(226.9f, 57.2f);
27+
Point2f center_2(393.1f, 187.0f);
28+
Point2f center_3(208.5f, 307.5f);
2929
// matching
3030
for (auto ell: ells) {
3131
bool has_match = false;

0 commit comments

Comments
 (0)