# Revision history [back]

### How can I get the value type for a cvMat?

I'm trying to get the value type for an element of my matrix and avoid having to hardcode it in order to maximize portability and compatibility with possible future changes.

The obvious way for me would seem to use TypeDev::value_type as defined in traits.cpp (located here: https://github.com/opencv/opencv/blob/master/modules/core/include/opencv2/core/traits.hpp)

Unfortunately the value_type member is defined as private, which I don't quite understand. Is there another way to access this?

To clarify with an example, I'm trying to do something like this:

using Type16S = cv::TypeDepth<CV_16S>::value_type;


In order to use the new type defenition in such a way:

cv::Mat matrix(10,10, CV_16S)
Type16S* pointer = matrix.ptr<Type16S>(1);

 2 None berak 32993 ●7 ●81 ●312

### How can I get the value type for a cvMat?

I'm trying to get the value type for an element of my matrix and avoid having to hardcode it in order to maximize portability and compatibility with possible future changes.

The obvious way for me would seem to use TypeDev::value_type as defined in traits.cpp (located here: https://github.com/opencv/opencv/blob/master/modules/core/include/opencv2/core/traits.hpp)

Unfortunately the value_type member is defined as private, which I don't quite understand. Is there another way to access this?

To clarify with an example, I'm trying to do something like this:

using Type16S = cv::TypeDepth<CV_16S>::value_type;


In order to use the new type defenition in such a way:

cv::Mat matrix(10,10, CV_16S)
Type16S* pointer = matrix.ptr<Type16S>(1);

 3 None berak 32993 ●7 ●81 ●312

### How can I get the value type for a cvMat?cv::Mat?

I'm trying to get the value type for an element of my matrix and avoid having to hardcode it in order to maximize portability and compatibility with possible future changes.

The obvious way for me would seem to use TypeDev::value_type TypeDepth::value_type as defined in traits.cpp (located here: https://github.com/opencv/opencv/blob/master/modules/core/include/opencv2/core/traits.hpp)

Unfortunately the value_type member is defined as private, which I don't quite understand. Is there another way to access this?

To clarify with an example, I'm trying to do something like this:

using Type16S = cv::TypeDepth<CV_16S>::value_type;


In order to use the new type defenition in such a way:

cv::Mat matrix(10,10, CV_16S)
Type16S* pointer = matrix.ptr<Type16S>(1);