可能重复:
Facial recognition/detection PHP or software for photo and video galleries
我正在尝试编码将肖像合并到可用的帧图片中。通过使用WideImage PHP Lib,我可以操作图像,这是我的代码:
//Load image from disk
$img = WideImage::load($fileName); //our character
$watermark = WideImage::load($framePath.'photo_frame.png'); //load frame picture
//crop img to fit into frame
$hWatermark = $watermark->getHeight();
$wWatermark = $watermark->getWidth();
$img = $img->resize($wWatermark, $hWatermark, "outside");
$hImg = $img->getHeight();
$wImg = $img->getWidth();
if($hImg > $hWatermark) {
$img = $img->crop(0, 0, $width = "100%", $height = $hWatermark);
}
if($wImg > $wWatermark) {
$img = $img->crop(0, 0, $width = $wWatermark, $height = "100%");
}
// place the frame override image
$new = $img->merge($watermark, $left = 0, $top = 0, $pct = 100);
//Result is a new image with our character in a frame
$new->output('jpg', 90);
使用上面的块代码,我可以制作一张新图片,但如果脸部没有位于左上角附近,则新图片不会聚焦到脸部。例:
我认为我编写的代码无法自动检测面部,但我们有一种简单的方法就是让用户选择一个区域进行拼贴。如何以这种方式实现HTML& JS? 谢谢你的帮助!