我想用 CodeBlocks 或 Linux 终端编译以下 OpenCV 程序。
http://plaza.ufl.edu/tyler727/imdl/src/eigenface.cpp
line 57: nTrainFaces = loadFaceImgArray("/home/hacker/data/Eigenfacecpp/train.txt");
line 192: // load test images and ground truth for person number
nTestFaces = loadFaceImgArray("/home/hacker/data/Eigenfacecpp/test.txt");
// project the training images onto the PCA subspace
projectedTrainFaceMat = cvCreateMat(nTrainFaces, nEigens, CV_32FC1);
for(i=0; i<nTrainFaces; i++)
{
cvEigenDecomposite(faceImgArr[i],
nEigens,
eigenVectArr,
0, 0,
pAvgTrainImg,
line 78: projectedTrainFaceMat->data.fl + i*nEigens);
}
cvCalcEigenObjects(nTrainFaces,
(void*)faceImgArr,
(void*)eigenVectArr,
CV_EIGOBJ_NO_CALLBACK,
0,
0,
&calcLimit,
pAvgTrainImg,
line 154: eigenValMat->data.fl);
//project the test image onto the PCA subspace
cvEigenDecomposite(faceImgArr[i],
nEigens,
eigenVectArr,
0, 0,
pAvgTrainImg,
line 211: projectedTestFace);
我得到了这些错误:
Compiling: eigenface.cpp
In Function »void learn()«:
line 57: deprecated conversion from string constant to ‘char*’ [Wwrite-strings]
In Function »double recognize()«:
line 192: deprecated conversion from string constant to ‘char*’ [Wwrite-strings]
/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
obj/Debug/eigenface.o: In function `learn()':
/home/hacker/data/Eigenfacecpp/eigenface.cpp:78: undefined reference to `cvEigenDecomposite'
obj/Debug/eigenface.o: In function `doPCA()':
/home/hacker/data/Eigenfacecpp/eigenface.cpp:154: undefined reference to `cvCalcEigenObjects'
obj/Debug/eigenface.o: In function `recognize()':
/home/hacker/data/Eigenfacecpp/eigenface.cpp:211: undefined reference to `cvEigenDecomposite'
我不明白我做错了什么。我认为这是愚蠢的,但我找不到它。
来自 CodeBlocks 的编译器和调试器设置:
链接器设置->其他选项:-lopencv_core -lopencv_objdetect -lopencv_imgproc
-lopencv_highgui
搜索目录->编译器:/usr/local/include/opencv
搜索目录->链接器:/usr/lib
我在这里做错了什么?请帮我解决这个问题。