Home >Backend Development >C++ >How to Get Started with OpenCV 2.4 on Windows 7 Using MinGW?
Getting Started with OpenCV 2.4 and MinGW on Windows 7
Installation:
OpenCV 2.4.3:
MinGW Compiler Suite:
Sample Code:
Create a file named 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; }
Compilation and Execution:
Compile the code using the command:
g++ -I"C:\opencv\build\include" -L"C:\opencv\build\x86\mingw\lib" loadimg.cpp -lopencv_core243 -lopencv_highgui243 -o loadimg
Execute the program:
loadimg
This will display the loaded image in a window.
Next Steps:
The above is the detailed content of How to Get Started with OpenCV 2.4 on Windows 7 Using MinGW?. For more information, please follow other related articles on the PHP Chinese website!