Skip to content

Commit

Permalink
[CORPS] Added a method to know the list of available backend and filt…
Browse files Browse the repository at this point in the history
…ering types for Canny
  • Loading branch information
rlagneau committed Oct 19, 2023
1 parent fc14b32 commit adedf60
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/core/include/visp3/core/vpImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
46 changes: 46 additions & 0 deletions modules/core/src/image/vpImageFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@
#include <visp3/core/vpIoTools.h>
#include <visp3/core/vpRGBa.h>

/**
* \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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
2 changes: 2 additions & 0 deletions tutorial/image/tutorial-canny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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."
Expand Down

0 comments on commit adedf60

Please sign in to comment.