http://blog.csdn.net/poem_qianmo/article/details/20537737
Using the OpenCV namespace, start with standard
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> using namespace CV;
Storing images
Mat -type storage image data
Reading images
Mat imread (const string& filename, Intflags=1);
Intflags=1 represents a three-channel color image = 0 Represents a grayscale image
Create window
Winname window name flags can control whether the window is changed by default, depending on the image size
Show
void Imshow (const string& winname, Inputarray mat);
Inputarray can be understood as mat
Time out
Waitkey (int N)
Wait for n milliseconds and press any key to continue
Save to File
BOOL Imwrite (const string& filename,inputarray img, const vector<int>& params=vector<int> ());
Practice
#include <opencv2/core/core.hpp> #include
Postscript:
Before opencv2.0, only CV, such as Cvmat,iplimage,cvloadimage, and so on, and Cvmat is a struct, each call must be memory allocation, Cvmat *a = Cvcreatemat (),
Memory is freed after it is exhausted. Opencv2.0 after the addition of the C + + interface Mat Matrix, Cv::mat is a class (class), use is not allocated memory, run out and do not release, the corresponding reading picture is imread and so on.
So now we don't have to start with CVS.
- Select Roi,rect four parameters are (x, y) coordinates, the third parameter is the width, the fourth parameter is the height
- Mat ROI (Mat,rect (0,0,2,1));
- cout<<roi<<endl;
The third lesson of the Mao Nebula Blog