38#include <visp3/core/vpImageTools.h>
39#include <visp3/core/vpIoTools.h>
40#include <visp3/gui/vpDisplayD3D.h>
41#include <visp3/gui/vpDisplayGDI.h>
42#include <visp3/gui/vpDisplayGTK.h>
43#include <visp3/gui/vpDisplayOpenCV.h>
44#include <visp3/gui/vpDisplayX.h>
45#include <visp3/io/vpImageIo.h>
47template <
typename Type>
bool test(
const std::string &display,
vpImage<Type> &I,
unsigned int scale,
bool click)
51 int scale_ = (int)scale;
52 int radius_ = (int)radius;
53 unsigned int thickness = 2;
58 vpRect roi(center, radius_ + scale_, radius_);
65 if (display ==
"GDI") {
69 }
else if (display ==
"GTK") {
73 }
else if (display ==
"X") {
77 }
else if (display ==
"OpenCV") {
78#ifdef HAVE_OPENCV_HIGHGUI
81 }
else if (display ==
"D3D9") {
86 std::cout <<
"Start test for " << display <<
" renderer..." << std::endl;
95 I.
insert(crop, roi.getTopLeft());
100 if (
sizeof(Type) == 1) {
106 Icolor.
subsample(scale, scale, Isampled);
111 if (Isampled != Irendered) {
113 std::cout <<
" -- Test width scale= " << scale <<
" type= " << itype <<
": failed" << std::endl;
115 std::stringstream ss;
116 ss <<
"Isampled-" << itype <<
"-scale-" << scale;
117#ifdef VISP_HAVE_OPENCV
127 ss <<
"Irendered-" << itype <<
"-scale-" << scale;
128#ifdef VISP_HAVE_OPENCV
140 ss <<
"Idiff-" << itype <<
"-scale-" << scale;
141#ifdef VISP_HAVE_OPENCV
149 std::cout <<
" ++ Test width scale= " << scale <<
" type= " << itype <<
": succeed" << std::endl;
155 Iinsert.
subsample(scale, scale, Isampled);
163 if (IsampledCopy != Irendered) {
165 std::cout <<
" -- Test width scale= " << scale <<
" type= " << itype <<
": failed" << std::endl;
167 std::stringstream ss;
168 ss <<
"Isampled-" << itype <<
"-scale-" << scale;
169#ifdef VISP_HAVE_OPENCV
179 ss <<
"Irendered-" << itype <<
"-scale-" << scale;
180#ifdef VISP_HAVE_OPENCV
191 ss <<
"Idiff-" << itype <<
"-scale-" << scale;
192#ifdef VISP_HAVE_OPENCV
201 std::cout <<
" ++ Test width scale= " << scale <<
" type= " << itype <<
": succeed" << std::endl;
215 int nbpoints = (int)(radius * sqrt(2.) / 8 / scale);
216 for (
int i = 0; i < nbpoints; i++) {
218 I, center - h_offset / 2. +
vpImagePoint(-i * radius_ / (nbpoints * 2), i * radius_ / (nbpoints * 2)),
234 std::stringstream ss;
235 ss <<
"overlay-" << display <<
"-" << itype <<
"-scale-" << scale;
236#ifdef VISP_HAVE_OPENCV
241 std::cout <<
" Overlay saved in: " << ss.str() << std::endl;
261int main(
int argc,
const char *argv[])
263 bool opt_click =
true;
264 bool opt_display =
true;
265 std::string opt_ipath;
266 std::string env_ipath;
269 for (
int i = 0; i < argc; i++) {
270 if (std::string(argv[i]) ==
"-c")
272 else if (std::string(argv[i]) ==
"-d")
274 else if (std::string(argv[i]) ==
"-i")
275 opt_ipath = std::string(argv[i + 1]);
276 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
277 std::cout <<
"\nUsage: " << argv[0] <<
" [-i <image path>] [-c] [-d] [--help]\n" << std::endl;
278 std::cout <<
"\nOptions: " << std::endl;
279 std::cout <<
" -i <input image path> : set image input path.\n"
280 <<
" From this path read \"Klimt/Klimt.pgm\" image.\n"
281 <<
" Setting the VISP_INPUT_IMAGE_PATH environment\n"
282 <<
" variable produces the same behaviour than using\n"
283 <<
" this option." << std::endl;
284 std::cout <<
" -c : disable mouse click" << std::endl;
285 std::cout <<
" -d : disable display" << std::endl;
286 std::cout <<
" -h, --help : print this help\n" << std::endl;
296 if (!env_ipath.empty())
300 if (!opt_ipath.empty())
303 std::string filename;
305 std::vector<std::string> display;
308 display.push_back(
"GDI");
311 display.push_back(
"GTK");
314 display.push_back(
"X");
316#ifdef VISP_HAVE_OPENCV
317 display.push_back(
"OpenCV");
320 display.push_back(
"D3D9");
323 if (display.size() == 0) {
324 std::cout <<
"No display available. We stop here." << std::endl;
337 for (
unsigned int i = 0; i < display.size(); i++) {
339 for (
unsigned int scale = 1; scale < 4; scale++) {
340 if (!test(display[i], I, scale, opt_click))
342 if (!test(display[i], C, scale, opt_click))
347 std::cout <<
"Test succeed" << std::endl;
349 std::cout <<
"Test failed with " << nbfailure <<
" failures" << std::endl;
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...
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
void init(vpImage< unsigned char > &I, int win_x=-1, int win_y=-1, const std::string &win_title="")
unsigned int getScreenHeight()
unsigned int getScreenWidth()
Class that defines generic functionalities for display.
static void close(vpImage< unsigned char > &I)
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)
virtual void setDownScalingFactor(unsigned int scale)
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 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.