41 #include <visp3/core/vpConfig.h> 43 #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020301) 45 #include <visp3/core/vpImage.h> 46 #include <visp3/core/vpIoTools.h> 47 #include <visp3/gui/vpDisplayGDI.h> 48 #include <visp3/gui/vpDisplayGTK.h> 49 #include <visp3/gui/vpDisplayOpenCV.h> 50 #include <visp3/gui/vpDisplayX.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 void usage(
const char *name,
const char *badparam);
60 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display);
70 void usage(
const char *name,
const char *badparam)
73 Test keypoints matching.\n\ 76 %s [-c] [-d] [-h]\n", name);
82 Disable the mouse click. Useful to automate the \n\ 83 execution of this program without human intervention.\n\ 86 Turn off the display.\n\ 92 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
106 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
114 click_allowed =
false;
120 usage(argv[0], NULL);
125 usage(argv[0], optarg_);
131 if ((c == 1) || (c == -1)) {
133 usage(argv[0], NULL);
134 std::cerr <<
"ERROR: " << std::endl;
135 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
142 template<
typename Type>
143 void run_test(
const std::string &env_ipath,
bool opt_click_allowed,
bool opt_display,
155 vpKeyPoint keypoints(
"ORB",
"ORB",
"BruteForce-Hamming");
156 std::cout <<
"Build " << keypoints.buildReference(Iref) <<
" reference points." << std::endl;
166 #if defined VISP_HAVE_X11 168 #elif defined VISP_HAVE_GTK 170 #elif defined VISP_HAVE_GDI 178 display.
init(Imatch, 0, 0,
"ORB keypoints matching");
181 bool opt_click =
false;
192 keypoints.matchPoint(Icur);
194 keypoints.displayMatching(Iref, Imatch);
201 if (opt_click_allowed && opt_display) {
226 int main(
int argc,
const char **argv)
229 std::string env_ipath;
230 bool opt_click_allowed =
true;
231 bool opt_display =
true;
234 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
242 if (env_ipath.empty()) {
243 std::cerr <<
"Please set the VISP_INPUT_IMAGE_PATH environment " 252 std::cout <<
"-- Test on gray level images" << std::endl;
253 run_test(env_ipath, opt_click_allowed, opt_display, Iref, Icur, Imatch);
259 std::cout <<
"-- Test on color images" << std::endl;
260 run_test(env_ipath, opt_click_allowed, opt_display, Iref, Icur, Imatch);
264 std::cerr << e.
what() << std::endl;
268 std::cout <<
"testKeyPoint is ok !" << std::endl;
274 std::cerr <<
"You need OpenCV library." << std::endl;
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
virtual void setDownScalingFactor(unsigned int scale)
Display for windows using GDI (available on any windows 32 platform).
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
error that can be emited by ViSP classes.
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
static void flush(const vpImage< unsigned char > &I)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
void open(vpImage< vpRGBa > &I)
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...
void acquire(vpImage< vpRGBa > &I)
void insert(const vpImage< Type > &src, const vpImagePoint &topLeft)
const char * what() const
unsigned int getHeight() const
Class that allows keypoints detection (and descriptors extraction) and matching thanks to OpenCV libr...
void setFileName(const std::string &filename)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
unsigned int getWidth() const
Definition of the vpImage class member functions.