January 2018
Intermediate to advanced
486 pages
11h 28m
English
Now that we have learned all about the Mat class in OpenCV, we can move on to learn how to read images and fill a Mat class with an image to further process it. As you have seen briefly in the previous chapters, the imread function can be used to read images from the disk. Here's an example:
Mat image = imread("c:/dev/test.jpg", IMREAD_GRAYSCALE | IMREAD_IGNORE_ORIENTATION);
imread simply takes a C++ std::string class as the first parameter and an ImreadModes flag as the second parameter. If for any reason the image cannot be read, then it returns an empty Mat class (data == NULL), otherwise, it returns a Mat class filled with the image pixels with the type and color specified in the second parameter. Depending ...