3 #include <visp3/core/vpImageTools.h> 4 #include <visp3/core/vpIoTools.h> 5 #include <visp3/gui/vpDisplayD3D.h> 6 #include <visp3/gui/vpDisplayGDI.h> 7 #include <visp3/gui/vpDisplayGTK.h> 8 #include <visp3/gui/vpDisplayOpenCV.h> 9 #include <visp3/gui/vpDisplayX.h> 10 #include <visp3/io/vpImageIo.h> 12 template <
typename Type>
bool test(
const std::string &
display,
vpImage<Type> &I,
unsigned int scale,
bool click)
16 int scale_ = (int)scale;
17 int radius_ = (int)radius;
18 unsigned int thickness = 2;
23 vpRect roi(center, radius_ + scale_, radius_);
30 if (display ==
"GDI") {
34 }
else if (display ==
"GTK") {
38 }
else if (display ==
"X") {
42 }
else if (display ==
"OpenCV") {
43 #ifdef VISP_HAVE_OPENCV 46 }
else if (display ==
"D3D9") {
51 std::cout <<
"Start test for " << display <<
" renderer..." << std::endl;
52 std::cout <<
" Screen resolution: " << d->getScreenWidth() <<
" " << d->getScreenHeight() << std::endl;
65 if (
sizeof(Type) == 1) {
76 if (Isampled != Irendered) {
78 std::cout <<
" -- Test width scale= " << scale <<
" type= " << itype <<
": failed" << std::endl;
81 ss <<
"Isampled-" << itype <<
"-scale-" << scale;
82 #ifdef VISP_HAVE_OPENCV 92 ss <<
"Irendered-" << itype <<
"-scale-" << scale;
93 #ifdef VISP_HAVE_OPENCV 105 ss <<
"Idiff-" << itype <<
"-scale-" << scale;
106 #ifdef VISP_HAVE_OPENCV 114 std::cout <<
" ++ Test width scale= " << scale <<
" type= " << itype <<
": succeed" << std::endl;
120 Iinsert.
subsample(scale, scale, Isampled);
128 if (IsampledCopy != Irendered) {
130 std::cout <<
" -- Test width scale= " << scale <<
" type= " << itype <<
": failed" << std::endl;
132 std::stringstream ss;
133 ss <<
"Isampled-" << itype <<
"-scale-" << scale;
134 #ifdef VISP_HAVE_OPENCV 144 ss <<
"Irendered-" << itype <<
"-scale-" << scale;
145 #ifdef VISP_HAVE_OPENCV 156 ss <<
"Idiff-" << itype <<
"-scale-" << scale;
157 #ifdef VISP_HAVE_OPENCV 166 std::cout <<
" ++ Test width scale= " << scale <<
" type= " << itype <<
": succeed" << std::endl;
180 int nbpoints = (int)(radius * sqrt(2.) / 8 / scale);
181 for (
int i = 0; i < nbpoints; i++) {
183 I, center - h_offset / 2. +
vpImagePoint(-i * radius_ / (nbpoints * 2), i * radius_ / (nbpoints * 2)),
199 std::stringstream ss;
200 ss <<
"overlay-" << display <<
"-" << itype <<
"-scale-" << scale;
201 #ifdef VISP_HAVE_OPENCV 206 std::cout <<
" Overlay saved in: " << ss.str() << std::endl;
226 int main(
int argc,
const char *argv[])
228 bool opt_click =
true;
229 bool opt_display =
true;
230 std::string opt_ipath;
231 std::string env_ipath;
234 for (
int i = 0; i < argc; i++) {
235 if (std::string(argv[i]) ==
"-c")
237 else if (std::string(argv[i]) ==
"-d")
239 else if (std::string(argv[i]) ==
"-i")
240 opt_ipath = std::string(argv[i + 1]);
241 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
242 std::cout <<
"\nUsage: " << argv[0] <<
" [-i <image path>] [-c] [-d] [--help]\n" << std::endl;
243 std::cout <<
"\nOptions: " << std::endl;
244 std::cout <<
" -i <input image path> : set image input path.\n" 245 <<
" From this path read \"Klimt/Klimt.pgm\" image.\n" 246 <<
" Setting the VISP_INPUT_IMAGE_PATH environment\n" 247 <<
" variable produces the same behaviour than using\n" 248 <<
" this option." << std::endl;
249 std::cout <<
" -c : disable mouse click" << std::endl;
250 std::cout <<
" -d : disable display" << std::endl;
251 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))
307 if (!test(display[i], C, scale, opt_click))
312 std::cout <<
"Test succeed" << std::endl;
314 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)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
virtual void setDownScalingFactor(unsigned int scale)
void subsample(unsigned int v_scale, unsigned int h_scale, vpImage< Type > &sampled) const
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)
void insert(const vpImage< Type > &src, const vpImagePoint &topLeft)
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
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)
unsigned int getHeight() const
static void read(vpImage< unsigned char > &I, const std::string &filename)
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)
unsigned int getWidth() const
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