first commit

This commit is contained in:
goodspb
2018-05-21 01:23:19 +08:00
commit 5539b5bff8
11 changed files with 450 additions and 0 deletions

36
src/face_detection.cc Normal file
View File

@@ -0,0 +1,36 @@
#include "../php_pdlib.h"
#include "face_detection.h"
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/gui_widgets.h>
#include <dlib/image_io.h>
#include <iostream>
using namespace dlib;
using namespace std;
PHP_FUNCTION(dlib_face_detection)
{
char *img_path;
size_t img_path_len;
if(zend_parse_parameters(ZEND_NUM_ARGS(), "s", &img_path, &img_path_len) == FAILURE){
RETURN_FALSE;
}
try {
frontal_face_detector detector = get_frontal_face_detector();
array2d<unsigned char> img;
load_image(img, img_path);
pyramid_up(img);
std::vector<rectangle> dets = detector(img);
RETURN_LONG(dets.size());
}
catch (exception& e)
{
RETURN_FALSE;
}
}

13
src/face_detection.h Normal file
View File

@@ -0,0 +1,13 @@
//
// Created by goodspb on 2018/5/20.
//
#ifndef PHP_DLIB_FACE_DETECTION_H
#define PHP_DLIB_FACE_DETECTION_H
ZEND_BEGIN_ARG_INFO_EX(dlib_face_detection_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, img_path)
ZEND_END_ARG_INFO()
PHP_FUNCTION(dlib_face_detection);
#endif //PHP_DLIB_FACE_DETECTION_H