我正在尝试使用OpenCV运行Facedetect示例,我将代码编译为build_all.sh文件。
然后我用
运行代码sudo ./facedetect --cascade="../../data/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="../../data/haarcascades/haarcascade_eye.xml" --scale=1.3 lena.jpg
显示一些说明
This program demonstrates the cascade recognizer. Now you can use Haar or LBP features.
This classifier can recognize many kinds of rigid objects, once the appropriate classifier is trained.
It's most known use is for faces.
Usage:
./facedetect [--cascade=<cascade_path> this is the primary trained classifier such as frontal face]
[--nested-cascade[=nested_cascade_path this an optional secondary classifier such as eyes]]
[--scale=<image scale greater or equal to 1, try 1.3 for example>]
[--try-flip]
[filename|camera_index]
see facedetect.cmd for one call:
./facedetect --cascade="../../data/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="../../data/haarcascades/haarcascade_eye.xml" --scale=1.3
During execution:
Hit any key to quit.
Using OpenCV version 2.4.8
Processing 1 --cascade=../../data/haarcascades/haarcascade_frontalface_alt.xml
from which we have cascadeName= ../../data/haarcascades/haarcascade_frontalface_alt.xml
Processing 2 --nested-cascade=../../data/haarcascades/haarcascade_eye.xml
Processing 3 --scale=1.3
from which we read scale = 1.3
Processing 4 lena.jpg
最后我收到以下错误:
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/userk/Development/OpenCV/opencv-2.4.8/modules/highgui/src/window.cpp, line 483
terminate called after throwing an instance of 'cv::Exception'
what(): /home/userk/Development/OpenCV/opencv-2.4.8/modules/highgui/src/window.cpp:483: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow
已经安装了libgtk2.0-dev和pkg-config软件包。你们有什么建议吗?
解决:
正如Berak建议的那样,我从主目录中重新编译了opencv:
cmake -D CMAKE_BUILD_TYPE=RELEASE ..
make
sudo make install