#include<iostream>
#include<string>
#include"opencv2/opencv.hpp"
using namespace std;
using namespace cv ;
int main(){
string filepath = "1.jpg" ;
Mat img = imread( filepath, 0 ) ; // the parameter 0?, if 1 reserve the original image?
cout << "img rows is " << img.rows << " img cols is " << img.cols << endl ;
return 1 ;
#include<string>
#include"opencv2/opencv.hpp"
using namespace std;
using namespace cv ;
int main(){
string filepath = "1.jpg" ;
Mat img = imread( filepath, 0 ) ; // the parameter 0?, if 1 reserve the original image?
cout << "img rows is " << img.rows << " img cols is " << img.cols << endl ;
return 1 ;
}
###name the above file as try.cpp, then use the following command to compile the code.
g++ try.cpp -o try -I /usr/loca/include -L /usr/local/lib -lopencv_imgproc -lopencv_highgui -lopencv_core -lopencv_imgcodecs
####note For openCV 3.X you need to add library imgcodecs to project.