1. If CMake is not installed, install using the command Brew install CMake.
If Pkg-config is not installed, use the command brew install Pkg-config installation. If the Pkg-config program cannot be found after installation, copy it to the/usr/local/bin directory.
2. Installing OPENCV
Brew Install OpenCV
3. Test procedures
#include <iostream>#include<opencv2/opencv.hpp>#include<vector>#include<string>using namespacestd;using namespaceCV;intMain () {Cv::mat img_encode; Img_encode= Imread ("./obito.jpeg", Cv_load_image_color); Vector<uchar>Data_encode; Imencode (". JPEG", Img_encode, Data_encode); stringStr_encode (Data_encode.begin (), Data_encode.end ()); //cout << str_encode << Endl;Cv::mat Img_decode; Vector<uchar>data (Str_encode.begin (), Str_encode.end ()); Img_decode=imdecode (data, cv_load_image_color); Imshow ("pic", Img_decode); Cvwaitkey (10000); //cout << "Hello" << Endl;}
The compile command is: g++ cpp_opencv.cpp-o cpp_opencv ' pkg-config--cflags--libs Opencv '
Or simply list the link library: g++ cpp_opencv.cpp -l/usr/local/lib/-lopencv_highgui.3.4.2-lopencv_core.3.4.2-lopencv_imgcodecs
Using C + + OpenCV library under Mac OS x