下載OpenCV
下載OpenCV,並切換到指定分支下:
$ git clone https://github.com/opencv/opencv.git
$ cd opencv
$ git checkout 3.4
$git branch
編譯安裝OpenCV
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
安裝pkg-config
$brew install pkg-config
C++ opencv程序編譯
#include <iostream>
#include <opencv2/core.hpp> // 核心功能
#include <opencv2/imgproc.hpp> // 圖像處理模塊
#include <opencv2/highgui.hpp> // 讀寫圖像和視頻的函數,以及用戶交互函數
// using namespace cv;
using namespace std;
int main(void)
{
cv::Mat image; // 創建一個空圖像, 0x0大小
cout << "This image is:" << image.rows << "x:" << image.cols << endl;
return 0;
}
g++ First_test.cpp -o First_test `pkg-config --cflags --libs opencv`
./First_test