first commit
This commit is contained in:
36
src/face_detection.cc
Normal file
36
src/face_detection.cc
Normal 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
13
src/face_detection.h
Normal 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
|
||||
Reference in New Issue
Block a user