其他分享
首页 > 其他分享> > NCNN和OPENCV 数据互相转换

NCNN和OPENCV 数据互相转换

作者:互联网

ncnn::Mat 转 cv::Mat

ncnn::Mat in = ncnn::Mat::from_pixels(a.data, ncnn::Mat::PIXEL_BGR2RGB, a.cols, a.rows);

cv::Mat 转ncnn::Mat

//You may need to call in.substract_mean_normalize() first to scale values from 0..1 to 0..255

// ncnn::Mat in(w, h, 3);
cv::Mat a(in.h, in.w, CV_8UC3);
in.to_pixels(a.data, ncnn::Mat::PIXEL_BGR2RGB);

参考:use ncnn with opencv · Tencent/ncnn Wiki · GitHub

标签:转换,Mat,PIXEL,OPENCV,NCNN,BGR2RGB,data,cv,ncnn
来源: https://blog.csdn.net/qq_38806886/article/details/123206982