Skip to content

Commit

Permalink
[EXAMPLE] Addedf namespace macro in the example folder
Browse files Browse the repository at this point in the history
  • Loading branch information
rlagneau committed May 28, 2024
1 parent 46a8096 commit 9342302
Show file tree
Hide file tree
Showing 182 changed files with 1,450 additions and 535 deletions.
6 changes: 5 additions & 1 deletion example/calibration/calibrate-camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ void usage(const char *argv[], int error)

int main(int argc, const char *argv[])
{
#if defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
#endif

try {
if (argc == 1) {
usage(argv, 0);
Expand Down Expand Up @@ -679,5 +683,5 @@ int main()
std::cout << "pugixml built-in 3rdparty is requested to run the calibration." << std::endl;
#endif
return EXIT_SUCCESS;
}
}
#endif
6 changes: 5 additions & 1 deletion example/calibration/calibrate-hand-eye.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <stdio.h>
#include <vector>

#include <visp3/core/vpConfig.h>
#include <visp3/core/vpDebug.h>
#include <visp3/core/vpExponentialMap.h>
#include <visp3/core/vpIoTools.h>
Expand All @@ -54,6 +55,9 @@
int main()
{
#if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
#if defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
#endif
try {
// We want to calibrate the hand-eye extrinsic camera parameters from 6
// couple of poses: cMo and wMe
Expand Down Expand Up @@ -167,4 +171,4 @@ int main()
std::cout << "Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
return EXIT_SUCCESS;
#endif
}
}
60 changes: 30 additions & 30 deletions example/calibration/calibration-helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ class Settings
bool read(const std::string &filename) // Read the parameters
{
// reading configuration file
if (!vpIoTools::loadConfigFile(filename))
if (!VISP_NAMESPACE_ADDRESSING vpIoTools::loadConfigFile(filename))
return false;
vpIoTools::readConfigVar("BoardSize_Width:", boardSize.width);
vpIoTools::readConfigVar("BoardSize_Height:", boardSize.height);
vpIoTools::readConfigVar("Square_Size:", squareSize);
vpIoTools::readConfigVar("Calibrate_Pattern:", patternToUse);
vpIoTools::readConfigVar("Input:", input);
vpIoTools::readConfigVar("Tempo:", tempo);
VISP_NAMESPACE_ADDRESSING vpIoTools::readConfigVar("BoardSize_Width:", boardSize.width);
VISP_NAMESPACE_ADDRESSING vpIoTools::readConfigVar("BoardSize_Height:", boardSize.height);
VISP_NAMESPACE_ADDRESSING vpIoTools::readConfigVar("Square_Size:", squareSize);
VISP_NAMESPACE_ADDRESSING vpIoTools::readConfigVar("Calibrate_Pattern:", patternToUse);
VISP_NAMESPACE_ADDRESSING vpIoTools::readConfigVar("Input:", input);
VISP_NAMESPACE_ADDRESSING vpIoTools::readConfigVar("Tempo:", tempo);

Check warning on line 77 in example/calibration/calibration-helper.hpp

View check run for this annotation

Codecov / codecov/patch

example/calibration/calibration-helper.hpp#L72-L77

Added lines #L72 - L77 were not covered by tests

std::cout << "grid width : " << boardSize.width << std::endl;
std::cout << "grid height: " << boardSize.height << std::endl;
Expand Down Expand Up @@ -128,55 +128,55 @@ class Settings
std::string patternToUse;
};

struct CalibInfo {
CalibInfo(const vpImage<unsigned char> &img, const std::vector<vpPoint> &points,
const std::vector<vpImagePoint> &imPts, const std::string &frame_name)
struct CalibInfo
{
CalibInfo(const VISP_NAMESPACE_ADDRESSING vpImage<unsigned char> &img, const std::vector<VISP_NAMESPACE_ADDRESSING vpPoint> &points,

Check warning on line 133 in example/calibration/calibration-helper.hpp

View check run for this annotation

Codecov / codecov/patch

example/calibration/calibration-helper.hpp#L133

Added line #L133 was not covered by tests
const std::vector<VISP_NAMESPACE_ADDRESSING vpImagePoint> &imPts, const std::string &frame_name)
: m_img(img), m_points(points), m_imPts(imPts), m_frame_name(frame_name)
{
}
{ }

Check warning on line 136 in example/calibration/calibration-helper.hpp

View check run for this annotation

Codecov / codecov/patch

example/calibration/calibration-helper.hpp#L136

Added line #L136 was not covered by tests

vpImage<unsigned char> m_img;
std::vector<vpPoint> m_points;
std::vector<vpImagePoint> m_imPts;
VISP_NAMESPACE_ADDRESSING vpImage<unsigned char> m_img;
std::vector<VISP_NAMESPACE_ADDRESSING vpPoint> m_points;
std::vector<VISP_NAMESPACE_ADDRESSING vpImagePoint> m_imPts;
std::string m_frame_name;
};

void drawCalibrationOccupancy(vpImage<unsigned char> &I, const std::vector<CalibInfo> &calib_info,
void drawCalibrationOccupancy(VISP_NAMESPACE_ADDRESSING vpImage<unsigned char> &I, const std::vector<CalibInfo> &calib_info,

Check warning on line 144 in example/calibration/calibration-helper.hpp

View check run for this annotation

Codecov / codecov/patch

example/calibration/calibration-helper.hpp#L144

Added line #L144 was not covered by tests
unsigned int patternW)
{
I = 0;
unsigned char pixel_value = static_cast<unsigned char>(255.0 / calib_info.size());
for (size_t idx = 0; idx < calib_info.size(); idx++) {
const CalibInfo &calib = calib_info[idx];

std::vector<vpImagePoint> corners;
std::vector<VISP_NAMESPACE_ADDRESSING vpImagePoint> corners;
corners.push_back(calib.m_imPts.front());
corners.push_back(*(calib.m_imPts.begin() + patternW - 1));
corners.push_back(calib.m_imPts.back());
corners.push_back(*(calib.m_imPts.end() - patternW));
vpPolygon poly(corners);
VISP_NAMESPACE_ADDRESSING vpPolygon poly(corners);

Check warning on line 157 in example/calibration/calibration-helper.hpp

View check run for this annotation

Codecov / codecov/patch

example/calibration/calibration-helper.hpp#L157

Added line #L157 was not covered by tests

for (unsigned int i = 0; i < I.getHeight(); i++) {
for (unsigned int j = 0; j < I.getWidth(); j++) {
if (poly.isInside(vpImagePoint(i, j))) {
if (poly.isInside(VISP_NAMESPACE_ADDRESSING vpImagePoint(i, j))) {
I[i][j] += pixel_value;
}
}
}
}
}

std::vector<vpImagePoint> undistort(const vpCameraParameters &cam_dist, const std::vector<vpImagePoint> &imPts)
std::vector<VISP_NAMESPACE_ADDRESSING vpImagePoint> undistort(const VISP_NAMESPACE_ADDRESSING vpCameraParameters &cam_dist, const std::vector<VISP_NAMESPACE_ADDRESSING vpImagePoint> &imPts)

Check warning on line 169 in example/calibration/calibration-helper.hpp

View check run for this annotation

Codecov / codecov/patch

example/calibration/calibration-helper.hpp#L169

Added line #L169 was not covered by tests
{
std::vector<vpImagePoint> imPts_undist;
std::vector<VISP_NAMESPACE_ADDRESSING vpImagePoint> imPts_undist;

vpCameraParameters cam(cam_dist.get_px(), cam_dist.get_py(), cam_dist.get_u0(), cam_dist.get_v0());
VISP_NAMESPACE_ADDRESSING vpCameraParameters cam(cam_dist.get_px(), cam_dist.get_py(), cam_dist.get_u0(), cam_dist.get_v0());

Check warning on line 173 in example/calibration/calibration-helper.hpp

View check run for this annotation

Codecov / codecov/patch

example/calibration/calibration-helper.hpp#L173

Added line #L173 was not covered by tests
for (size_t i = 0; i < imPts.size(); i++) {
double x = 0, y = 0;
vpPixelMeterConversion::convertPoint(cam_dist, imPts[i], x, y);
VISP_NAMESPACE_ADDRESSING vpPixelMeterConversion::convertPoint(cam_dist, imPts[i], x, y);

Check warning on line 176 in example/calibration/calibration-helper.hpp

View check run for this annotation

Codecov / codecov/patch

example/calibration/calibration-helper.hpp#L176

Added line #L176 was not covered by tests

vpImagePoint imPt;
vpMeterPixelConversion::convertPoint(cam, x, y, imPt);
VISP_NAMESPACE_ADDRESSING vpImagePoint imPt;
VISP_NAMESPACE_ADDRESSING vpMeterPixelConversion::convertPoint(cam, x, y, imPt);

Check warning on line 179 in example/calibration/calibration-helper.hpp

View check run for this annotation

Codecov / codecov/patch

example/calibration/calibration-helper.hpp#L179

Added line #L179 was not covered by tests
imPts_undist.push_back(imPt);
}

Expand All @@ -190,11 +190,11 @@ bool extractCalibrationPoints(const Settings &s, const cv::Mat &cvI, std::vector
{
case Settings::CHESSBOARD:
found =
findChessboardCorners(cvI, s.boardSize, pointBuf,
findChessboardCorners(cvI, s.boardSize, pointBuf,

Check warning on line 193 in example/calibration/calibration-helper.hpp

View check run for this annotation

Codecov / codecov/patch

example/calibration/calibration-helper.hpp#L193

Added line #L193 was not covered by tests
#if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
cv::CALIB_CB_ADAPTIVE_THRESH | cv::CALIB_CB_FAST_CHECK | cv::CALIB_CB_NORMALIZE_IMAGE);
cv::CALIB_CB_ADAPTIVE_THRESH | cv::CALIB_CB_FAST_CHECK | cv::CALIB_CB_NORMALIZE_IMAGE);
#else
CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FAST_CHECK | CV_CALIB_CB_NORMALIZE_IMAGE);
CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FAST_CHECK | CV_CALIB_CB_NORMALIZE_IMAGE);
#endif
break;
case Settings::CIRCLES_GRID:
Expand All @@ -207,15 +207,15 @@ bool extractCalibrationPoints(const Settings &s, const cv::Mat &cvI, std::vector

if (found) // If done with success,
{
std::vector<vpImagePoint> data;
std::vector<VISP_NAMESPACE_ADDRESSING vpImagePoint> data;

if (s.calibrationPattern == Settings::CHESSBOARD) {
// improve the found corners' coordinate accuracy for chessboard
cornerSubPix(cvI, pointBuf, cv::Size(11, 11), cv::Size(-1, -1),
#if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
cv::TermCriteria(cv::TermCriteria::EPS + cv::TermCriteria::COUNT, 30, 0.1));
#else
cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
#endif
}
}
Expand Down
4 changes: 4 additions & 0 deletions example/coin-simulator/simulateCircle2DCamVelocity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
#define GETOPTARGS "cdi:h"
#define SAVE 0

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

/*!
Print the program options.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
#define GETOPTARGS "di:h"
#define SAVE 0

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

/*!
Print the program options.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
#define GETOPTARGS "di:h"
#define SAVE 0

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

/*!
Print the program options.
Expand Down
4 changes: 4 additions & 0 deletions example/device/display/displayD3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
// List of allowed command line options
#define GETOPTARGS "cdi:o:h"

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

/*!
Print the program options.
Expand Down
4 changes: 4 additions & 0 deletions example/device/display/displayGDI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
// List of allowed command line options
#define GETOPTARGS "cdi:o:h"

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

/*!
Print the program options.
Expand Down
4 changes: 4 additions & 0 deletions example/device/display/displayGTK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
// List of allowed command line options
#define GETOPTARGS "cdi:o:h"

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

/*!
Print the program options.
Expand Down
6 changes: 5 additions & 1 deletion example/device/display/displayOpenCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
// List of allowed command line options
#define GETOPTARGS "cdi:o:p:h"

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

/*!
Print the program options.
Expand Down Expand Up @@ -459,5 +463,5 @@ int main()
std::cout << "Tip:" << std::endl;
std::cout << "- Install OpenCV, configure again ViSP using cmake and build again this example" << std::endl;
return EXIT_SUCCESS;
}
}
#endif
6 changes: 5 additions & 1 deletion example/device/display/displaySequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
// List of allowed command line options
#define GETOPTARGS "di:p:hf:l:s:w"

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

/*!
Print the program options.
Expand Down Expand Up @@ -402,5 +406,5 @@ int main()
std::cout << "Tip if you are on a windows-like system:" << std::endl;
std::cout << "- Install GDI, configure again ViSP using cmake and build again this example" << std::endl;
return EXIT_SUCCESS;
}
}
#endif
6 changes: 5 additions & 1 deletion example/device/display/displayX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
// List of allowed command line options
#define GETOPTARGS "cdi:o:p:h"

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

/*!
Print the program options.
Expand Down Expand Up @@ -447,5 +451,5 @@ int main()
std::cout << "Tip if you are on a unix-like system:" << std::endl;
std::cout << "- Install X11, configure again ViSP using cmake and build again this example" << std::endl;
return EXIT_SUCCESS;
}
}
#endif
6 changes: 5 additions & 1 deletion example/device/display/displayXMulti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
// List of allowed command line options
#define GETOPTARGS "cdi:o:h"

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

/*!
Print the program options.
Expand Down Expand Up @@ -411,5 +415,5 @@ int main()
std::cout << "Tip if you are on a unix-like system:" << std::endl;
std::cout << "- Install X11, configure again ViSP using cmake and build again this example" << std::endl;
return EXIT_SUCCESS;
}
}
#endif
4 changes: 4 additions & 0 deletions example/device/framegrabber/getRealSense2Info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@
*/

#include <iostream>
#include <visp3/core/vpConfig.h>
#include <visp3/sensor/vpRealSense2.h>

#if defined(VISP_HAVE_REALSENSE2) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)

int main()
{
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
try {
vpRealSense2 rs;
rs.open();
Expand Down
5 changes: 5 additions & 0 deletions example/device/framegrabber/grab1394CMU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
// List of allowed command line options
#define GETOPTARGS "dhn:o:"

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif


void usage(const char *name, const char *badparam, unsigned &nframes, std::string &opath);
bool getOptions(int argc, const char **argv, bool &display, unsigned int &nframes, bool &save, std::string &opath);

Expand Down
6 changes: 5 additions & 1 deletion example/device/framegrabber/grab1394Two.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
#define GETOPTARGS "b:c:df:g:hH:L:mn:io:p:rsT:v:W:"
#define DUAL_ACQ

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

/*!
Print the program options.
Expand Down Expand Up @@ -685,6 +689,6 @@ int main()
std::cout << "Tip if you are on a unix-like system:" << std::endl;
std::cout << "- Install libdc1394-2, configure again ViSP using cmake and build again this example" << std::endl;
return EXIT_SUCCESS;
}
}

#endif
11 changes: 8 additions & 3 deletions example/device/framegrabber/grabDirectShow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
// List of allowed command line options
#define GETOPTARGS "dhn:o:"

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

/*!
Print the program options.
Expand Down Expand Up @@ -94,7 +98,7 @@ OPTIONS: Default\n\
-h \n\
Print the help.\n\
\n",
nframes, opath.c_str());
nframes, opath.c_str());
if (badparam) {
fprintf(stderr, "ERROR: \n");
fprintf(stderr, "\nBad parameter [%s]\n", badparam);
Expand Down Expand Up @@ -254,7 +258,8 @@ int main(int argc, const char **argv)
// Release the framegrabber
delete grabber;
return EXIT_SUCCESS;
} catch (const vpException &e) {
}
catch (const vpException &e) {
std::cout << "Catch an exception: " << e << std::endl;
return EXIT_FAILURE;
}
Expand All @@ -264,7 +269,7 @@ int main(int argc, const char **argv)
int main()
{
std::cout << "You do not have GDI (Graphical Device Interface), or GTK functionalities to display images..."
<< std::endl;
<< std::endl;
std::cout << "Tip if you are on a windows-like system:" << std::endl;
std::cout << "- Install GDI, configure again ViSP using cmake and build again this example" << std::endl;
return EXIT_SUCCESS;
Expand Down
Loading

0 comments on commit 9342302

Please sign in to comment.