Syntax:
C++: Mat imread(const string& filename, int flags=1 )
Parameters:
filename – Name of file to be loaded.
flags –Flags specifying the color type of a loaded image:-
CV_LOAD_IMAGE_ANYDEPTH - If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
CV_LOAD_IMAGE_COLOR - If set, always convert image to the color one
CV_LOAD_IMAGE_GRAYSCALE - If set, always convert image to the grayscale one
>0 Return a 3-channel color image.
=0 Return a grayscale image.
<0 Return the loaded image as is (with alpha channel).
Note the Location of the image is:
C:\Users\arjun\Desktop\a.jpg where "opencv-logo.jpg" .
( Here we append additional "\" after each file or folder name.)
Image Formats supported by OpenCV:
C++: Mat imread(const string& filename, int flags=1 )
Parameters:
filename – Name of file to be loaded.
flags –Flags specifying the color type of a loaded image:-
CV_LOAD_IMAGE_ANYDEPTH - If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
CV_LOAD_IMAGE_COLOR - If set, always convert image to the color one
CV_LOAD_IMAGE_GRAYSCALE - If set, always convert image to the grayscale one
>0 Return a 3-channel color image.
=0 Return a grayscale image.
<0 Return the loaded image as is (with alpha channel).
//OpenCv C++ Example of Reading Image
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "iostream"
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
Mat image1;
// Read the file
image1 = imread("C:\\Users\\arjun\\Desktop\\opencv-logo.jpg",CV_LOAD_IMAGE_COLOR);
// Check for invalid input
if(! image1.data )
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
//Dispay the Image in the window
namedWindow("Image1");
imshow("Image1",image1);
waitKey(0);
}
Note the Location of the image is:
C:\Users\arjun\Desktop\a.jpg where "opencv-logo.jpg" .
( Here we append additional "\" after each file or folder name.)
Image Formats supported by OpenCV:
| Windows bitmaps | *.bmp, *.dib |
| JPEG files | *.jpeg, *.jpg, *.jpe |
| JPEG 2000 files | *.jp2 |
| Portable Network Graphics | *.png |
| Portable image format | *.pbm, *.pgm, *.ppm |
| Sun rasters | *.sr, *.ras |
| TIFF files | *.tiff, *.tif |
No comments:
Post a Comment