【OpenCV】 Windows、Visual StudioでOpenCVを使う準備
この辺を参考に。。。
初めてのOpenCV開発 ― Visual Studio/CMake/NuGetでプロジェクト作成【OpenCV 3.0/3.1】 - Build Insider
①まず、OpenCVパッケージをgithubから落としてくる。
②適当なディレクトリに解凍。今回はC:\opencv-3.1.0
③環境変数にC:\opencv-3.1.0\opencv\build\x64\vc14\binを追加する。Visual Studio2012はvc11、Visual Studio2013はvc12、Visual Studio2015はvc14にパスを通す。
④Visual Studioのプロジェクト→プロパティ→C/C++→全般→追加のインクルードディレクトリにC:\opencv-3.1.0\opencv\build\includeを追加。
⑤Visual Studioのプロジェクト→プロパティ→リンカー→全般→追加のライブラリディレクトリにC:\opencv-3.1.0\opencv\build\x64\vc12\libを追加。
⑥Visual Studioのプロジェクト→プロパティ→リンカー→入力→追加の依存ファイルにopencv_world310.lib、opencv_world310d.libを追加。
あとはcppファイルに、
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
を追加すれば良い。上記リンク先のサンプルコードを動かしてみる。
#include <opencv2/core.hpp> // coreモジュールのヘッダーをインクルード
#include <opencv2/highgui.hpp> // highguiモジュールのヘッダーをインクルード
#include <iostream>
int main(int argc, const char* argv[])
{
// 1幅320px、高さ240pxで赤色の画像データを生成
cv::Mat redImg(cv::Size(320, 240), CV_8UC3, cv::Scalar(0, 0, 255));
// 2画像表示用のウィンドウを生成
cv::namedWindow("red", cv::WINDOW_AUTOSIZE);
// 3ウィンドウに画像を表示
cv::imshow("red", redImg);
// 4キー入力を待機
cv::waitKey(0);
// 5作成したウィンドウを全て破棄
cv::destroyAllWindows();
return 0;
}
ビルドするが、64ビットデバッグ操作に予想以上に時間がかかっていますなるエラーで進まん!
> netsh winsock reset catalog
> netsh int p reset reset.log hit
としたらビルドが通った。
一応?環境構築はできた。