0

I need to access the element type T of an opencv matrix Mat_<\T> at compile time; Is there any way to do it? I am trying to achieve the following:

template <typename T> void foo(const T& mat) { // T::type* ptr = (T::type*)mat.data; } foo(Mat_<float>::ones(5,5)); 

The following declaration is not an option:

template <typename T> void foo(const Mat_<T>& mat); 

1 Answer 1

1

It looks like there is a typedef called value_type that does what you want.

template <typename T> void foo(const T& mat) { T::value_type* ptr = ...; } 
Sign up to request clarification or add additional context in comments.

2 Comments

Use the source Luke. :-)
Couldn't find the source either :( , I quickly looked for it as well. They used to have the header within the documentation of Mat_ once, I think they should put it back :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.