编译完成后,想测试example中例子,但是由于没有sudo权限,不能运行pkg-config查看opencv的--cflags和--libs。
记录一下,备忘:
pkg-config --libs opencv -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
pkg-config --cflags opencv -I/usr/local/include/opencv -I/usr/local/include
比如,我要编译facedetect.cpp:
g++ -ggdb -I/opt/baoquanwang/third_partylib/opencv-2.4.11/include -o facedetect facedetect.cpp -L/opt/baoquanwang/third_partylib/opencv-2.4.11/lib/ -Wl,-R/opt/baoquanwang/third_partylib/opencv-2.4.11/lib/ -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_objdetect
用到哪个库最后添加哪个库即可。
测试一下:
./facedetect --cascade="../../data/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="../../data/haarcascades/haarcascade_eye.xml" --scale=1.3 lena.jpg
我的没有桌面,没法测试……
时间: 2024-10-06 00:53:25