关于opencv中Mat类型转换的一个问题

论坛 期权论坛 脚本     
匿名技术用户   2021-1-5 11:02   34   0

在Opencv的Mat转换函数converto(),当将<unsigned int>或<unsigned >类型进行转换时,总是会提示“opencv error: assertion failed (func != 0) in unknown function, file..\..\..\src\opencv\modules\core\src\convert.cpp”

示例:

Mat a = Mat_<unsigned int>(10,3);//或Mat a = Mat_<unsigned> (10,3)

Mat_<float> b;

a.ConvertTo(b, CV_32F);

cout<<"a type"<<endl<<a.depth()<<endl<<"b type"<<endl<<b.depth()<<endl;

运行时会提示上述错误;


正确示例

Mat a = Mat_<unsigned short> (10, 3);//或Mat a = Mat_<unsigned char> (10, 3)

Mat_<float> b;

a.ConvertTo(b, CV_32F);

cout<<"a type"<<endl<<a.depth()<<endl<<"b type"<<endl<<b.depth()<<endl;

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP