Reading the image file
Reading the images file is also pretty straightforward; we read the header records and sequentially read the images. From the header records, we get the total number of images in the file and the image size. Then, we define the OpenCV matrix object that has a corresponding size and type – the one channel image with the underlying byte CV_8UC1 type. We read images from disk in a loop directly to the OpenCV matrix object by passing a pointer, which is returned by the data object variable, to the stream read function. The size of the data we need to read is determined by calling the cv::Mat::size() function, followed by the call to the area function. Then, we use the convertTo OpenCV function to convert an image from ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access