42 #include <visp3/core/vpConfig.h>
44 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_FEATURES2D) && defined(HAVE_OPENCV_VIDEO)
46 #include <visp3/core/vpImage.h>
47 #include <visp3/core/vpIoTools.h>
48 #include <visp3/gui/vpDisplayGDI.h>
49 #include <visp3/gui/vpDisplayGTK.h>
50 #include <visp3/gui/vpDisplayOpenCV.h>
51 #include <visp3/gui/vpDisplayX.h>
52 #include <visp3/io/vpImageIo.h>
53 #include <visp3/io/vpParseArgv.h>
54 #include <visp3/io/vpVideoReader.h>
55 #include <visp3/vision/vpKeyPoint.h>
58 #define GETOPTARGS "cdh"
60 #ifdef ENABLE_VISP_NAMESPACE
64 void usage(
const char *name,
const char *badparam);
65 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display);
75 void usage(
const char *name,
const char *badparam)
78 Test keypoints matching.\n\
88 Disable the mouse click. Useful to automate the \n\
89 execution of this program without human intervention.\n\
92 Turn off the display.\n\
98 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
112 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
120 click_allowed =
false;
126 usage(argv[0],
nullptr);
131 usage(argv[0], optarg_);
137 if ((c == 1) || (c == -1)) {
139 usage(argv[0],
nullptr);
140 std::cerr <<
"ERROR: " << std::endl;
141 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
148 template <
typename Type>
149 void run_test(
const std::string &env_ipath,
bool opt_click_allowed,
bool opt_display,
vpImage<Type> &Iref,
152 #if VISP_HAVE_DATASET_VERSION >= 0x030600
153 std::string ext(
"png");
155 std::string ext(
"pgm");
166 vpKeyPoint keypoints(
"ORB",
"ORB",
"BruteForce-Hamming");
167 std::cout <<
"Build " << keypoints.buildReference(Iref) <<
" reference points." << std::endl;
177 #if defined(VISP_HAVE_X11)
179 #elif defined(VISP_HAVE_GTK)
181 #elif defined(VISP_HAVE_GDI)
183 #elif defined(HAVE_OPENCV_HIGHGUI)
189 display.init(Imatch, 0, 0,
"ORB keypoints matching");
192 bool opt_click =
false;
203 keypoints.matchPoint(Icur);
205 keypoints.displayMatching(Iref, Imatch);
212 if (opt_click_allowed && opt_display) {
234 int main(
int argc,
const char **argv)
237 std::string env_ipath;
238 bool opt_click_allowed =
true;
239 bool opt_display =
true;
242 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
250 if (env_ipath.empty()) {
251 std::cerr <<
"Please set the VISP_INPUT_IMAGE_PATH environment "
260 std::cout <<
"-- Test on gray level images" << std::endl;
261 run_test(env_ipath, opt_click_allowed, opt_display, Iref, Icur, Imatch);
267 std::cout <<
"-- Test on color images" << std::endl;
268 run_test(env_ipath, opt_click_allowed, opt_display, Iref, Icur, Imatch);
273 std::cerr << e.
what() << std::endl;
277 std::cout <<
"testKeyPoint is ok !" << std::endl;
283 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...
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)