39 #include <visp3/core/vpConfig.h>
40 #include <visp3/core/vpImageTools.h>
41 #include <visp3/core/vpIoTools.h>
42 #include <visp3/gui/vpDisplayD3D.h>
43 #include <visp3/gui/vpDisplayGDI.h>
44 #include <visp3/gui/vpDisplayGTK.h>
45 #include <visp3/gui/vpDisplayOpenCV.h>
46 #include <visp3/gui/vpDisplayX.h>
47 #include <visp3/io/vpImageIo.h>
49 #ifdef ENABLE_VISP_NAMESPACE
53 template <
typename Type>
bool test(
const std::string &display,
vpImage<Type> &I,
unsigned int scale,
bool click)
57 int scale_ = (int)scale;
58 int radius_ = (int)radius;
59 unsigned int thickness = 2;
64 vpRect roi(center, radius_ + scale_, radius_);
71 if (display ==
"GDI") {
76 else if (display ==
"GTK") {
81 else if (display ==
"X") {
86 else if (display ==
"OpenCV") {
87 #ifdef HAVE_OPENCV_HIGHGUI
91 else if (display ==
"D3D9") {
96 std::cout <<
"Start test for " << display <<
" renderer..." << std::endl;
97 std::cout <<
" Screen resolution: " << d->getScreenWidth() <<
" " << d->getScreenHeight() << std::endl;
105 I.
insert(crop, roi.getTopLeft());
110 if (
sizeof(Type) == 1) {
116 Icolor.
subsample(scale, scale, Isampled);
121 if (Isampled != Irendered) {
123 std::cout <<
" -- Test width scale= " << scale <<
" type= " << itype <<
": failed" << std::endl;
125 std::stringstream ss;
126 ss <<
"Isampled-" << itype <<
"-scale-" << scale;
127 #ifdef VISP_HAVE_OPENCV
137 ss <<
"Irendered-" << itype <<
"-scale-" << scale;
138 #ifdef VISP_HAVE_OPENCV
150 ss <<
"Idiff-" << itype <<
"-scale-" << scale;
151 #ifdef VISP_HAVE_OPENCV
160 std::cout <<
" ++ Test width scale= " << scale <<
" type= " << itype <<
": succeed" << std::endl;
167 Iinsert.
subsample(scale, scale, Isampled);
175 if (IsampledCopy != Irendered) {
177 std::cout <<
" -- Test width scale= " << scale <<
" type= " << itype <<
": failed" << std::endl;
179 std::stringstream ss;
180 ss <<
"Isampled-" << itype <<
"-scale-" << scale;
181 #ifdef VISP_HAVE_OPENCV
191 ss <<
"Irendered-" << itype <<
"-scale-" << scale;
192 #ifdef VISP_HAVE_OPENCV
203 ss <<
"Idiff-" << itype <<
"-scale-" << scale;
204 #ifdef VISP_HAVE_OPENCV
214 std::cout <<
" ++ Test width scale= " << scale <<
" type= " << itype <<
": succeed" << std::endl;
228 int nbpoints = (int)(radius * sqrt(2.) / 8 / scale);
229 for (
int i = 0; i < nbpoints; i++) {
231 I, center - h_offset / 2. +
vpImagePoint(-i * radius_ / (nbpoints * 2), i * radius_ / (nbpoints * 2)),
247 std::stringstream ss;
248 ss <<
"overlay-" << display <<
"-" << itype <<
"-scale-" << scale;
249 #ifdef VISP_HAVE_OPENCV
254 std::cout <<
" Overlay saved in: " << ss.str() << std::endl;
274 int main(
int argc,
const char *argv[])
276 bool opt_click =
true;
277 bool opt_display =
true;
278 std::string opt_ipath;
279 std::string env_ipath;
282 for (
int i = 1; i < argc; i++) {
283 if (std::string(argv[i]) ==
"-c") {
286 else if (std::string(argv[i]) ==
"-d") {
289 else if (std::string(argv[i]) ==
"-i" && i + 1 < argc) {
290 opt_ipath = std::string(argv[++i]);
292 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
293 std::cout <<
"\nUsage: " << argv[0] <<
" [-i <image path>] [-c] [-d] [--help]\n" << std::endl;
294 std::cout <<
"\nOptions: " << std::endl;
295 std::cout <<
" -i <input image path> : set image input path.\n"
296 <<
" From this path read \"Klimt/Klimt.pgm\" image.\n"
297 <<
" Setting the VISP_INPUT_IMAGE_PATH environment\n"
298 <<
" variable produces the same behaviour than using\n"
299 <<
" this option." << std::endl;
300 std::cout <<
" -c : disable mouse click" << std::endl;
301 std::cout <<
" -d : disable display" << std::endl;
302 std::cout <<
" -h, --help : print this help\n" << std::endl;
312 if (!env_ipath.empty())
316 if (!opt_ipath.empty())
319 std::string filename;
321 std::vector<std::string> display;
324 display.push_back(
"GDI");
327 display.push_back(
"GTK");
330 display.push_back(
"X");
332 #ifdef VISP_HAVE_OPENCV
333 display.push_back(
"OpenCV");
335 #ifdef VISP_HAVE_D3D9
336 display.push_back(
"D3D9");
339 if (display.size() == 0) {
340 std::cout <<
"No display available. We stop here." << std::endl;
353 for (
unsigned int i = 0; i < display.size(); i++) {
355 for (
unsigned int scale = 1; scale < 4; scale++) {
356 if (!test(display[i], I, scale, opt_click))
358 if (!test(display[i], C, scale, opt_click))
363 std::cout <<
"Test succeed" << std::endl;
365 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...
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)
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 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.