0

I'm creating a module that should accept an OpenCV matrix. I'm new to OpenCV and effectively not using the library, so maybe my question is naive.

I would like to have a function that accepts OpenCV types as widely as possible (cv::Mat, cv::Mat_<T>, cv::Matx<T,M,N>), however I need to know the underlying value-type at compile-time.

My question is: Is the value-type known at compile-time for cv::Mat? It seems that one can cast, and that one can extract it at run-time. But can it be found at compile-time? My guess is no, because the underlying value-type is non-standard. But if it is known, how do I get it?

This does not seem to work:

template <class T>
inline void foo(const T& bar)
{
    using value_type = typename std::decay_t<T>::value_type;
}
Tom de Geus
  • 5,625
  • 2
  • 33
  • 77
  • 1
    You can't find the type of `cv::Mat` at compile time. For `cv::Mat_` you can, it's specified by the template parameter, and you can't store any other type of data in it. Not sure what you mean by `cv::Mat_`... maybe you mixed that up with the `Matx` template? – Dan Mašek May 20 '20 at 16:51
  • 1
    @DanMašek Thanks! Yeah, I guess I meant `Matx`, I'll edit. But in general the question is if I template brutally (like in now in the question), how do I get the value-type? – Tom de Geus May 20 '20 at 16:52

0 Answers0