Skip to content

Commit

Permalink
Fix warnings detected during build on ci with Visual 2019
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed Oct 23, 2023
1 parent d58c72a commit 4842e54
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 205 deletions.
12 changes: 5 additions & 7 deletions modules/core/src/image/vpGaussianFilter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/****************************************************************************
*
/*
* ViSP, open source Visual Servoing Platform software.
* Copyright (C) 2005 - 2023 by Inria. All rights reserved.
*
Expand Down Expand Up @@ -30,8 +29,7 @@
*
* Description:
* Gaussian filter class
*
*****************************************************************************/
*/

#include <Simd/SimdLib.h>
#include <visp3/core/vpGaussianFilter.h>
Expand Down Expand Up @@ -88,7 +86,8 @@ class vpGaussianFilter::Impl
if (!m_deinterleave) {
SimdGaussianBlurRun(m_funcPtrRGBa, reinterpret_cast<unsigned char *>(I.bitmap), I.getWidth() * 4,
reinterpret_cast<unsigned char *>(I_blur.bitmap), I_blur.getWidth() * 4);
} else {
}
else {
vpImageConvert::split(I, &m_red, &m_green, &m_blue);
SimdGaussianBlurRun(m_funcPtrGray, m_red.bitmap, m_red.getWidth(), m_redBlurred.bitmap, m_redBlurred.getWidth());
SimdGaussianBlurRun(m_funcPtrGray, m_green.bitmap, m_green.getWidth(), m_greenBlurred.bitmap,
Expand Down Expand Up @@ -125,8 +124,7 @@ class vpGaussianFilter::Impl
*/
vpGaussianFilter::vpGaussianFilter(unsigned int width, unsigned int height, float sigma, bool deinterleave)
: m_impl(new Impl(width, height, sigma, deinterleave))
{
}
{ }

vpGaussianFilter::~vpGaussianFilter() { delete m_impl; }

Expand Down
85 changes: 45 additions & 40 deletions modules/core/src/image/vpImageCircle.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/****************************************************************************
*
/*
* ViSP, open source Visual Servoing Platform software.
* Copyright (C) 2005 - 2023 by Inria. All rights reserved.
*
Expand Down Expand Up @@ -30,8 +29,7 @@
*
* Description:
* Image circle, i.e. circle in the image space.
*
*****************************************************************************/
*/

#include <visp3/core/vpImageCircle.h>

Expand All @@ -53,30 +51,28 @@ vpImageCircle::vpImageCircle(const vpImagePoint &center, const float &radius)
vpImageCircle::vpImageCircle(const cv::Vec3f &vec)
: m_center(vec[1], vec[0])
, m_radius(vec[2])
{

}
{ }
#endif

vpImageCircle::~vpImageCircle()
{

}
{ }

/*!
* \brief Express \b theta between - Pi and Pi .
* \brief Express \b theta between \f$-\pi\f$ and \f$\pi\f$.
*
* \param[in] theta The input angle we want to ensure it is in the interval [-Pi ; Pi]
* \return float The input angle in the interval [-Pi ; Pi]
* \param[in] theta The input angle we want to ensure it is in the interval \f$[-\pi ; \pi]\f$.
* \return The input angle in the interval \f$[-\pi ; \pi]\f$.
*/
float getAngleBetweenMinPiAndPi(const float &theta)
{
float theta1 = theta;
if (theta1 > M_PI) {
theta1 -= 2.0 * M_PI;
float pi = static_cast<float>(M_PI);

if (theta1 > pi) {
theta1 -= 2.0f * pi;
}
else if (theta1 < -M_PI) {
theta1 += 2.0 * M_PI;
else if (theta1 < -pi) {
theta1 += 2.0f * pi;
}
return theta1;
}
Expand Down Expand Up @@ -122,7 +118,8 @@ void computeIntersectionsRightBorderOnly(const float &u_c, const float &umax_roi
float theta2 = -1.f * theta1;
float theta_min = std::min(theta1, theta2);
float theta_max = std::max(theta1, theta2);
delta_theta = 2.f * M_PI - (theta_max - theta_min);
float pi = static_cast<float>(M_PI);
delta_theta = 2.f * pi - (theta_max - theta_min);
}

/*!
Expand All @@ -140,24 +137,25 @@ void computeIntersectionsTopBorderOnly(const float &v_c, const float &vmin_roi,
// v = vc - r sin(theta) because the v-axis goes down
// theta = asin((vc - v)/r)
float theta1 = std::asin((v_c - vmin_roi) / radius);
float pi = static_cast<float>(M_PI);
theta1 = getAngleBetweenMinPiAndPi(theta1);

float theta2 = 0.f;
if (theta1 >= 0.f) {
theta2 = M_PI - theta1;
theta2 = pi - theta1;
}
else {
theta2 = -theta1 - M_PI;
theta2 = -theta1 - pi;
}
float theta_min = std::min(theta1, theta2);
float theta_max = std::max(theta1, theta2);
if (std::abs(theta_max - theta_min) * radius < 1.f) {
// Between the maximum and minimum theta there is less than 1 pixel of difference
// It meens that the full circle is visible
delta_theta = 2.f * M_PI;
delta_theta = 2.f * pi;
}
else if (theta1 > 0.f) {
delta_theta = 2.f * M_PI - (theta_max - theta_min);
delta_theta = 2.f * pi - (theta_max - theta_min);
}
else {
delta_theta = theta_max - theta_min;
Expand All @@ -179,27 +177,28 @@ void computeIntersectionsBottomBorderOnly(const float &v_c, const float &vmax_ro
// v = vc - r sin(theta) because the v-axis goes down
// theta = asin((vc - v)/r)
float theta1 = std::asin((v_c - vmax_roi) / radius);
float pi = static_cast<float>(M_PI);
theta1 = getAngleBetweenMinPiAndPi(theta1);

float theta2 = 0.f;
if (theta1 >= 0.f) {
theta2 = M_PI - theta1;
theta2 = pi - theta1;
}
else {
theta2 = -theta1 - M_PI;
theta2 = -theta1 - pi;
}
float theta_min = std::min(theta1, theta2);
float theta_max = std::max(theta1, theta2);
if (std::abs(theta_max - theta_min) * radius < 1.f) {
// Between the maximum and minimum theta there is less than 1 pixel of difference
// It meens that the full circle is visible
delta_theta = 2.f * M_PI;
// It means that the full circle is visible
delta_theta = 2.f * pi;
}
else if (theta1 > 0.f) {
delta_theta = theta_max - theta_min;
}
else {
delta_theta = 2.f * M_PI - (theta_max - theta_min);
delta_theta = 2.f * pi - (theta_max - theta_min);
}
}

Expand All @@ -226,13 +225,14 @@ void computePerpendicularAxesIntersections(const float &u_c, const float &v_c, c
// v = vc - r sin(theta) because the v-axis goes down
// theta = asin((vc - v)/r)
float theta_u_cross = std::asin((v_c - crossing_u)/radius);
float pi = static_cast<float>(M_PI);
theta_u_cross = getAngleBetweenMinPiAndPi(theta_u_cross);
float theta_u_cross_2 = 0.f;
if (theta_u_cross > 0) {
theta_u_cross_2 = M_PI - theta_u_cross;
theta_u_cross_2 = pi - theta_u_cross;
}
else {
theta_u_cross_2 = -M_PI - theta_u_cross;
theta_u_cross_2 = -pi - theta_u_cross;
}
// Computing the corresponding u-coordinates at which the u-axis is crossed
float u_ucross = u_c + radius * std::cos(theta_u_cross);
Expand Down Expand Up @@ -352,19 +352,20 @@ void computeIntersectionsTopRight(const float &u_c, const float &v_c, const floa
float u_umax = crossing_theta_u_max.second;
float v_vmin = crossing_theta_v_min.second;
float v_vmax = crossing_theta_v_max.second;
float pi = static_cast<float>(M_PI);
if (u_umin <= umax_roi && v_vmin < vmin_roi && u_umax >= umax_roi && v_vmax >= vmin_roi) {
// The circle crosses only once each axis and the center is below the top border
//Case crossing once
delta_theta = theta_v_max - theta_u_min;
if (delta_theta < 0) {
// The arc cannot be negative
delta_theta += 2.f * M_PI;
delta_theta += 2.f * pi;
}
}
else if (u_umin <= umax_roi && v_vmin >= vmin_roi && u_umax <= umax_roi && v_vmax >= vmin_roi) {
// The circle crosses twice each axis
//Case crossing twice
delta_theta = 2 * M_PI - ((theta_u_min - theta_u_max)+(theta_v_min - theta_v_max));
delta_theta = 2.f * pi - ((theta_u_min - theta_u_max)+(theta_v_min - theta_v_max));
}
else if (u_umin >= umax_roi && v_vmin >= vmin_roi && u_umax >= umax_roi && v_vmax >= vmin_roi) {
// The circle crosses the u-axis outside the roi
Expand Down Expand Up @@ -458,19 +459,20 @@ void computeIntersectionsBottomRight(const float &u_c, const float &v_c, const f
float u_umax = crossing_theta_u_max.second;
float v_vmin = crossing_theta_v_min.second;
float v_vmax = crossing_theta_v_max.second;
float pi = static_cast<float>(M_PI);
if (u_umin <= umax_roi && u_umax > umax_roi && v_vmin <= vmax_roi && v_vmax > vmax_roi) {
// The circle crosses only once each axis
//Case crossing once
delta_theta = theta_u_min - theta_v_min;
if (delta_theta < 0) {
// An arc length cannot be negative it means that theta_u_max was comprise in the bottom left quadrant of the circle
delta_theta += 2.f * M_PI;
delta_theta += 2.f * pi;
}
}
else if (u_umin <= umax_roi && u_umax <= umax_roi && v_vmin <= vmax_roi && v_vmax <= vmax_roi) {
// The circle crosses twice each axis
//Case crossing twice
delta_theta = 2.f * M_PI - ((theta_v_min - theta_v_max) + (theta_u_max - theta_u_min));
delta_theta = 2.f * pi - ((theta_v_min - theta_v_max) + (theta_u_max - theta_u_min));
}
else if (u_umin > umax_roi && u_umax > umax_roi && v_vmin <= vmax_roi && v_vmax <= vmax_roi) {
// The circle crosses the u-axis outside the roi
Expand Down Expand Up @@ -586,9 +588,10 @@ void computeIntersectionsTopRightBottom(const float &u_c, const float &v_c, cons
float theta_u_max_bottom = crossing_theta_u_max.first;
float u_umin_bottom = crossing_theta_u_min.second;
float u_umax_bottom = crossing_theta_u_max.second;
float pi = static_cast<float>(M_PI);
if (u_umax_top <= umax_roi && u_umax_bottom <= umax_roi && v_vmin >= vmin_roi && v_vmax <= vmax_roi) {
// case intersection top + right + bottom twice
delta_theta = 2.f * M_PI - ((theta_u_min_top - theta_u_max_top) + (theta_v_min - theta_v_max) + (theta_u_max_bottom - theta_u_min_bottom));
delta_theta = 2.f * pi - ((theta_u_min_top - theta_u_max_top) + (theta_v_min - theta_v_max) + (theta_u_max_bottom - theta_u_min_bottom));
}
else if (u_umin_top <= umax_roi && u_umax_top > umax_roi && v_vmin <= vmin_roi && u_umin_bottom <= umax_roi && u_umax_bottom > umax_roi && v_vmax >= vmax_roi) {
// case intersection top and bottom
Expand Down Expand Up @@ -628,11 +631,12 @@ void computeIntersectionsTopBottomOnly(const float &u_c, const float &v_c, const
float theta_u_cross_top = std::asin((v_c - vmin_roi)/radius);
theta_u_cross_top = getAngleBetweenMinPiAndPi(theta_u_cross_top);
float theta_u_cross_top_2 = 0.f;
float pi = static_cast<float>(M_PI);
if (theta_u_cross_top > 0) {
theta_u_cross_top_2 = M_PI - theta_u_cross_top;
theta_u_cross_top_2 = pi - theta_u_cross_top;
}
else {
theta_u_cross_top_2 = -M_PI - theta_u_cross_top;
theta_u_cross_top_2 = -pi - theta_u_cross_top;
}

// Computing the corresponding u-coordinates at which the u-axis is crossed
Expand All @@ -656,10 +660,10 @@ void computeIntersectionsTopBottomOnly(const float &u_c, const float &v_c, const
theta_u_cross_bottom = getAngleBetweenMinPiAndPi(theta_u_cross_bottom);
float theta_u_cross_bottom_2 = 0.f;
if (theta_u_cross_bottom > 0) {
theta_u_cross_bottom_2 = M_PI - theta_u_cross_bottom;
theta_u_cross_bottom_2 = pi - theta_u_cross_bottom;
}
else {
theta_u_cross_bottom_2 = -M_PI - theta_u_cross_bottom;
theta_u_cross_bottom_2 = -pi - theta_u_cross_bottom;
}

// Computing the corresponding u-coordinates at which the u-axis is crossed
Expand All @@ -679,7 +683,7 @@ void computeIntersectionsTopBottomOnly(const float &u_c, const float &v_c, const

// Computing the the length of the angular interval of the circle when it intersects
// only with the top and bottom borders of the Region of Interest (RoI)
delta_theta = 2.f * M_PI - ((theta_u_cross_top_min - theta_u_cross_top_max) + (theta_u_cross_bottom_max - theta_u_cross_bottom_min));
delta_theta = 2.f * pi - ((theta_u_cross_top_min - theta_u_cross_top_max) + (theta_u_cross_bottom_max - theta_u_cross_bottom_min));
}

/*!
Expand Down Expand Up @@ -938,11 +942,12 @@ float vpImageCircle::computeAngularCoverageInRoI(const vpRect &roi) const
bool touchBottomBorder = (v_c + radius) >= vmax_roi;
bool isHorizontallyOK = (!touchLeftBorder && !touchRightBorder);
bool isVerticallyOK = (!touchTopBorder && !touchBottomBorder);
float pi = static_cast<float>(M_PI);
if (isHorizontallyOK && isVerticallyOK && roi.isInside(m_center)) {
// Easy case
// The circle has its center in the image and its radius is not too great
// to make it fully contained in the RoI
delta_theta = 2.f * M_PI;
delta_theta = 2.f * pi;
}
else if (touchBottomBorder && !touchLeftBorder && !touchRightBorder && !touchTopBorder) {
// Touches/intersects only the bottom border of the RoI
Expand Down
8 changes: 3 additions & 5 deletions modules/core/src/image/vpImageFilter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/****************************************************************************
*
/*
* ViSP, open source Visual Servoing Platform software.
* Copyright (C) 2005 - 2023 by Inria. All rights reserved.
*
Expand Down Expand Up @@ -30,8 +29,7 @@
*
* Description:
* Various image tools, convolution, ...
*
*****************************************************************************/
*/

#include <visp3/core/vpCannyEdgeDetection.h>
#include <visp3/core/vpException.h>
Expand Down Expand Up @@ -373,7 +371,7 @@ void vpImageFilter::canny(const vpImage<unsigned char> &Isrc, vpImage<unsigned c
else if (lowerCannyThresh < 0) {
lowerCannyThresh = upperCannyThresh / 3.;
}
vpCannyEdgeDetection edgeDetector(gaussianFilterSize, 0.1, lowerCannyThresh, upperCannyThresh);
vpCannyEdgeDetection edgeDetector(gaussianFilterSize, 0.1f, lowerCannyThresh, upperCannyThresh);
Ires = edgeDetector.detect(Isrc);
#endif
}
Expand Down
Loading

0 comments on commit 4842e54

Please sign in to comment.