大神代码链接
称之为MTCNN人脸检测算法,同时有大神已经GitHub上开源了其基于caffe的C++ API 的源代码,https://github.com/DaFuCoding/MTCNN_Caffe 再次感谢大神以及开源~
编译机器
1. 安装依赖
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler libatlas-base-dev cmake python-pip
2. 安装 numpy
pip install numpy
3 安装caffe动态库
下载caffe源码
wget https://github.com/BVLC/caffe/archive/1.0.tar.gz
cd caffe-1.0.0
cp Makefile.config.example Makefile.config
更改Makefile.config 第一行 加入 如下内容
①. 修改opencv库路径【如果不指定opencv库 用默认的即可】
OPENCV_PATH := /work/lib/opencv/3.3.0
OPENCV_INCLUDE_PATH = $(OPENCV_PATH)/include
OPENCV_LIB_PATH = $(OPENCV_PATH)/lib
修改包含目录和库目录
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include $(OPENCV_INCLUDE_PATH)
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib $(OPENCV_LIB_PATH)
如果不想这么麻烦 可以修改 cmake/Dependencies.cmake
最顶部加入:
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/work/lib/opencv/3.3")
find_package(OpenCV 3.3.0 REQUIRED)
② 第八行 CPU_ONLY := 1 打开,表示只使用CPU,如果你用GPU 这一步就不用做了。
mkdir build
cd build
cmake ../ -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_PREFIX=install
#### cmake . -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_PREFIX=install
【可选项】修改caffe 源码,使其不要在控制台打印一大堆东西, 将src/caffe/common.cpp GlobalInit 源码替换为如下
void GlobalInit(int* pargc, char*** pargv) { { // Google flags. ::gflags::ParseCommandLineFlags(pargc, pargv, true); ::google::InitGoogleLogging(*(pargv)[0]); google::SetLogDestination(google::WARNING,""); }
make
make install
cd MTCNN_Caffe
cmake .
make
运行机器:
apt-get install libgoogle-glog-dev libopencv-dev
所有评论(0)