在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;