Preparation Link
Opencv Official Website: http://opencv.org/
Start: http://opencv.org/quickstart.html
Cmake: http://www.cmake.org/cmake/resources/software.html (build the corresponding static dynamic library solution based on your development platform)
Numpy: http://www.numpy.org/(not required, a scientific computing library for Python)
Eigen: http://eigen.tuxfamily.org/index.php? Title = main_page # download (optional, C ++ template library for linear algebra)
Cuda: https://developer.nvidia.com/cuda-downloads (not required, can take full advantage of your GPU performance to accelerate your algorithm)
Materials
Opencv2.4.8 for Windows
Visual Studio 2012
Cmake-3.0.0 Win32
Method 1: use pre-compiled library files
- Decompress the downloaded opencv2.4.8 file to the specified folder. (Take D: \ opencv248 as an example)
- Open vs2012 and create the project testopencv. (The following is the official test code)
1 #include <opencv2\core\core.hpp> 2 #include <opencv2\highgui\highgui.hpp> 3 #include <iostream> 4 5 using namespace cv; 6 using namespace std; 7 8 int main( int argc, char** argv ) 9 {10 if( argc != 2)11 {12 cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;13 return -1;14 }15 16 Mat image;17 image = imread(argv[1], IMREAD_COLOR); // Read the file18 19 if(! image.data ) // Check for invalid input20 {21 cout << "Could not open or find the image" << std::endl ;22 return -1;23 }24 25 namedWindow( "Display window", WINDOW_AUTOSIZE ); // Create a window for display.26 imshow( "Display window", image ); // Show our image inside it.27 28 waitKey(0); // Wait for a keystroke in the window29 return 0;30 }
- Open project Property Manager and create opencvdebug.
4. Double-click to open the opencvdebug attribute page.
(General-"Additional include directory = D: \ opencv248 \ opencv \ build \ include)
(Connector-additional library directory = D: \ opencv248 \ opencv \ build \ x86 \ vc11 \ Lib, vc11 corresponds to vs2012, other versions, and so on)
5. Save and compile. After compilation, run the prompt that the dll library (Runtime Library File) cannot be found ). You can add environment variables.
Add system variables (; Path = D: \ opencv248 \ opencv \ build \ x86 \ vc11 \ bin) (note the previous)
6. add runtime parameters (right-click Project-> properties-> Configure properties-> debug-> command parameters = D: \ myfile \ opencv \ shakila.jpg) (You can switch to the image path you want to process)
7. Run the compiled EXE executable file and observe the results (if any, the environment is correctly configured. If any, the configuration is incorrect)
Follow-up law 2