 |
Visual Servoing Platform
version 3.3.0
|
41 #include <visp3/core/vpImageTools.h>
42 #include <visp3/core/vpIoTools.h>
43 #include <visp3/gui/vpDisplayD3D.h>
44 #include <visp3/gui/vpDisplayGDI.h>
45 #include <visp3/gui/vpDisplayGTK.h>
46 #include <visp3/gui/vpDisplayOpenCV.h>
47 #include <visp3/gui/vpDisplayX.h>
48 #include <visp3/io/vpImageIo.h>
50 template <
typename Type>
bool test(
const std::string &
display,
vpImage<Type> &I,
unsigned int scale,
bool click)
54 int scale_ = (int)scale;
55 int radius_ = (int)radius;
56 unsigned int thickness = 2;
61 vpRect roi(center, radius_ + scale_, radius_);
80 }
else if (
display ==
"OpenCV") {
81 #ifdef VISP_HAVE_OPENCV
89 std::cout <<
"Start test for " <<
display <<
" renderer..." << std::endl;
103 if (
sizeof(Type) == 1) {
109 Icolor.
subsample(scale, scale, Isampled);
114 if (Isampled != Irendered) {
116 std::cout <<
" -- Test width scale= " << scale <<
" type= " << itype <<
": failed" << std::endl;
118 std::stringstream ss;
119 ss <<
"Isampled-" << itype <<
"-scale-" << scale;
120 #ifdef VISP_HAVE_OPENCV
130 ss <<
"Irendered-" << itype <<
"-scale-" << scale;
131 #ifdef VISP_HAVE_OPENCV
143 ss <<
"Idiff-" << itype <<
"-scale-" << scale;
144 #ifdef VISP_HAVE_OPENCV
152 std::cout <<
" ++ Test width scale= " << scale <<
" type= " << itype <<
": succeed" << std::endl;
158 Iinsert.
subsample(scale, scale, Isampled);
166 if (IsampledCopy != Irendered) {
168 std::cout <<
" -- Test width scale= " << scale <<
" type= " << itype <<
": failed" << std::endl;
170 std::stringstream ss;
171 ss <<
"Isampled-" << itype <<
"-scale-" << scale;
172 #ifdef VISP_HAVE_OPENCV
182 ss <<
"Irendered-" << itype <<
"-scale-" << scale;
183 #ifdef VISP_HAVE_OPENCV
194 ss <<
"Idiff-" << itype <<
"-scale-" << scale;
195 #ifdef VISP_HAVE_OPENCV
204 std::cout <<
" ++ Test width scale= " << scale <<
" type= " << itype <<
": succeed" << std::endl;
218 int nbpoints = (int)(radius * sqrt(2.) / 8 / scale);
219 for (
int i = 0; i < nbpoints; i++) {
221 I, center - h_offset / 2. +
vpImagePoint(-i * radius_ / (nbpoints * 2), i * radius_ / (nbpoints * 2)),
237 std::stringstream ss;
238 ss <<
"overlay-" <<
display <<
"-" << itype <<
"-scale-" << scale;
239 #ifdef VISP_HAVE_OPENCV
244 std::cout <<
" Overlay saved in: " << ss.str() << std::endl;
264 int main(
int argc,
const char *argv[])
266 bool opt_click =
true;
267 bool opt_display =
true;
268 std::string opt_ipath;
269 std::string env_ipath;
272 for (
int i = 0; i < argc; i++) {
273 if (std::string(argv[i]) ==
"-c")
275 else if (std::string(argv[i]) ==
"-d")
277 else if (std::string(argv[i]) ==
"-i")
278 opt_ipath = std::string(argv[i + 1]);
279 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
280 std::cout <<
"\nUsage: " << argv[0] <<
" [-i <image path>] [-c] [-d] [--help]\n" << std::endl;
281 std::cout <<
"\nOptions: " << std::endl;
282 std::cout <<
" -i <input image path> : set image input path.\n"
283 <<
" From this path read \"Klimt/Klimt.pgm\" image.\n"
284 <<
" Setting the VISP_INPUT_IMAGE_PATH environment\n"
285 <<
" variable produces the same behaviour than using\n"
286 <<
" this option." << std::endl;
287 std::cout <<
" -c : disable mouse click" << std::endl;
288 std::cout <<
" -d : disable display" << std::endl;
289 std::cout <<
" -h, --help : print this help\n" << std::endl;
299 if (!env_ipath.empty())
303 if (!opt_ipath.empty())
306 std::string filename;
308 std::vector<std::string>
display;
319 #ifdef VISP_HAVE_OPENCV
322 #ifdef VISP_HAVE_D3D9
327 std::cout <<
"No display available. We stop here." << std::endl;
340 for (
unsigned int i = 0; i <
display.size(); i++) {
342 for (
unsigned int scale = 1; scale < 4; scale++) {
343 if (!test(
display[i], I, scale, opt_click))
345 if (!test(
display[i], C, scale, opt_click))
350 std::cout <<
"Test succeed" << std::endl;
352 std::cout <<
"Test failed with " << nbfailure <<
" failures" << std::endl;
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
static void displayDotLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
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 convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
unsigned int getScreenWidth()
static void read(vpImage< unsigned char > &I, const std::string &filename)
static void close(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)
void insert(const vpImage< Type > &src, const vpImagePoint &topLeft)
static const vpColor blue
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)
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed....
static void displayPoint(const vpImage< unsigned char > &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
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 write(const vpImage< unsigned char > &I, const std::string &filename)
static void display(const vpImage< unsigned char > &I)
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
unsigned int getHeight() const
unsigned int getScreenHeight()
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
static void displayROI(const vpImage< unsigned char > &I, const vpRect &roi)
virtual void setDownScalingFactor(unsigned int scale)
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
Definition of the vpImage class member functions.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
Class that defines generic functionnalities for display.
Defines a rectangle in the plane.
static const vpColor cyan
unsigned int getWidth() const
vpDisplayGDI()
Basic constructor.