Skip to content

build: fix/eliminate MSVC warnings #3389

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

Merged
merged 1 commit into from
Dec 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions modules/ximgproc/src/find_ellipses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,11 @@ float EllipseDetectorImpl::getMedianSlope(std::vector<Point2f> &med, Point2f &ce
// centers : centroid of the points in med
// slopes : vector of the slopes

unsigned pointCount = med.size();
size_t pointCount = med.size();
// CV_Assert(pointCount >= 2);

unsigned halfSize = pointCount >> 1;
unsigned quarterSize = halfSize >> 1;
size_t halfSize = pointCount >> 1;
size_t quarterSize = halfSize >> 1;

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

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

slopes.push_back(num / den);
}
Expand Down Expand Up @@ -1341,7 +1341,7 @@ void EllipseDetectorImpl::preProcessing(Mat1b &image, Mat1b &dp, Mat1b &dn) {
}

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

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

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

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

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

// find B value. See Eq [23] in the paper
Expand Down
6 changes: 3 additions & 3 deletions modules/ximgproc/test/test_find_ellipses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ TEST(FindEllipsesTest, EllipsesOnly)

// position check
// target centers
Point2f center_1(226.9, 57.2);
Point2f center_2(393.1, 187.0);
Point2f center_3(208.5, 307.5);
Point2f center_1(226.9f, 57.2f);
Point2f center_2(393.1f, 187.0f);
Point2f center_3(208.5f, 307.5f);
// matching
for (auto ell: ells) {
bool has_match = false;
Expand Down