 |
Visual Servoing Platform
version 3.2.0
|
42 #include <visp3/core/vpConfig.h>
44 #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020301)
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/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 detection.\n\
76 %s [-c] [-d] [-h]\n", name);
82 Disable the mouse click. Useful to automaze the \n\
83 execution of this program without humain 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;
148 int main(
int argc,
const char **argv)
151 std::string env_ipath;
152 bool opt_click_allowed =
true;
153 bool opt_display =
true;
156 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
164 if (env_ipath.empty()) {
165 std::cerr <<
"Please set the VISP_INPUT_IMAGE_PATH environment "
181 #if defined VISP_HAVE_X11
183 #elif defined VISP_HAVE_GTK
185 #elif defined VISP_HAVE_GDI
192 display.init(I, 0, 0,
"KeyPoints detection.");
197 std::cout <<
"INFORMATION: " << std::endl;
198 std::cout <<
"Here, we want to test feature detection on a pyramid of images "
200 "that are scale invariant to detect potential problem in ViSP."
207 std::vector<std::string> detectorNames;
208 detectorNames.push_back(
"PyramidFAST");
209 detectorNames.push_back(
"FAST");
210 detectorNames.push_back(
"PyramidMSER");
211 detectorNames.push_back(
"MSER");
212 detectorNames.push_back(
"PyramidGFTT");
213 detectorNames.push_back(
"GFTT");
214 detectorNames.push_back(
"PyramidSimpleBlob");
215 detectorNames.push_back(
"SimpleBlob");
217 #if (VISP_HAVE_OPENCV_VERSION < 0x030000) || defined(VISP_HAVE_OPENCV_XFEATURES2D)
218 detectorNames.push_back(
"PyramidSTAR");
219 detectorNames.push_back(
"STAR");
221 #if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
222 detectorNames.push_back(
"PyramidAGAST");
223 detectorNames.push_back(
"AGAST");
225 detectorNames.push_back(
"PyramidORB");
226 detectorNames.push_back(
"ORB");
227 #if (VISP_HAVE_OPENCV_VERSION >= 0x020403)
228 detectorNames.push_back(
"PyramidBRISK");
229 detectorNames.push_back(
"BRISK");
231 #if (VISP_HAVE_OPENCV_VERSION >= 0x030000)
232 detectorNames.push_back(
"PyramidKAZE");
233 detectorNames.push_back(
"KAZE");
234 detectorNames.push_back(
"PyramidAKAZE");
235 detectorNames.push_back(
"AKAZE");
238 #if defined(VISP_HAVE_OPENCV_NONFREE) || defined(VISP_HAVE_OPENCV_XFEATURES2D)
239 detectorNames.push_back(
"PyramidSIFT");
240 detectorNames.push_back(
"SIFT");
241 detectorNames.push_back(
"PyramidSURF");
242 detectorNames.push_back(
"SURF");
245 for (std::vector<std::string>::const_iterator itd = detectorNames.begin(); itd != detectorNames.end(); ++itd) {
248 std::vector<cv::KeyPoint> kpts;
250 keyPoints.
detect(I, kpts);
251 std::cout <<
"Nb keypoints detected: " << kpts.size() <<
" for " << *itd <<
" method." << std::endl;
253 std::cerr <<
"No keypoints detected with " << *itd <<
" and image: " << filename <<
"." << std::endl;
260 for (std::vector<cv::KeyPoint>::const_iterator it = kpts.begin(); it != kpts.end(); ++it) {
262 imPt.
set_uv(it->pt.x, it->pt.y);
269 if (opt_click_allowed) {
277 std::map<vpKeyPoint::vpFeatureDetectorType, std::string> mapOfDetectorNames = keyPoints.
getDetectorNames();
281 std::vector<cv::KeyPoint> kpts;
283 keyPoints.
detect(I, kpts);
284 std::cout <<
"Nb keypoints detected: " << kpts.size() <<
" for "
288 <<
" method and image: " << filename <<
"." << std::endl;
295 for (std::vector<cv::KeyPoint>::const_iterator it = kpts.begin(); it != kpts.end(); ++it) {
297 imPt.
set_uv(it->pt.x, it->pt.y);
304 if (opt_click_allowed) {
311 std::cerr << e.
what() << std::endl;
315 std::cout <<
"testKeyPoint-5 is ok !" << std::endl;
323 std::cerr <<
"You need OpenCV library." << std::endl;
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
void halfSizeImage(vpImage< Type > &res) const
static void read(vpImage< unsigned char > &I, const std::string &filename)
void set_uv(const double u, const double v)
Display for windows using GDI (available on any windows 32 platform).
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
static void display(const vpImage< unsigned char > &I)
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
const char * what() const
Class that allows keypoints detection (and descriptors extraction) and matching thanks to OpenCV libr...
void detect(const vpImage< unsigned char > &I, std::vector< cv::KeyPoint > &keyPoints, const vpRect &rectangle=vpRect())
std::map< vpFeatureDetectorType, std::string > getDetectorNames() const
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static void flush(const vpImage< unsigned char > &I)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
void setDetector(const vpFeatureDetectorType &detectorType)
error that can be emited by ViSP classes.