[英]The type of the element stored in Mat structure of OpenCV
是否存在一些可用於確定OpenCV的Mat結構中存儲的元素的數據類型的方法(例如uchar,cv :: Vec3b ...)?
您可以使用cv::Mat::type()
確定存儲在cv::Mat
的像素的數據類型。
可以如下確定類型:
int type = mat.type();
if(type == CV_8UC1)
unsigned char* ptr = mat.ptr<unsigned char>();
else if(type == CV_8UC3)
cv::Vec3b* ptr = mat.ptr<cv::Vec3b>();
else if(type == CV_16UC3)
unsigned short* ptr = mat.ptr<unsigned short>();
else if(type == CV_16UC3)
cv::Vec3w* ptr = mat.ptr<cv::Vec3w>();
else if(type == CV_32FC1)
float* ptr = mat.ptr<float>();
else if(type == CV_32FC3)
cv::Vec3f* ptr = mat.ptr<cv::Vec3f>();
else
printf("Unknown type\n");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.