Loading, displaying and outputting images to files
OpenCV namespace
C++ classes and functions in OpenCV are defined within the namespace cv.
Image loading: imread() function
prototype:
Mat imread(const string& filename, int flags = 1);
- filename : image name
- flags : Load flag, specifying the color type of a loaded image
CV_LOAD_IMAGE_GRAYSCALE - 0: Convert the image to grayscale and then return
CV_LOAD_IMAGE_COLOR - 1: Default value, color image
Image display: imshow() function
void imshow(const string& winname, InputArray mat);
- winname : The name of the window identification that needs to be displayed
Create window: namedWindow() function
void namedWindow(const string& winname, int flags = WINDOW_AUTOSIZE);
- WINDOW_AUTOSIZE : The window size is automatically adjusted to fit the displayed image. Users cannot manually change the window size.
- WINDOW_NORMAL : window size can be changed by the user
- WINDOW_OPENGL : The window supports OpenGL
Delete window:
destroyWindow(const string & winname);
destroyAllWindows();