OpenCV cung cấp hàm imwrite() để lưu ảnh vào file. Phần mở rộng file đại diện cho định dạng ảnh.
Cú pháp
imwrite("Duong_dan/Ten_anh_voi_duoi_mo_rong", Source_Matrix)
Ví dụ
#include <iostream>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
int main(int argc, const char** argv) {
Mat myImage;
myImage = imread("lena.png");
imwrite("lakshmi.jpg", myImage);
waitKey(0);
destroyWindow("MyWindow");
cout << "Anh da duoc luu thanh cong...";
return 0;
}
Kết quả
Anh da duoc luu thanh cong...