http://blog.163.com/yuyang_tech/blog/static/21605008320132642254689/
一個小例子:
#include "stdafx.h"
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int _tmain(int argc, _TCHAR* argv[])//
{
//讀入圖像
const char* imagename = "lena.jpg";
Mat img = imread(imagename);
//如果讀入圖像失敗
if(img.empty()){
fprintf(stderr, "Can not load image %s\n", imagename);
return -1;
}
//創建及復制圖像
Mat img2;
img2 = img.clone();
//顯示圖像
//namedWindow("image",1);//創建窗口
imshow("image", img2);
//保存圖像
imwrite("lena2.jpg",img2);
//此函數等待按鍵,按鍵盤任意鍵就返回
waitKey();
return 0;
}
〉
namedWindow()不是必須,imshow可自動創建窗口。
c、c++混雜吧!!!!!