Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This happens when you declare a cv::Mat_<> with an unsupported type.

OpenCV only 'instantiates' the template code for a few types of Mat_. Unfortunately since it's a template, the compiler error shows up in mat.hpp. Depending on your compiler, the next few lines of compiler output are more helpful. In Visual Studio for example, the actual problem codepoint appears 10 lines down:

1>C:\..\OpenCV.3.4.9.1\build\native\v142\x64\include\opencv2\core\mat.hpp(2209,37): error C2039: 'channel_type': is not a member of 'cv::DataType<_Tp>'
1>        with
1>        [
1>            _Tp=uint32_t
1>        ] (compiling source file MyCode.cpp)
1>C:\..\OpenCV.3.4.9.1\build\native\v142\x64\include\opencv2\core\mat.hpp(2209): message : see declaration of 'cv::DataType<_Tp>'
1>        with
1>        [
1>            _Tp=uint32_t
1>        ] (compiling source file MyCode.cpp)
1>C:\..\MyCode.cpp(123): message : see reference to class template instantiation 'cv::Mat_<uint32_t>' being compiled

(In VS, you can double-click the last line to take you to your code.) In this case, the critical error in MyCode.cpp looks like:

cv::Mat_<std::uint32_t> foo;  // compile fail

Changing to one of the supported types:

cv::Mat_<short> foo;

Or equivalently:

cv::Mat1w foo;

Resolved this particular issue.

This happens when you declare a cv::Mat_<> with an unsupported type.

OpenCV only 'instantiates' the template code for a few types of Mat_. Unfortunately since it's a template, the compiler error shows up reports in mat.hpp. mat.hpp, but actually is triggered by a bad type in your own code.

Depending on your compiler, the next few following lines of compiler output are may be more helpful. In Visual Studio for example, the actual problem codepoint appears is listed 10 lines down:

1>C:\..\OpenCV.3.4.9.1\build\native\v142\x64\include\opencv2\core\mat.hpp(2209,37): error C2039: 'channel_type': is not a member of 'cv::DataType<_Tp>'
1>        with
1>        [
1>            _Tp=uint32_t
1>        ] (compiling source file MyCode.cpp)
1>C:\..\OpenCV.3.4.9.1\build\native\v142\x64\include\opencv2\core\mat.hpp(2209): message : see declaration of 'cv::DataType<_Tp>'
1>        with
1>        [
1>            _Tp=uint32_t
1>        ] (compiling source file MyCode.cpp)
1>C:\..\MyCode.cpp(123): message : see reference to class template instantiation 'cv::Mat_<uint32_t>' being compiled

See the invalid class template instantiation in the final line. (In VS, you can double-click the last line to take you to your code.) In this case, the critical error in MyCode.cpp looks like:

cv::Mat_<std::uint32_t> foo;   // compile fail
fail, type not implemented

since Mat_ is not instantiated for uint32_t (aka unsigned int). Changing to one of the supported types:types

cv::Mat_<short> foo;
foo;           // or cv::Mat1s
cv::Mat_<unsigned short> foo;  // or cv::Mat1w
cv::Mat_<int> foo;             // or cv::Mat1i

Or equivalently:

cv::Mat1w foo;

Resolved .. would resolve this particular issue.

This happens when you declare a cv::Mat_<> with an unsupported type.

OpenCV only 'instantiates' the template for a few types of Mat_. Unfortunately since it's a template, the compiler error reports in mat.hpp, but actually is triggered by a bad type in your own code.

Check the compiler output after the error you posted, see if it references any of your code. Depending on your compiler, the following lines of output may be more helpful. compiler. In Visual Studio for example, the actual problem codepoint is listed 10 lines down:

1>C:\..\OpenCV.3.4.9.1\build\native\v142\x64\include\opencv2\core\mat.hpp(2209,37): error C2039: 'channel_type': is not a member of 'cv::DataType<_Tp>'
1>        with
1>        [
1>            _Tp=uint32_t
1>        ] (compiling source file MyCode.cpp)
1>C:\..\OpenCV.3.4.9.1\build\native\v142\x64\include\opencv2\core\mat.hpp(2209): message : see declaration of 'cv::DataType<_Tp>'
1>        with
1>        [
1>            _Tp=uint32_t
1>        ] (compiling source file MyCode.cpp)
1>C:\..\MyCode.cpp(123): message : see reference to class template instantiation 'cv::Mat_<uint32_t>' being compiled

See the The invalid class template instantiation shows up in the final last line. (In VS, you can double-click the last line to take you to your code.) In this case, the critical example, the error in MyCode.cpp looks looked like:

cv::Mat_<std::uint32_t> foo;   // fail, type not implemented

since Mat_ is not instantiated for uint32_t (aka unsigned int). Changing to one of the supported types

cv::Mat_<short> foo;           // or cv::Mat1s
cv::Mat_<unsigned short> foo;  // or cv::Mat1w
cv::Mat_<int> foo;             // or cv::Mat1i

.. would resolve this particular issue.