Getting Started: OpenCV 2.4 and MinGW on Windows 7 with a Sample Code
Installing OpenCV 2.4
Installing MinGW
Writing a Sample Code
Create a new C file (e.g., loadimg.cpp) with the following code:
#include "opencv2/highgui/highgui.hpp" #include <iostream> using namespace cv; using namespace std; int main(int argc, char** argv) { Mat im = imread(argc == 2 ? argv[1] : "lena.jpg", 1); if (im.empty()) { cout << "Cannot open image!" << endl; return -1; } imshow("image", im); waitKey(0); return 0; }
Compile the code:
g++ -I"C:\opencv\build\include" -L"C:\opencv\build\x86\mingw\lib" loadimg.cpp -lopencv_core243 -lopencv_highgui243 -o loadimg
Next Steps
The above is the detailed content of How to Set Up OpenCV 2.4 and MinGW on Windows 7 for Image Processing?. For more information, please follow other related articles on the PHP Chinese website!