以下は私のステップです:
1)コマンドラインツールプロジェクト「OpenCV」を作成します
2)「libopencv_calib3d.2.4.2.dylib」など、サフィックス2.4.2が付いた/ usr / local/libにあるファイルをプロジェクトに追加します。
3)プロジェクトのヘッダー検索パスに「/ usr / local/include」を追加します
4)このプログラムを入力します。
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/cvaux.hpp>
int main(int argc, char** argv)
{
IplImage * pInpImg = 0;
// Load an image from file - change this based on your image name
pInpImg = cvLoadImage("my_image.jpg", CV_LOAD_IMAGE_UNCHANGED);
if(!pInpImg)
{
fprintf(stderr, "failed to load input image\n");
return -1;
}
// Write the image to a file with a different name,
// using a different image format -- .png instead of .jpg
if( !cvSaveImage("my_image_copy.png", pInpImg) )
{
fprintf(stderr, "failed to write image file\n");
}
// Remember to free image memory after using it!
cvReleaseImage(&pInpImg);
return 0;
}
ただし、エラーが発生します:
ld: library not found for -lopencv_calib3d.2.4.2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
問題はどこだ?
マウンテンライオンとXcode4.4を使用しています