我試圖建立在OS X 10.8使用Eclipse下面的例子:大廈OpenCV的例子X 10.8與Eclipse
//============================================================================
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
if(argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file
if(! image.data) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow("Display window", CV_WINDOW_AUTOSIZE);// Create a window for display.
imshow("Display window", image); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}
,但得到這樣的結果:
**** Build of configuration Debug for project cvTesting ****
make all
Building file: ../src/cvTesting.cpp
Invoking: GCC C++ Compiler
g++ -I/opt/local/include/opencv -I/opt/local/include/opencv2 -I/opt/local/include/opencv2/core/ - I/opt/local/include/opencv2/highgui/ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/cvTesting.d" -MT"src/cvTesting.d" -o "src/cvTesting.o" "../src/cvTesting.cpp"
../src/cvTesting.cpp:9:33: warning: opencv2/core/core.hpp: No such file or directory
../src/cvTesting.cpp:10:39: warning: opencv2/highgui/highgui.hpp: No such file or directory
../src/cvTesting.cpp:13: error: 'cv' is not a namespace-name
../src/cvTesting.cpp:13: error: expected namespace-name before ';' token
../src/cvTesting.cpp: In function 'int main(int, char**)':
../src/cvTesting.cpp:24: error: 'Mat' was not declared in this scope
../src/cvTesting.cpp:24: error: expected `;' before 'image'
../src/cvTesting.cpp:25: error: 'image' was not declared in this scope
../src/cvTesting.cpp:25: error: 'CV_LOAD_IMAGE_COLOR' was not declared in this scope
../src/cvTesting.cpp:25: error: 'imread' was not declared in this scope
../src/cvTesting.cpp:33: error: 'CV_WINDOW_AUTOSIZE' was not declared in this scope
../src/cvTesting.cpp:33: error: 'namedWindow' was not declared in this scope
../src/cvTesting.cpp:34: error: 'imshow' was not declared in this scope
../src/cvTesting.cpp:36: error: 'waitKey' was not declared in this scope
make: *** [src/cvTesting.o] Error 1
**** Build Finished ****
我的OpenCV安裝這樣pkg配置報告如下:
$ pkg配置OpenCV的--cflags
-I /選擇/本地/包括/ OpenCV的-I /選擇/本地/包括
和
$ pkg配置--libs OpenCV的
/opt/local/lib/libopencv_calib3d.dylib /選擇/ local/lib目錄/ libopencv_contrib.dylib /opt/local/lib/libopencv_core.dylib /opt/local/lib/libopencv_features2d.dylib /opt/local/lib/libopencv_flann.dylib /opt/local/lib/libopencv_gpu.dylib /選擇/ local/lib目錄/ libopencv_highgui.dylib /opt/local/lib/libopencv_imgproc.dylib /opt/local/lib/libopencv_legacy.dylib /opt/local/lib/libopencv_ml.dylib /opt/local/lib/libopencv_nonfree.dylib /選擇/ local/lib目錄/ libopencv_objdetect.dylib /opt/local/lib/libopencv_photo.dylib /opt/local/lib/libopencv_stitching.dylib的/ opt/local/lib目錄/ libopencv_ts.dylib /opt/local/lib/libopencv_video.dylib /opt/local/lib/libopencv_videostab.dylib
在Eclipse中,在項目屬性中我有,C/C++構建 - >設置 - > GCC C++編譯器「所有選項」 設置爲:
-I /選擇/本地/包含/ OpenCV的-I /選擇/本地/包含/ opencv2 -O0 -g3 -Wall -c -fmessage長度= 0
和C/C++編譯 - >設置 - > MacOS X C++鏈接器 - >「所有選項」設置爲: -L/opt/local/lib
我還有以下庫(-l)/C++ Build - > Setti NGS - > MacOS X的C++鏈接器 - >庫:
opencv_core opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_features2d opencv_calib3d opencv_objdetect opencv_contrib opencv_legacy opencv_flann
我能夠建立在Ubuntu同樣的例子, ,只是沒有OS X.任何人都可以幫助解釋在OS X中使用日食路徑的建立,爲OpenCV的?
的core.hpp和highgui.hpp文件是在正確的位置,這是 /選擇/local/include/opencv2/core/core.hpp /opt/local/include/opencv2/highgui/highgui.hpp 然而使用預處理的語法時,這是不搜索: 的#include #include –
Walt
2013-04-08 14:42:25
我沒有嘗試,但我很確定我可以通過提供這些文件的具體路徑包括文件。但是,構建環境 需要能夠解析對的引用 –
Walt
2013-04-08 14:50:36