3 #include <visp3/gui/vpDisplayD3D.h>
4 #include <visp3/gui/vpDisplayGDI.h>
5 #include <visp3/gui/vpDisplayGTK.h>
6 #include <visp3/gui/vpDisplayOpenCV.h>
7 #include <visp3/gui/vpDisplayX.h>
8 #include <visp3/io/vpImageIo.h>
9 #include <visp3/core/vpImageTools.h>
10 #include <visp3/core/vpIoTools.h>
12 template<
typename Type>
17 int scale_ = (int)scale;
18 int radius_ = (int)radius;
19 unsigned int thickness = 2;
24 vpRect roi(center, radius_+scale_, radius_);
31 if (display ==
"GDI") {
36 else if (display ==
"GTK") {
41 else if (display ==
"X") {
46 else if (display ==
"OpenCV") {
47 #ifdef VISP_HAVE_OPENCV
51 else if (display ==
"D3D9") {
56 std::cout <<
"Start test for " << display <<
" renderer..." << std::endl;
57 std::cout <<
" Screen resolution: " << d->getScreenWidth() <<
" " << d->getScreenHeight() << std::endl;
70 if (
sizeof(Type) == 1) {
81 if (Isampled != Irendered) {
83 std::cout <<
" -- Test width scale= " << scale <<
" type= " << itype <<
": failed" << std::endl;
86 ss <<
"Isampled-" << itype <<
"-scale-" << scale;
87 #ifdef VISP_HAVE_OPENCV
95 ss.str(
""); ss.clear();
96 ss <<
"Irendered-" << itype <<
"-scale-" << scale;
97 #ifdef VISP_HAVE_OPENCV
107 ss.str(
""); ss.clear();
108 ss <<
"Idiff-" << itype <<
"-scale-" << scale;
109 #ifdef VISP_HAVE_OPENCV
118 std::cout <<
" ++ Test width scale= " << scale <<
" type= " << itype <<
": succeed" << std::endl;
125 Iinsert.
subsample(scale, scale, Isampled);
133 if (IsampledCopy != Irendered) {
135 std::cout <<
" -- Test width scale= " << scale <<
" type= " << itype <<
": failed" << std::endl;
137 std::stringstream ss;
138 ss <<
"Isampled-" << itype <<
"-scale-" << scale;
139 #ifdef VISP_HAVE_OPENCV
147 ss.str(
""); ss.clear();
148 ss <<
"Irendered-" << itype <<
"-scale-" << scale;
149 #ifdef VISP_HAVE_OPENCV
158 ss.str(
""); ss.clear();
159 ss <<
"Idiff-" << itype <<
"-scale-" << scale;
160 #ifdef VISP_HAVE_OPENCV
170 std::cout <<
" ++ Test width scale= " << scale <<
" type= " << itype <<
": succeed" << std::endl;
183 int nbpoints = (int)(radius*sqrt(2.)/8/scale);
184 for (
int i=0; i< nbpoints; i++) {
200 std::stringstream ss;
201 ss <<
"overlay-" << display <<
"-" << itype <<
"-scale-" << scale;
202 #ifdef VISP_HAVE_OPENCV
207 std::cout <<
" Overlay saved in: " << ss.str() << std::endl;
227 int main(
int argc,
const char *argv[])
229 bool opt_click =
true;
230 bool opt_display =
true;
231 std::string opt_ipath;
232 std::string env_ipath;
235 for (
int i=0; i<argc; i++) {
236 if (std::string(argv[i]) ==
"-c")
238 else if (std::string(argv[i]) ==
"-d")
240 else if (std::string(argv[i]) ==
"-i")
241 opt_ipath = std::string(argv[i+1]);
242 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
243 std::cout <<
"\nUsage: " << argv[0] <<
" [-i <image path>] [-c] [-d] [--help]\n" << std::endl;
244 std::cout <<
"\nOptions: " << std::endl;
245 std::cout <<
" -i <input image path> : set image input path.\n"
246 <<
" From this path read \"ViSP-images/Klimt/Klimt.pgm\" image.\n"
247 <<
" Setting the VISP_INPUT_IMAGE_PATH environment\n"
248 <<
" variable produces the same behaviour than using\n"
249 <<
" this option." << std::endl;
250 std::cout <<
" -c : disable mouse click" << std::endl;
251 std::cout <<
" -d : disable display" << std::endl;
252 std::cout <<
" -h, --help : print this help\n" << std::endl;
261 if (! env_ipath.empty())
265 if (!opt_ipath.empty())
268 std::string filename;
270 std::vector<std::string>
display;
273 display.push_back(
"GDI");
276 display.push_back(
"GTK");
279 display.push_back(
"X");
281 #ifdef VISP_HAVE_OPENCV
282 display.push_back(
"OpenCV");
284 #ifdef VISP_HAVE_D3D9
285 display.push_back(
"D3D9");
288 if (display.size() == 0) {
289 std::cout <<
"No display available. We stop here." << std::endl;
302 for(
unsigned int i=0; i<display.size(); i++) {
304 for(
unsigned int scale=1; scale<4; scale++) {
305 if (! test(display[i], I, scale, opt_click) ) nbfailure ++;
306 if (! test(display[i], C, scale, opt_click) ) nbfailure ++;
310 std::cout <<
"Test succeed" << std::endl;
312 std::cout <<
"Test failed with " << nbfailure <<
" failures" << std::endl;
Class that defines generic functionnalities for display.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void close(vpImage< unsigned char > &I)
unsigned int getWidth() const
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
virtual void setDownScalingFactor(unsigned int scale)
vpDisplayGDI()
Basic constructor.
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
static void displayPoint(const vpImage< unsigned char > &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
static void write(const vpImage< unsigned char > &I, const std::string &filename)
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed...
static const vpColor cyan
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 display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
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 getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
void subsample(unsigned int v_scale, unsigned int h_scale, vpImage< Type > &sampled) const
static void displayCircle(const vpImage< unsigned char > &I, const vpImagePoint ¢er, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static void read(vpImage< unsigned char > &I, const std::string &filename)
void insert(const vpImage< Type > &src, const vpImagePoint topLeft)
unsigned int getHeight() const
Defines a rectangle in the plane.
static void displayROI(const vpImage< unsigned char > &I, const vpRect &roi)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
Definition of the vpImage class member functions.
static void displayDotLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
static const vpColor blue