Ask Your Question
2

'channel_type': is not a member of 'cv::DataType<_Tp>'

asked 2018-01-21 05:56:36 -0600

boazgarty gravatar image

Hi,

Im using opencv 3.4.0 on windows and getting the error: 'channel_type': is not a member of 'cv::DataType<_Tp>' how can I fixed it?

edit retag flag offensive close merge delete

Comments

where do you get that error ? (your own code ? some opencv library ?)

any chance, you're using opencv_contrib modules, and forgot to update those to latest version ?

berak gravatar imageberak ( 2018-01-21 05:58:13 -0600 )edit

Im getting the error from opencv2/core/mat.hpp actually there are 2 errors both in mat.hpp file

first: 'channel_type': unknown override specifier second: channel_type': is not a member of 'cv::DataType<_Tp>

using opencv_contrib version 3.4.0 downloaded from: https://github.com/opencv/opencv_cont...

I've seen this https://github.com/opencv/opencv/issu... but still have the same errors.

boazgarty gravatar imageboazgarty ( 2018-01-21 06:15:27 -0600 )edit
1

again, if using opencv_contrib modules, get exactly the same version, and rebuild.

(yes, there were changes to the DataType / traits code, and it looks like a synchronization problem from here)

berak gravatar imageberak ( 2018-01-21 06:27:08 -0600 )edit

Hey there,

So I'm having same problem as described by boazgarty.

Following berak advice, i recompiled openCV 3.4 (deleted all previews folders, re-downloaded from source both openCV master and contrib master, deleted cmake cache). Still got the same error, bellow a copy of visual studio error:

So i'm able to run other projects under 3.4 without problems, and this specific project I'm able to run if I downgrade to a previous 3.2 version on this same machine...

Any suggestions ?

Thanks.

pcosta gravatar imagepcosta ( 2018-02-17 11:01:34 -0600 )edit

@pcosta, if you have a question or comment, don't post an answer instead. (better even -- ask your own question !)

also, i removed your screenshot, those are never helpful. please edit again, and insert a text version of the errors you get. thank you !

berak gravatar imageberak ( 2018-02-17 11:28:06 -0600 )edit

About posting an answer instead of comment or question, my bad and wasn't paying attention, thanks for the correction. Since the error is the same, do I really have to open a new question?

I took the screen shot because of formatting... here his the text:

'depth': is not a member of 'cv::DataType<_Tp>' in file traits.hpp  
'cv::Mat::channels': non-standard syntax; use '&' to create a pointer to member in file mat.inl.hpp
'*': illegal, right operand has type 'int (__cdecl cv::Mat::* )(void) const' in mat.inl.hpp
'depth': undeclared identifier  in traits.hpp
'channels': is not a member of 'cv::DataType<_Tp>' in file mat.inl.hpp

Any advice?

pcosta gravatar imagepcosta ( 2018-02-17 12:41:42 -0600 )edit

"this specific project" -- please clarify, is the error coming from the opencv libs (like in the question above), or from your own code ?

(if you find any instance of DataType in that project -- do us a favour , and ask a new question, same error msg, but different situation)

berak gravatar imageberak ( 2018-02-17 12:52:06 -0600 )edit

The errors are in traits.hpp and mat.inl.hpp I have no instance of DataType in my project files, but if you want i can still open a new question. I said this specific project, because so far this is the only one that I used recently that causes this, but this same project runs on a 3.2 contrib compiled openCV.

pcosta gravatar imagepcosta ( 2018-02-17 13:18:02 -0600 )edit

"The errors are in traits.hpp" -- unfortunately, given how templates work, this is not the cause but the effect.

"his same project runs on a 3.2 contrib" -- as said before, there were changes to the DataType thing, it was made more strict. there is no more a general implementation, that has a "type" member, you have to come up with our own template specialization for anything "new".

unfortunately, you don't give enough clues, where, and why that error happens. dig in more !

berak gravatar imageberak ( 2018-02-17 13:24:33 -0600 )edit

please clarify, again : -- do the opencv libs build ? (but not your project ?)

you also want to look into, where the DataType is actually used, it might be a weird case in FileStorage or such (might even happen, if your code is not using that directly)

berak gravatar imageberak ( 2018-02-17 13:29:07 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
3

answered 2020-03-05 11:54:23 -0600

jonathan gravatar image

updated 2020-03-06 11:21:20 -0600

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. 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

The invalid class shows up in the last line. In this example, the error in MyCode.cpp 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.

edit flag offensive delete link more

Comments

Thank you for a helpful answer. I have the same issue, wherecv::Mat_<std::uint32_t> is not implemented. However, it works with OpenCV 3.2.0 on Windows x86 using GCC 7.1. In 3.2.0, the non-specialized definition of cv::DataType<std::uint32_t> works out to CV_USRTYPE1 and just happens to allocate 4 bytes for each element. Post 3.3.0, this default implementation was removed by an ifdef on OPENCV_TRAITS_ENABLE_DEPRECATED. So, while it might not have been intended, using a 32-bit unsigned int worked up until 3.3.1

gibbontrothy gravatar imagegibbontrothy ( 2020-04-01 22:39:26 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2018-01-21 05:56:36 -0600

Seen: 8,697 times

Last updated: Mar 06 '20