#include <sstream>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpImageTools.h>
#include <visp3/core/vpIoTools.h>
#include <visp3/gui/vpDisplayD3D.h>
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayGTK.h>
#include <visp3/gui/vpDisplayOpenCV.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/io/vpImageIo.h>
#ifdef ENABLE_VISP_NAMESPACE
#endif
template <
typename Type>
bool test(
const std::string &display,
vpImage<Type> &I,
unsigned int scale,
bool click)
{
bool success = true;
int scale_ = (int)scale;
int radius_ = (int)radius;
unsigned int thickness = 2;
vpRect roi(center, radius_ + scale_, radius_);
std::string itype;
if (display == "GDI") {
#ifdef VISP_HAVE_GDI
#endif
}
else if (display == "GTK") {
#ifdef VISP_HAVE_GTK
#endif
}
else if (display == "X") {
#ifdef VISP_HAVE_X11
d = new vpDisplayX;
#endif
}
else if (display == "OpenCV") {
#ifdef HAVE_OPENCV_HIGHGUI
#endif
}
else if (display == "D3D9") {
#ifdef VISP_HAVE_D3D9
#endif
}
std::cout << "Start test for " << display << " renderer..." << std::endl;
if (sizeof(Type) == 1) {
itype = "uchar";
if (Isampled != Irendered) {
success = false;
std::cout << " -- Test width scale= " << scale << " type= " << itype << ": failed" << std::endl;
std::stringstream ss;
ss << "Isampled-" << itype << "-scale-" << scale;
#ifdef VISP_HAVE_OPENCV
ss << ".png";
#else
ss << ".ppm";
#endif
ss.str("");
ss.clear();
ss << "Irendered-" << itype << "-scale-" << scale;
#ifdef VISP_HAVE_OPENCV
ss << ".png";
#else
ss << ".ppm";
#endif
ss.str("");
ss.clear();
ss << "Idiff-" << itype << "-scale-" << scale;
#ifdef VISP_HAVE_OPENCV
ss << ".png";
#else
ss << ".ppm";
#endif
}
else {
std::cout << " ++ Test width scale= " << scale << " type= " << itype << ": succeed" << std::endl;
}
}
else {
itype = "rgba";
if (IsampledCopy != Irendered) {
success = false;
std::cout << " -- Test width scale= " << scale << " type= " << itype << ": failed" << std::endl;
std::stringstream ss;
ss << "Isampled-" << itype << "-scale-" << scale;
#ifdef VISP_HAVE_OPENCV
ss << ".png";
#else
ss << ".ppm";
#endif
ss.str("");
ss.clear();
ss << "Irendered-" << itype << "-scale-" << scale;
#ifdef VISP_HAVE_OPENCV
ss << ".png";
#else
ss << ".ppm";
#endif
ss.str("");
ss.clear();
ss << "Idiff-" << itype << "-scale-" << scale;
#ifdef VISP_HAVE_OPENCV
ss << ".png";
#else
ss << ".ppm";
#endif
}
else {
std::cout << " ++ Test width scale= " << scale << " type= " << itype << ": succeed" << std::endl;
}
}
false, thickness);
int nbpoints = (int)(radius * sqrt(2.) / 8 / scale);
for (int i = 0; i < nbpoints; i++) {
I, center - h_offset / 2. +
vpImagePoint(-i * radius_ / (nbpoints * 2), i * radius_ / (nbpoints * 2)),
}
if (click)
else
std::stringstream ss;
ss << "overlay-" << display << "-" << itype << "-scale-" << scale;
#ifdef VISP_HAVE_OPENCV
ss << ".png";
#else
ss << ".ppm";
#endif
std::cout << " Overlay saved in: " << ss.str() << std::endl;
if (click)
I = Ibackup;
if (d != nullptr)
delete d;
if (success)
return true;
else
return false;
}
int main(int argc, const char *argv[])
{
bool opt_click = true;
bool opt_display = true;
std::string opt_ipath;
std::string env_ipath;
std::string ipath;
for (int i = 0; i < argc; i++) {
if (std::string(argv[i]) == "-c")
opt_click = false;
else if (std::string(argv[i]) == "-d")
opt_display = false;
else if (std::string(argv[i]) == "-i")
opt_ipath = std::string(argv[i + 1]);
else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") {
std::cout << "\nUsage: " << argv[0] << " [-i <image path>] [-c] [-d] [--help]\n" << std::endl;
std::cout << "\nOptions: " << std::endl;
std::cout << " -i <input image path> : set image input path.\n"
<< " From this path read \"Klimt/Klimt.pgm\" image.\n"
<< " Setting the VISP_INPUT_IMAGE_PATH environment\n"
<< " variable produces the same behaviour than using\n"
<< " this option." << std::endl;
std::cout << " -c : disable mouse click" << std::endl;
std::cout << " -d : disable display" << std::endl;
std::cout << " -h, --help : print this help\n" << std::endl;
return EXIT_SUCCESS;
}
}
if (!env_ipath.empty())
ipath = env_ipath;
if (!opt_ipath.empty())
ipath = opt_ipath;
std::string filename;
std::vector<std::string> display;
if (opt_display) {
#ifdef VISP_HAVE_GDI
display.push_back("GDI");
#endif
#ifdef VISP_HAVE_GTK
display.push_back("GTK");
#endif
#ifdef VISP_HAVE_X11
display.push_back("X");
#endif
#ifdef VISP_HAVE_OPENCV
display.push_back("OpenCV");
#endif
#ifdef VISP_HAVE_D3D9
display.push_back("D3D9");
#endif
if (display.size() == 0) {
std::cout << "No display available. We stop here." << std::endl;
return EXIT_FAILURE;
}
int nbfailure = 0;
for (unsigned int i = 0; i < display.size(); i++) {
for (unsigned int scale = 1; scale < 4; scale++) {
if (!test(display[i], I, scale, opt_click))
nbfailure++;
if (!test(display[i], C, scale, opt_click))
nbfailure++;
}
}
if (nbfailure == 0)
std::cout << "Test succeed" << std::endl;
else
std::cout << "Test failed with " << nbfailure << " failures" << std::endl;
}
return EXIT_SUCCESS;
}
static const vpColor cyan
static const vpColor blue
static const vpColor green
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed....
Display for windows using GDI (available on any windows 32 platform).
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="") VP_OVERRIDE
unsigned int getScreenWidth() VP_OVERRIDE
unsigned int getScreenHeight() VP_OVERRIDE
void setDownScalingFactor(unsigned int scale)
Class that defines generic functionalities for display.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void displayCircle(const vpImage< unsigned char > &I, const vpImageCircle &circle, const vpColor &color, bool fill=false, unsigned int thickness=1)
static void displayROI(const vpImage< unsigned char > &I, const vpRect &roi)
static void display(const vpImage< unsigned char > &I)
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static void close(vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
static void displayArrow(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1)
static void displayPoint(const vpImage< unsigned char > &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
static void displayDotLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
static void displayRectangle(const vpImage< unsigned char > &I, const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
static void write(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition of the vpImage class member functions.
void subsample(unsigned int v_scale, unsigned int h_scale, vpImage< Type > &sampled) const
unsigned int getWidth() const
void insert(const vpImage< Type > &src, const vpImagePoint &topLeft)
unsigned int getHeight() const
Defines a rectangle in the plane.
vpImagePoint getTopLeft() const