主要讲解:imread imshow namedWindow imwrite 函数
1、关于opencv的命名空间
opencv中的C++类或者函数类都是定义在命名空间cv中的,两种方法可以访问,一种是在代码开头位置加上using namespace cv;
另外一种是在使用函数时加cv::.
2、关于Mat类型
Mat类是用于保存图像以及其他矩阵数据的数据结构。
3、图像的读入与显示
3.1 imread函数
Loads an image from a file.
-
C++: Mat imread(const String& filename, int flags=IMREAD_COLOR )
-
Python: cv2.imread(filename[, flags]) → retval
-
C: IplImage* cvLoadImage(const char* filename, int iscolor=CV_LOAD_IMAGE_COLOR )
-
C: CvMat* cvLoadImageM(const char* filename, int iscolor=CV_LOAD_IMAGE_COLOR )
-
Parameters: - filename – Name of file to be loaded.
- flags –
Flags specifying the color type of a loaded image:
- CV_LOAD_IMAGE_ANYDEPTH - If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
- CV_LOAD_IMAGE_COLOR - If set, always convert image to the color one
- CV_LOAD_IMAGE_GRAYSCALE - If set, always convert image to the grayscale one