图像的载入、显示和输出到文件
OpenCV的命名空间
OpenCV中的C++类和函数都是定义在命名空间cv以内的。web
图像的载入: imread() 函数
原型:svg
Mat imread(const string& filename, int flags = 1);
- filename : 图像名称
- flags: 载入标识,指定了一个加载图像的颜色类型
CV_LOAD_IMAGE_GRAYSCALE – 0 : 将图像转换成灰度再返回
CV_LOAD_IMAGE_COLOR – 1 : 默认值,彩色图像
图像的显示:imshow() 函数
void imshow(const string& winname, InputArray mat);
建立窗口:namedWindow() 函数
void namedWindow(const string& winname, int flags = WINDOW_AUTOSIZE);
- WINDOW_AUTOSIZE : 窗口大小自动调整以适应显示图像,切用户不可手动改变窗口大小
- WINDOW_NORMAL : 窗口大小能够被用户改变
- WINDOW_OPENGL : 窗口支持OpenGL
删除窗口:函数
destroyWindow(const string & winname);
destroyAllWindows();