时间:2021-07-01 10:21:17 帮助过:22人阅读
if($_FILES){
$img = $_FILES['pic']['tmp_name'];
$arr = face_detect($img, ‘haarcascade_frontalface_alt2.xml');
//$arr1 = face_detect($img, 'haarcascade_frontalface_alt_tree.xml');
if(is_array($arr1)) $all =array_merge($arr,$arr1);
else $all = $arr;
$im = new Imagick($img);
//$draw =new ImagickDraw();
//$borderColor = new ImagickPixel('red');
//$draw->setFillAlpha(0.0);
//$draw->setStrokeColor ($borderColor);
//$draw->setStrokeWidth (1);
if(is_array($all)){
foreach ($all as $v){
$im_cl = $im->clone();
$im_cl->cropImage($v['w'],$v['h'],$v['x'],$v['y']);
$im_cl->swirlImage(60);
$im->compositeImage( $im_cl, Imagick::COMPOSITE_OVER , $v['x'], $v['y'] );
//$draw->rectangle($v['x'],$v['y'],$v['x']+$v['w'],$v['y']+$v['h']);
//$im->drawimage($draw);
}
}
header( “Content-Type: image/png” );
echo $im;
}else{
?>
}
?>
参考资料:
http://www.xarg.org/2008/07/face-detection-with-php/
http://www.opencv.org.cn/index.php/首页
http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/index.html