类型 | 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);