虽然之前已经在一定程度上接触、学习并应用了 OpenCV,但是依然想系统地对这些内容重新学习和整理。
Mat imread(const String& filename, int flags = IMREAD_COLOR) This function loads an image from the specified file and return is as a Mat object. If the function cannot read the file, it will return an empty Mat object.
filename - You have to give the relative or absolute path of an image file. If you are giving the relative path, it should be relative to your cpp file. jpeg, jpg, bmp, png, tiff and tif image file types are always supported. Other image file types are supported depending on your platform and installed codecs.flags - There are several possible values for the flag argument. In the above program, I did not pass any value to this argument such that default IMREAD_COLOR argument will be used. IMREAD_UNCHANGED - The image will be loaded as it is. If you want to get the alpha channel in your input image (if it is available), you have to use this flag.IMREAD_GRAYSCALE - The image will be load as a gray-scale image (i.e. - Single channel image, Black and white image)IMREAD_COLOR - The image will be loaded as a BGR image (i.e. - 3 channel image, color image)void namedWindow(const String& winname, int flags = WINDOW_AUTOSIZE) This function creates a window which can be used to place images and track bars. If a window already exists with the given name, this function does nothing.
winname - Name of the window. That name will display in the title bar of the newly created window. This name is also the identifier for this window and it will be used in the later OpenCV function calls to identify the window.flags - Determine the size of the window. In the above program, I did not pass any value to this argument such that default WINDOW_AUTOSIZE argument will be used. WINDOW_AUTOSIZE - User cannot resize the window. Image will be displayed in its original size.WINDOW_NORMAL- User can resize the window.void imshow(const String& winname, InputArray mat) This function shows the image in a window specified by winname. If the window is created with WINDOW_AUTOSIZE flag, image will be displayed in its original size. Otherwise image may be scaled to the size of the window. If the window has not been created by calling to namedWindow() function, this function will create a window with the WINDOW_AUTOSIZE flag. This function call should be followed by waitKey(int) function call in order to provide sufficient time to paint and display the image in the window for the specified time duration in milliseconds. If you do not call waitKey(int) function, the image will not be displayed in the window.
winname - Name of the window which created by namedWindow() function.mat - Mat object which holds the image转载于:https://www.cnblogs.com/zdfffg/p/11551264.html