LoginSignup
5

More than 3 years have passed since last update.

macでC++のOpenCVを動かす。

Homebrewがインストールされているとします。

brew install pkg-config
brew install opencv  

適当なプログラムを書きます。

test_opencv.cpp
#include <opencv2/opencv.hpp>

int main(){
    cv::Mat a = cv::imread("img.jpg", 1); 
    cv::imshow("hello", a); 
    cv::waitKey();
}

コンパイル時にpkg-configを使って必要なヘッダやライブラリを設定します。

g++ `pkg-config --libs --cflags opencv` test_opencv.cpp

動作確認をします。

./a.out

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
5