42 #include <visp3/core/vpConfig.h>
44 #if defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO) && \
45 ((VISP_HAVE_OPENCV_VERSION < 0x050000) && defined(HAVE_OPENCV_CALIB3D) && defined(HAVE_OPENCV_FEATURES2D)) || \
46 ((VISP_HAVE_OPENCV_VERSION >= 0x050000) && defined(HAVE_OPENCV_3D) && defined(HAVE_OPENCV_FEATURES))
48 #include <visp3/core/vpImage.h>
49 #include <visp3/core/vpIoTools.h>
50 #include <visp3/gui/vpDisplayFactory.h>
51 #include <visp3/io/vpImageIo.h>
52 #include <visp3/io/vpParseArgv.h>
53 #include <visp3/io/vpVideoReader.h>
54 #include <visp3/vision/vpKeyPoint.h>
57 #define GETOPTARGS "cdh"
59 #ifdef ENABLE_VISP_NAMESPACE
63 void usage(
const char *name,
const char *badparam);
64 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display);
74 void usage(
const char *name,
const char *badparam)
77 Test keypoints matching.\n\
80 %s [-c] [-d] [-h]\n", name);
86 Disable the mouse click. Useful to automate the \n\
87 execution of this program without human intervention.\n\
90 Turn off the display.\n\
96 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
110 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
118 click_allowed =
false;
124 usage(argv[0],
nullptr);
129 usage(argv[0], optarg_);
135 if ((c == 1) || (c == -1)) {
137 usage(argv[0],
nullptr);
138 std::cerr <<
"ERROR: " << std::endl;
139 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
146 template <
typename Type>
147 void run_test(
const std::string &env_ipath,
bool opt_click_allowed,
bool opt_display,
vpImage<Type> &Iref,
150 #if VISP_HAVE_DATASET_VERSION >= 0x030600
151 std::string ext(
"png");
153 std::string ext(
"pgm");
164 vpKeyPoint keypoints(
"ORB",
"ORB",
"BruteForce-Hamming");
165 std::cout <<
"Build " << keypoints.buildReference(Iref) <<
" reference points." << std::endl;
178 #ifdef VISP_HAVE_DISPLAY
182 std::cout <<
"No image viewer is available..." << std::endl;
186 bool opt_click =
false;
197 keypoints.matchPoint(Icur);
199 keypoints.displayMatching(Iref, Imatch);
206 if (opt_click_allowed && opt_display) {
232 int main(
int argc,
const char **argv)
235 std::string env_ipath;
236 bool opt_click_allowed =
true;
237 bool opt_display =
true;
240 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
248 if (env_ipath.empty()) {
249 std::cerr <<
"Please set the VISP_INPUT_IMAGE_PATH environment "
258 std::cout <<
"-- Test on gray level images" << std::endl;
259 run_test(env_ipath, opt_click_allowed, opt_display, Iref, Icur, Imatch);
265 std::cout <<
"-- Test on color images" << std::endl;
266 run_test(env_ipath, opt_click_allowed, opt_display, Iref, Icur, Imatch);
271 std::cerr << e.
what() << std::endl;
275 std::cout <<
"testKeyPoint is ok !" << std::endl;
281 std::cerr <<
"You need OpenCV library." << std::endl;
Class that defines generic functionalities for display.
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 2D features detection (and descriptors extraction) and matching thanks to...
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)
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.