如何根据面部识别裁剪 php 中的图像

How to crop image in php based on facial recognition

我想创建 php 代码来创建我的图片的缩略图。但是在裁剪图像时,我会丢失图像的一些重要部分,例如面部。

php有没有基于人脸检测等裁剪图片的包

您可以使用 image copy resize

在不裁剪的情况下创建图像的缩略图

PHP-Facedetection https://github.com/mauricesvay/php-facedetection 应该确实有用。

它完成检测面部的工作并提供一组坐标,您最终可以将其用于裁剪目的:

// Return coordinates in JSON
// {'x':56.375, 'y':45.1, 'w':227.55}
$face_detect->toJson();

// OR

// Return coordinates as an Array
$face_detect->getFace();

参考:http://www.codediesel.com/algorithms/face-detection-in-images-using-php/

希望对您有所帮助。

此致