42#include <visp3/core/vpConfig.h>
44#if defined(VISP_HAVE_OPENCV) && 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
63void usage(
const char *name,
const char *badparam);
64bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display);
74void 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);
110bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
118 click_allowed =
false;
124 usage(argv[0],
nullptr);
128 usage(argv[0], optarg_);
133 if ((c == 1) || (c == -1)) {
135 usage(argv[0],
nullptr);
136 std::cerr <<
"ERROR: " << std::endl;
137 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
144template <
typename Type>
145void run_test(
const std::string &env_ipath,
bool opt_click_allowed,
bool opt_display,
vpImage<Type> &Iref,
148#if defined(VISP_HAVE_DATASET)
149#if VISP_HAVE_DATASET_VERSION >= 0x030600
150 std::string ext(
"png");
152 std::string ext(
"pgm");
156 std::string ext(
"png");
167 vpKeyPoint keypoints(
"ORB",
"ORB",
"BruteForce-Hamming");
168 std::cout <<
"Build " << keypoints.buildReference(Iref) <<
" reference points." << std::endl;
181#ifdef VISP_HAVE_DISPLAY
185 std::cout <<
"No image viewer is available..." << std::endl;
189 bool opt_click =
false;
200 keypoints.matchPoint(Icur);
202 keypoints.displayMatching(Iref, Imatch);
209 if (opt_click_allowed && opt_display) {
235int main(
int argc,
const char **argv)
238 std::string env_ipath;
239 bool opt_click_allowed =
true;
240 bool opt_display =
true;
243 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
251 if (env_ipath.empty()) {
252 std::cerr <<
"Please set the VISP_INPUT_IMAGE_PATH environment "
261 std::cout <<
"-- Test on gray level images" << std::endl;
262 run_test(env_ipath, opt_click_allowed, opt_display, Iref, Icur, Imatch);
268 std::cout <<
"-- Test on color images" << std::endl;
269 run_test(env_ipath, opt_click_allowed, opt_display, Iref, Icur, Imatch);
274 std::cerr <<
e.what() << std::endl;
278 std::cout <<
"testKeyPoint is ok !" << std::endl;
284 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.
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 open(vpImage< vpRGBa > &I) VP_OVERRIDE
void setFileName(const std::string &filename)
void acquire(vpImage< vpRGBa > &I) VP_OVERRIDE
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.