36 #include <visp3/core/vpConfig.h>
38 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_FEATURES2D) && defined(HAVE_OPENCV_VIDEO)
40 #include <visp3/core/vpImage.h>
41 #include <visp3/core/vpIoTools.h>
42 #include <visp3/gui/vpDisplayGDI.h>
43 #include <visp3/gui/vpDisplayGTK.h>
44 #include <visp3/gui/vpDisplayOpenCV.h>
45 #include <visp3/gui/vpDisplayX.h>
46 #include <visp3/io/vpImageIo.h>
47 #include <visp3/io/vpParseArgv.h>
48 #include <visp3/io/vpVideoReader.h>
49 #include <visp3/vision/vpKeyPoint.h>
52 #define GETOPTARGS "cdh"
54 void usage(
const char *name,
const char *badparam);
55 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display);
65 void usage(
const char *name,
const char *badparam)
68 Test keypoints matching.\n\
78 Disable the mouse click. Useful to automate the \n\
79 execution of this program without human intervention.\n\
82 Turn off the display.\n\
88 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
102 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
110 click_allowed =
false;
116 usage(argv[0],
nullptr);
121 usage(argv[0], optarg_);
127 if ((c == 1) || (c == -1)) {
129 usage(argv[0],
nullptr);
130 std::cerr <<
"ERROR: " << std::endl;
131 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
138 template <
typename Type>
139 void run_test(
const std::string &env_ipath,
bool opt_click_allowed,
bool opt_display,
vpImage<Type> &Iref,
142 #if VISP_HAVE_DATASET_VERSION >= 0x030600
143 std::string ext(
"png");
145 std::string ext(
"pgm");
156 vpKeyPoint keypoints(
"ORB",
"ORB",
"BruteForce-Hamming");
157 std::cout <<
"Build " << keypoints.buildReference(Iref) <<
" reference points." << std::endl;
167 #if defined(VISP_HAVE_X11)
169 #elif defined(VISP_HAVE_GTK)
171 #elif defined(VISP_HAVE_GDI)
173 #elif defined(HAVE_OPENCV_HIGHGUI)
179 display.init(Imatch, 0, 0,
"ORB keypoints matching");
182 bool opt_click =
false;
193 keypoints.matchPoint(Icur);
195 keypoints.displayMatching(Iref, Imatch);
202 if (opt_click_allowed && opt_display) {
227 int main(
int argc,
const char **argv)
230 std::string env_ipath;
231 bool opt_click_allowed =
true;
232 bool opt_display =
true;
235 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
243 if (env_ipath.empty()) {
244 std::cerr <<
"Please set the VISP_INPUT_IMAGE_PATH environment "
253 std::cout <<
"-- Test on gray level images" << std::endl;
254 run_test(env_ipath, opt_click_allowed, opt_display, Iref, Icur, Imatch);
260 std::cout <<
"-- Test on color images" << std::endl;
261 run_test(env_ipath, opt_click_allowed, opt_display, Iref, Icur, Imatch);
265 std::cerr << e.
what() << std::endl;
269 std::cout <<
"testKeyPoint is ok !" << std::endl;
275 std::cerr <<
"You need OpenCV library." << std::endl;
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...
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
error that can be emitted by ViSP classes.
const char * what() const
static void read(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.
unsigned int getWidth() const
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
void insert(const vpImage< Type > &src, const vpImagePoint &topLeft)
unsigned int getHeight() const
Class that allows keypoints detection (and descriptors extraction) and matching thanks to OpenCV libr...
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
void acquire(vpImage< vpRGBa > &I)
void open(vpImage< vpRGBa > &I)
void setFileName(const std::string &filename)
void display(vpImage< unsigned char > &I, const std::string &title)
Display a gray-scale image.