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目录下:
<?php if ($_FILES) { $imgName = $_FILES['pic']['tmp_name']; //返回多维数组,每个人脸的位置。 $all = face_detect($imgName, 'data/haarcascade_frontalface_alt2.xml'); // print_r($all);exit; $image = new Imagick($imgName); if (is_array($all)) { foreach ($all as $v) { $image->cropImage($v['w'], $v['h'], $v['x'], $v['y']); } } ob_clean(); header("Content-Type: image/jpeg"); echo $image; $image->destroy(); } else { ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
参考网址:
http://blog.csdn.net/zhongmao/article/details/3753377

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Atom editor mac version download
The most popular open source editor

Dreamweaver CS6
Visual web development tools
