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/io/vpImageIo.h>
47 #include <visp3/gui/vpDisplayX.h>
48 #include <visp3/gui/vpDisplayGTK.h>
49 #include <visp3/gui/vpDisplayGDI.h>
50 #include <visp3/gui/vpDisplayOpenCV.h>
51 #include <visp3/core/vpIoTools.h>
52 #include <visp3/io/vpParseArgv.h>
53 #include <visp3/vision/vpKeyPoint.h>
56 #define GETOPTARGS "cdh"
58 void usage(
const char *name,
const char *badparam);
59 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display);
69 void usage(
const char *name,
const char *badparam)
72 Test keypoints detection.\n\
75 %s [-c] [-d] [-h]\n", name);
81 Disable the mouse click. Useful to automaze the \n\
82 execution of this program without humain intervention.\n\
85 Turn off the display.\n\
91 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
105 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
112 case 'c': click_allowed =
false;
break;
113 case 'd': display =
false;
break;
114 case 'h': usage(argv[0], NULL);
return false;
break;
117 usage(argv[0], optarg_);
122 if ((c == 1) || (c == -1)) {
124 usage(argv[0], NULL);
125 std::cerr <<
"ERROR: " << std::endl;
126 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
139 int main(
int argc,
const char ** argv) {
141 std::string env_ipath;
142 bool opt_click_allowed =
true;
143 bool opt_display =
true;
146 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
153 if(env_ipath.empty()) {
154 std::cerr <<
"Please set the VISP_INPUT_IMAGE_PATH environment variable value." << std::endl;
167 #if defined VISP_HAVE_X11
169 #elif defined VISP_HAVE_GTK
171 #elif defined VISP_HAVE_GDI
178 display.
init(I, 0, 0,
"KeyPoints detection.");
185 std::vector<std::string> detectorNames;
186 detectorNames.push_back(
"PyramidFAST");
187 detectorNames.push_back(
"FAST");
188 detectorNames.push_back(
"PyramidMSER");
189 detectorNames.push_back(
"MSER");
190 detectorNames.push_back(
"PyramidGFTT");
191 detectorNames.push_back(
"GFTT");
192 detectorNames.push_back(
"PyramidSimpleBlob");
193 detectorNames.push_back(
"SimpleBlob");
195 #if (VISP_HAVE_OPENCV_VERSION < 0x030000) || defined(VISP_HAVE_OPENCV_XFEATURES2D)
196 detectorNames.push_back(
"PyramidSTAR");
197 detectorNames.push_back(
"STAR");
199 #if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
200 detectorNames.push_back(
"PyramidAGAST");
201 detectorNames.push_back(
"AGAST");
204 detectorNames.push_back(
"ORB");
205 #if (VISP_HAVE_OPENCV_VERSION >= 0x020403)
207 detectorNames.push_back(
"BRISK");
209 #if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
210 detectorNames.push_back(
"PyramidKAZE");
211 detectorNames.push_back(
"KAZE");
212 detectorNames.push_back(
"PyramidAKAZE");
213 detectorNames.push_back(
"AKAZE");
216 #if defined(VISP_HAVE_OPENCV_NONFREE) || defined(VISP_HAVE_OPENCV_XFEATURES2D)
217 detectorNames.push_back(
"PyramidSIFT");
218 detectorNames.push_back(
"SIFT");
219 detectorNames.push_back(
"PyramidSURF");
220 detectorNames.push_back(
"SURF");
223 for(std::vector<std::string>::const_iterator itd = detectorNames.begin(); itd != detectorNames.end(); ++itd) {
226 std::vector<cv::KeyPoint> kpts;
228 keyPoints.
detect(I, kpts, elapsedTime);
229 std::cout <<
"Nb keypoints detected: " << kpts.size() <<
" for " << *itd <<
" method." << std::endl;
231 std::cerr <<
"No keypoints detected with " << *itd <<
" and image: " << filename <<
"." << std::endl;
238 for(std::vector<cv::KeyPoint>::const_iterator it = kpts.begin(); it != kpts.end(); ++it) {
240 imPt.
set_uv(it->pt.x, it->pt.y);
247 if(opt_click_allowed) {
254 std::cerr << e.
what() << std::endl;
258 std::cout <<
"testKeyPoint-5 is ok !" << std::endl;
263 std::cerr <<
"You need OpenCV library." << std::endl;
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
void detect(const vpImage< unsigned char > &I, std::vector< cv::KeyPoint > &keyPoints, double &elapsedTime, const vpRect &rectangle=vpRect())
Display for windows using GDI (available on any windows 32 platform).
Define the X11 console to display images.
error that can be emited by ViSP classes.
static void flush(const vpImage< unsigned char > &I)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
const char * what() const
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the opencv library.
virtual void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)=0
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
Class that allows keypoints detection (and descriptors extraction) and matching thanks to OpenCV libr...
void set_uv(const double u, const double v)
void setDetector(const std::string &detectorName)
virtual bool getClick(bool blocking=true)=0
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static void read(vpImage< unsigned char > &I, const char *filename)