1 Star 1 Fork 2

带刀医生/php-opencv

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
detect_facemarks_by_lbf.php 955 Bytes
一键复制 编辑 原始数据 按行查看 历史
yangquanliang 提交于 2020-11-23 10:22 . 初始化php-opencv
<?php
use CV\CascadeClassifier, CV\Face\FacemarkLBF;
use function CV\{circle, imread, imwrite, cvtColor, equalizeHist};
use CV\Scalar;
use const CV\{COLOR_BGR2GRAY};
$src = imread("images/faces.jpg");
$gray = cvtColor($src, COLOR_BGR2GRAY);
equalizeHist($gray, $gray);
// face by lbpcascade_frontalface
$faceClassifier = new CascadeClassifier();
$faceClassifier->load('models/lbpcascades/lbpcascade_frontalface.xml');
$faces = null;
$faceClassifier->detectMultiScale($gray, $faces);
//var_export($faces);
$facemark = FacemarkLBF::create();
$facemark->loadModel('models/opencv-facemark-lbf/lbfmodel.yaml');
$facemark->fit($src, $faces, $landmarks);
//var_export($landmarks);
if ($landmarks) {
$scalar = new Scalar(0, 0, 255);
foreach ($landmarks as $face) {
foreach($face as $k => $point) {//var_export($point);
circle($src, $point, 2, $scalar, 2);
}
}
}
imwrite("results/_detect_facemarks_by_lbf.jpg", $src);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/mycharm/php-opencv.git
git@gitee.com:mycharm/php-opencv.git
mycharm
php-opencv
php-opencv
master

搜索帮助