類型 | C | C++ |
---|---|---|
頭文件 | #include <opencv/cv.h> #include <opencv/highgui.h> … |
#include <opencv2/opencv.hpp> #include <opencv2/highgui/highgui.hpp> … |
主要數據類型 | IplImage *img | Mat img |
顯示 | cvShowImage(“name”, img); | imshow(“name”, img); |
等待按鍵 | cvWaitKey(1); | waitKey(1); |
數據轉換
IplImage -> 原始數組數據:
- IplImage* img = cvLoadImage(imagename);
- IplImage* img = cvCreateImage(cvSize(int width, int height), int depth, int channels);
- uint8_t *data = img->imageDataOrigin; //未對齊的原始圖像數據
- uint8_t *data = img->imageData; //已對齊的圖像數據
原始數組數據 -> IplImage :
- IplImage* img = cvCreateImageHeader(cvSize(width,height),depth,channels);
- cvSetData(img, (uint8_t *)data, linesize);