diff --git a/modules/core/include/visp3/core/vpImageFilter.h b/modules/core/include/visp3/core/vpImageFilter.h index 2af1b1513c..a977d73509 100644 --- a/modules/core/include/visp3/core/vpImageFilter.h +++ b/modules/core/include/visp3/core/vpImageFilter.h @@ -78,6 +78,9 @@ class VISP_EXPORT vpImageFilter CANNY_COUNT_BACKEND = 2 //! Number of supported backends } vpCannyBackendType; + static std::string vpCannyBackendTypeList(const std::string &pref = "<", const std::string &sep = " , ", + const std::string &suf = ">"); + static std::string vpCannyBackendTypeToString(const vpCannyBackendType &type); static vpCannyBackendType vpCannyBackendTypeFromString(const std::string &name); @@ -90,6 +93,9 @@ class VISP_EXPORT vpImageFilter CANNY_COUNT_FILTERING = 2 //! Number of supported backends } vpCannyFilteringAndGradientType; + static std::string vpCannyFilteringAndGradientTypeList(const std::string &pref = "<", const std::string &sep = " , ", + const std::string &suf = ">"); + static std::string vpCannyFilteringAndGradientTypeToString(const vpCannyFilteringAndGradientType &type); static vpCannyFilteringAndGradientType vpCannyFilteringAndGradientTypeFromString(const std::string &name); diff --git a/modules/core/src/image/vpImageFilter.cpp b/modules/core/src/image/vpImageFilter.cpp index f2fc84a2da..ad33a28fd3 100644 --- a/modules/core/src/image/vpImageFilter.cpp +++ b/modules/core/src/image/vpImageFilter.cpp @@ -38,6 +38,29 @@ #include #include +/** + * \brief Get the list of available vpCannyBackendType. + * + * \param[in] pref The prefix of the list. + * \param[in] sep The separator between two elements of the list. + * \param[in] suf The suffix of the list. + * \return std::string The list of available items. + */ +std::string vpImageFilter::vpCannyBackendTypeList(const std::string &pref, const std::string &sep, + const std::string &suf) +{ + std::string list(pref); + for (unsigned int i = 0; i < vpCannyBackendType::CANNY_COUNT_BACKEND - 1; i++) { + vpCannyBackendType type = (vpCannyBackendType)i; + list += vpCannyBackendTypeToString(type); + list += sep; + } + vpCannyBackendType type = (vpCannyBackendType)(vpCannyBackendType::CANNY_COUNT_BACKEND - 1); + list += vpCannyBackendTypeToString(type); + list += suf; + return list; +} + /** * \brief Cast a \b vpImageFilter::vpCannyBackendTypeToString into a string, to know its name. * @@ -83,6 +106,29 @@ vpImageFilter::vpCannyBackendType vpImageFilter::vpCannyBackendTypeFromString(co return type; } +/** + * \brief Get the list of available vpCannyFilteringAndGradientType. + * + * \param[in] pref The prefix of the list. + * \param[in] sep The separator between two elements of the list. + * \param[in] suf The suffix of the list. + * \return std::string The list of available items. + */ +std::string vpImageFilter::vpCannyFilteringAndGradientTypeList(const std::string &pref, const std::string &sep, + const std::string &suf) +{ + std::string list(pref); + for (unsigned int i = 0; i < vpCannyFilteringAndGradientType::CANNY_COUNT_FILTERING - 1; i++) { + vpCannyFilteringAndGradientType type = (vpCannyFilteringAndGradientType)i; + list += vpCannyFilteringAndGradientTypeToString(type); + list += sep; + } + vpCannyFilteringAndGradientType type = (vpCannyFilteringAndGradientType)(CANNY_COUNT_FILTERING - 1); + list += vpCannyFilteringAndGradientTypeToString(type); + list += suf; + return list; +} + /** * \brief Cast a \b vpImageFilter::vpCannyFilteringAndGradientType into a string, to know its name. * diff --git a/tutorial/image/tutorial-canny.cpp b/tutorial/image/tutorial-canny.cpp index 6e133f5da9..e75e6c16cb 100644 --- a/tutorial/image/tutorial-canny.cpp +++ b/tutorial/image/tutorial-canny.cpp @@ -124,6 +124,7 @@ void usage(const std::string &softName) << std::endl; std::cout << "\t-f, --filter" << std::endl << "\t\tPermits to choose the type of filter to apply to compute the gradient." + << "\t\tAvailable values = " << vpImageFilter::vpCannyFilteringAndGradientTypeList() << std::endl << std::endl; std::cout << "\t-r, --ratio" << std::endl << "\t\tPermits to set the lower and upper thresholds ratio of the vpCanny class." @@ -132,6 +133,7 @@ void usage(const std::string &softName) << std::endl; std::cout << "\t-b, --backend" << std::endl << "\t\tPermits to use the vpImageFilter::canny method for comparison." + << "\t\tAvailable values = " << vpImageFilter::vpCannyBackendTypeList() << std::endl << std::endl; std::cout << "\t-h, --help" << std::endl << "\t\tPermits to display the different arguments this software handles."