1.opencv显示图片
#include#include using namespace std; using namespace cv; int main() { Mat srcimg=imread("E:/OpenCV_textPictures/textpicture01.jpg",1); if (srcimg.empty()) return -1; namedWindow("Example1", WINDOW_AUTOSIZE); imshow("Example1", srcimg); waitKey(0); }
imread函数
原型:Mat imread( const String& filename, int flags = IMREAD_COLOR );
参数1:const string&类型的filename,指我们需要载入图片路径名。
参数2:int类型的flags,为载入标识,指定一个加载图像的颜色类型,默认值为1。
CV_LOAD_IMAGE_GRAYSCALE——等价取值为0,返回灰色图
CV_LOAD_IMAGE_COLOR——等价取值为1,返回彩色图像
如果输入有冲突的标志,将采用较小的数字值
namedWindow函数
原型:void nameWindow(const string& winname,int flags = WINDOW_AUTOSIZE) ;
参数1:新建的窗口的名称。自己随便取。
参数2:窗口的标识,一般默认为WINDOW_AUTOSIZE 。
WINDOW_AUTOSIZE 窗口大小自动适应图片大小,并且不可手动更改。
WINDOW_NORMAL 用户可以改变这个窗口大小
WINDOW_OPENGL 窗口创建的时候会支持OpenGL
waiKey函数:暂停并等待键盘事件
waitKey(0):程序无限等待知道有键被按下
waitKey(30):等待30ms时释放



