Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should CV_16F be supported? #20279

Closed
pstricks-fans opened this issue Jun 19, 2021 · 1 comment · Fixed by #20321
Closed

Should CV_16F be supported? #20279

pstricks-fans opened this issue Jun 19, 2021 · 1 comment · Fixed by #20321

Comments

@pstricks-fans
Copy link

pstricks-fans commented Jun 19, 2021

#include <opencv2/opencv.hpp>
using namespace cv;

int main()
{    
    Mat mat = Mat::zeros(3, 3, CV_16F); // But it is just fine for CV_32F, weird?
    FileStorage fs("file.yml", FileStorage::WRITE);
    fs << "Mat" << mat;
    fs.release();
    return 0;
}

OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(4.5.1) Error: Assertion failed (depth >=0 && depth <= CV_64F)
in typeSymbol, file C:\opencv-4.5.1\modules\core\src\persistence.cpp,
line 146

Taken from the interface.h

#define CV_8U   0
#define CV_8S   1
#define CV_16U  2
#define CV_16S  3
#define CV_32S  4
#define CV_32F  5
#define CV_64F  6
#define CV_16F  7

and the line 146 which is

CV_Assert(depth >=0 && depth <= CV_64F);

CV_16F is not supported. Should it be supported?


relates #12463

@pstricks-fans
Copy link
Author

Because the type is not well ordered --- CV_16F comes after CV_64F --- so I think we should define CV_DEPTH as follows to avoid using hard-coded CV_64F in the entire libraries.

#define CV_8U   0
#define CV_8S   1
#define CV_16U  2
#define CV_16S  3
#define CV_32S  4
#define CV_32F  5
#define CV_64F  6
#define CV_16F  7
#define CV_DEPTH CV_16F // just edit this line if another type is added in the future


CV_Assert(depth >=0 && depth <= CV_DEPTH); // Replace all the hard-coded CV-64F in the entire libraries with CV_DEPTH.

It is just an idea, ignore it if it does not make sense. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants