opencv保存内存位图数据到文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <opencv2/opencv.hpp>
 
#ifdef _DEBUG
#pragma comment(lib, "opencv_highgui249d.lib")
#pragma comment(lib, "opencv_core249d.lib")
#pragma comment(lib, "opencv_calib3d249d.lib")
#pragma comment(lib, "opencv_imgproc249d.lib")
#else
#pragma comment(lib, "opencv_highgui249.lib")
#pragma comment(lib, "opencv_core249.lib")
#pragma comment(lib, "opencv_calib3d249.lib")
#pragma comment(lib, "opencv_imgproc249.lib")
#endif
 
Mat mat(iHeight, iWidth, CV_8UC3, pData);
Mat yuvMat;
cvtColor(mat, yuvMat, CV_RGB2YUV);
imwrite(path, yuvMat);