利用OpenCV进行PHP人脸识别
程序员文章站
2024-04-06 16:10:49
...
1.opencv下载安装 下载地址:http://opencv.org/downloads.html,注意:2.4.4版本采用的是cmake,所以需要事先安装cmake。 shell: wget http://softlayer-dal.dl.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.4/OpenCV-2.4.4a.tar.bz2 tar xvf O
1.opencv下载安装
下载地址:http://opencv.org/downloads.html,注意:2.4.4版本采用的是cmake,所以需要事先安装cmake。
shell:
wget http://softlayer-dal.dl.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.4/OpenCV-2.4.4a.tar.bz2tar xvf OpenCV-2.4.4a.tar.bz2
cd opencv-2.4.4/
cmake ./
make
make install
2.安装facedetect
http://www.xarg.org/project/php-facedetect/cd PHP-Facedetect-master
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
编译完之后会提示facedetect.so 文件所在的位置。
最后确认在php.ini加入
extension=facedetect.so,reload php-fpm.
3.安装imagemagick
http://www.imagemagick.org/script/install-source.phpwget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar xvf ImageMagick.tar.gzcd ImageMagick-6.8.6-10/
./configure
make && make install
ldconfig /usr/local/lib
4.安装php的imagick扩展
http://pecl.php.net/package/imagickwget http://pecl.php.net/get/imagick-3.1.1.tgz
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
Installing header files: /usr/local/php/include/php/
最后确认在php.ini加入
extension=imagick.so,reload php-fpm.
5.php实例代码
从openCV源代码/data/haarcascades/里头取出所有xml文件放在php的执行目录下,此处我是放在data目录下:
cropImage($v['w'], $v['h'], $v['x'], $v['y']); } } ob_clean(); header("Content-Type: image/jpeg"); echo $image; $image->destroy(); } else { ?>
参考网址:
http://blog.csdn.net/zhongmao/article/details/3753377