Skip to content

Commit

Permalink
[TUTO][FIX] Fix compilation errors when ViSP namespace is activated
Browse files Browse the repository at this point in the history
  • Loading branch information
LAGNEAU Romain committed Sep 11, 2024
1 parent d1280ef commit eb76327
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#include "vpTutoSegmentation.h"

#ifdef ENABLE_VISP_NAMESPACE
using VISP_NAMESPACE_NAME;
using namespace VISP_NAMESPACE_NAME;
#endif

#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) && defined(VISP_HAVE_DISPLAY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#include "vpTutoSegmentation.h"

#ifdef ENABLE_VISP_NAMESPACE
using VISP_NAMESPACE_NAME;
using namespace VISP_NAMESPACE_NAME;
#endif

#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) && defined(VISP_HAVE_DISPLAY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include "vpTutoSegmentation.h"

#ifdef ENABLE_VISP_NAMESPACE
using VISP_NAMESPACE_NAME;
using namespace VISP_NAMESPACE_NAME;
#endif

#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) && defined(VISP_HAVE_DISPLAY)
Expand Down
30 changes: 15 additions & 15 deletions tutorial/particle-filter-curve-fitting/vpTutoCommonData.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#ifndef DOXYGEN_SHOULD_SKIP_THIS
namespace tutorial
{
inline void log(std::ostream &os, const std::string &filename, const std::string &funName, const std::string &arrayName, const vpArray2D<double> &array, const unsigned int &level = 0)
inline void log(std::ostream &os, const std::string &filename, const std::string &funName, const std::string &arrayName, const VISP_NAMESPACE_ADDRESSING vpArray2D<double> &array, const unsigned int &level = 0)
{
os << "[" << filename << "::" << funName << "] ";
for (unsigned int i = 0; i < level; ++i) {
Expand Down Expand Up @@ -267,7 +267,7 @@ typedef struct vpTutoCommonData
m_pfRatiosAmpliMax.resize(m_degree, m_pfRatiosAmpliMax[0]);

// Load the HSV thresholds
if (vpColVector::loadYAML(m_hsvFilename, m_hsv_values)) {
if (VISP_NAMESPACE_ADDRESSING vpColVector::loadYAML(m_hsvFilename, m_hsv_values)) {
std::cout << "Load HSV threshold values from " << m_hsvFilename << std::endl;
std::cout << "HSV low/high values: " << m_hsv_values.t() << std::endl;
}
Expand All @@ -281,7 +281,7 @@ typedef struct vpTutoCommonData
m_grabber.setFileName(m_seqFilename);
m_grabber.open(m_I_orig);
}
catch (const vpException &e) {
catch (const VISP_NAMESPACE_ADDRESSING vpException &e) {
std::cout << e.getStringMessage() << std::endl;
return EXIT_FAILURE;
}
Expand Down Expand Up @@ -310,27 +310,27 @@ typedef struct vpTutoCommonData

#ifdef VISP_HAVE_DISPLAY
template<typename T>
void displayLegend(const vpImage<T> &I)
void displayLegend(const VISP_NAMESPACE_ADDRESSING vpImage<T> &I)
{
vpImagePoint ip(20, 20);
vpImagePoint offset(20, 0);
VISP_NAMESPACE_ADDRESSING vpImagePoint ip(20, 20);
VISP_NAMESPACE_ADDRESSING vpImagePoint offset(20, 0);
if (m_stepbystep) {
vpDisplay::displayText(I, ip, std::string("Left click to switch to next image"), vpColor::red);
VISP_NAMESPACE_ADDRESSING vpDisplay::displayText(I, ip, std::string("Left click to switch to next image"), VISP_NAMESPACE_ADDRESSING vpColor::red);
}
vpDisplay::displayText(I, ip + offset, std::string("Middle click to switch to ") + (m_stepbystep ? std::string("video mode") : std::string("step-by-step mode")), vpColor::red);
vpDisplay::displayText(I, ip + offset + offset, std::string("Right click to quit"), vpColor::red);
VISP_NAMESPACE_ADDRESSING vpDisplay::displayText(I, ip + offset, std::string("Middle click to switch to ") + (m_stepbystep ? std::string("video mode") : std::string("step-by-step mode")), VISP_NAMESPACE_ADDRESSING vpColor::red);
VISP_NAMESPACE_ADDRESSING vpDisplay::displayText(I, ip + offset + offset, std::string("Right click to quit"), VISP_NAMESPACE_ADDRESSING vpColor::red);
}

template<typename T>
bool manageClicks(const vpImage<T> &I, bool &stepbystep)
bool manageClicks(const VISP_NAMESPACE_ADDRESSING vpImage<T> &I, bool &stepbystep)
{
vpImagePoint ip;
vpMouseButton::vpMouseButtonType button;
vpDisplay::getClick(I, ip, button, stepbystep);
if (button == vpMouseButton::vpMouseButtonType::button3) {
VISP_NAMESPACE_ADDRESSING vpImagePoint ip;
VISP_NAMESPACE_ADDRESSING vpMouseButton::vpMouseButtonType button;
VISP_NAMESPACE_ADDRESSING vpDisplay::getClick(I, ip, button, stepbystep);
if (button == VISP_NAMESPACE_ADDRESSING vpMouseButton::vpMouseButtonType::button3) {
return false;
}
if (button == vpMouseButton::vpMouseButtonType::button2) {
if (button == VISP_NAMESPACE_ADDRESSING vpMouseButton::vpMouseButtonType::button2) {
stepbystep = stepbystep ^ true;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
namespace tutorial
{
#ifdef ENABLE_VISP_NAMESPACE
using VISP_NAMESPACE_NAME;
using namespace VISP_NAMESPACE_NAME;
#endif

vpTutoMeanSquareFitting::vpTutoMeanSquareFitting(const unsigned int &degree, const unsigned int &height, const unsigned int &width)
Expand Down
13 changes: 4 additions & 9 deletions tutorial/particle-filter-curve-fitting/vpTutoSegmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@
#ifndef DOXYGEN_SHOULD_SKIP_THIS
namespace tutorial
{
void performSegmentationHSV(vpTutoCommonData &data)
{
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
using namespace VISP_NAMESPACE_NAME;
#endif

void performSegmentationHSV(vpTutoCommonData &data)
{
const unsigned int height = data.m_I_orig.getHeight(), width = data.m_I_orig.getWidth();
vpImage<unsigned char> H(height, width);
vpImage<unsigned char> S(height, width);
Expand All @@ -64,9 +65,6 @@ void performSegmentationHSV(vpTutoCommonData &data)

std::vector< VISP_NAMESPACE_ADDRESSING vpImagePoint > extractSkeleton(vpTutoCommonData &data)
{
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
const int height = data.m_mask.getHeight();
const int width = data.m_mask.getWidth();
data.m_Iskeleton.resize(height, width, 0);
Expand Down Expand Up @@ -122,9 +120,6 @@ std::vector< VISP_NAMESPACE_ADDRESSING vpImagePoint > extractSkeleton(vpTutoComm

std::vector< vpImagePoint > addSaltAndPepperNoise(const std::vector< vpImagePoint > &noisefreePts, vpTutoCommonData &data)
{
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
const unsigned int nbNoiseFreePts = noisefreePts.size();
const unsigned int nbPtsToAdd = data.m_ratioSaltPepperNoise * nbNoiseFreePts;
const double width = data.m_Iskeleton.getWidth();
Expand Down

0 comments on commit eb76327

Please sign in to comment.