questions about cvtypes CV_32S, CV_16F etc.

asked 2020-04-20 03:04:37 -0600

xxxlucodes gravatar image

updated 2020-04-20 03:24:47 -0600

hello, everyone, I'm new to opencv. While I'm proceeding with opencv tutorials, I have lots of confusions about cvtypes such as CV_32S, and CV_16F. Literally I know the meanings of these types, but I'am not sure about the criteria by which I can make choice to choose one of them in specified situation.

for example, I have encountered a problem when dealing with the tutorial code "imageSegmentaion.cpp" in the part "Image Segmentation with Distance Transofrm and Watershed Algorithm. The problem is showed below:


terminate called after throwing an instance of 'cv::Exception' what(): OpenCV(4.3.0-pre) /home/ehuman/working_cv/opencv-master/modules/highgui/src/precomp.hpp:137: error: (-215:Assertion failed) src_depth != CV_16F && src_depth != CV_32S in function 'convertToShow'

Aborted (core dumped)


Although I can solve the problem by manually changing the type of the image from CV_32S to CV_32F before the function "imshow" according to instructions from website. it's still not clear for me that why I have to do this? In what situation should I use CV_32S? Why there's an assertion described above in function 'convertToShow' ? Could anyone give me some explanations about those types and their usages as well as reasons behind it ? links to specified detailed description are also useful to me. Thank you very much!

edit retag flag offensive close merge delete

Comments

1

Have a look at the doc for imshow. There are mention of expected ranges and expected data type.

Don't use CV_16F. It has been introduced for Deep Learning and there are no support of this type elsewhere.

Eduardo gravatar imageEduardo ( 2020-04-20 05:24:17 -0600 )edit

thank you :)

xxxlucodes gravatar imagexxxlucodes ( 2020-04-21 02:35:48 -0600 )edit