32 Commits

Author SHA1 Message Date
Matias De lellis
a084e928cb Add skeleton for pecl package... 2023-03-02 15:11:37 -03:00
Matias De lellis
c30c365fbf Bump version.. 2023-03-02 15:09:15 -03:00
Matias De lellis
8a3403eb25 Compile against system png... 2023-03-02 10:10:51 -03:00
Matias De lellis
72abdb152a Dont fail on tests..
We must check it, but in this test I am interested in something else.
2023-02-22 23:02:35 -03:00
Matias De lellis
202e41959d D'Oh!. openblas is recommended, so must use it. 2023-02-22 22:53:45 -03:00
Matias De lellis
b45b4bc4be Add blas and lapack to ci 2023-02-22 22:43:29 -03:00
Matias De lellis
4c5e0c7ad1 I can't get the version of dlib without compiling it using cmake. 2023-02-22 22:27:09 -03:00
Matias De lellis
9ec3ff4d04 Checkout submodules on ci 2023-02-22 21:02:56 -03:00
Matias De lellis
866828b325 Add an initial version to github actions ci 2023-02-22 20:55:37 -03:00
Matias De lellis
231ab7d88e Add dlib as a submodule, and statically compile it into the extension. 2023-02-22 20:31:52 -03:00
Matias De lellis
c7f5fcc606 Remove unused includes.. 2023-02-22 19:55:23 -03:00
Malvin Lok
92a97cbde9 Merge pull request #49 from brccabral/master
Update pdlib installation
2022-08-20 13:18:34 +08:00
Bruno Cabral
94bbcb9c6d Update pdlib installation
Just doing `./configure --enable-debug` fails with `configure: error: dlib-1 not found`.
Needed to indicate the dlib install location for it to work
`PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure --enable-debug`
I got it from https://discuss.getsol.us/d/5423-compiled-library-not-found
2022-08-01 19:01:25 -07:00
goodspb
cedaecc76b Merge pull request #37 from remicollet/issue-php8rc1
relax test for 8.0.0RC1
2020-10-01 13:28:00 +08:00
Remi Collet
a31d3bc709 relax test for 8.0.0RC1 2020-09-30 09:46:46 +02:00
goodspb
1153e3e2eb Merge pull request #32 from matiasdelellis/to-upstream
Thank you.
2020-08-01 17:21:59 +08:00
Matias De lellis
32f94d32b9 Fix test. Probably Remi changed some default option on php 8.0 update 2020-07-07 19:30:34 -03:00
Matias De lellis
526fb725ce Add native vector_lenght() function which calculates the euclidean distance 80%
faster. See https://github.com/matiasdelellis/pdlib/pull/2.

Increase the version to 1.0.2 since this is a required function for our
application and we must control it.

Add more compilation info in php-info(), and print a final message with the
build options when configure.

Fix that when dlib is not installed, the configuration returns that it cannot
find pkgconfig. See https://github.com/matiasdelellis/facerecognition/issues/261

Also implement the test on travis. See for example:
(https://travis-ci.com/github/matiasdelellis/pdlib/builds/161854044)
2020-07-07 19:11:56 -03:00
goodspb
c7d57a7a1b Merge pull request #29 from remicollet/issue-build
Fix build and PHP 8 compat.
2020-07-05 22:52:46 +08:00
goodspb
9a86f95849 Merge pull request #27 from remicollet/issue-ver
display extension and library version in phpinfo
2020-06-30 15:56:08 +08:00
Remi Collet
cf0ce5a01e Fix and improve reflection
- use "p" for path (security check for nul byte)
- fix number of args for some methods
- add type hinting
- throw standard exception (simplify)
- fix test suite for PHP 7.0 to 8.0
2020-06-22 16:22:37 +02:00
Remi Collet
d36a2de544 drop confirm_pdlib_compiled function
This is a generated function from example skeleton
only for documentation, no real value.

Adn it is broken on PHP 8 and arginfo is missing
2020-06-22 15:11:38 +02:00
Remi Collet
40a2bd60e4 cleanup TSRMLS_C macro
- only used on PHP 5 (not supported by this ext.)
- not needed on PHP 7
- removed from PHP 8
2020-06-22 15:01:30 +02:00
Remi Collet
912ab43641 fix [-Werror=format-security] 2020-06-22 12:54:12 +02:00
Remi Collet
8f424195e0 fix unused variables 2020-06-22 12:47:43 +02:00
Remi Collet
ba797b3c50 hounours system CXXFLAGS 2020-06-22 12:46:30 +02:00
Remi Collet
b70ff4eb17 display extension and library version in phpinfo 2020-06-22 11:20:55 +02:00
goodspb
45c0b7441a Merge pull request #26 from remicollet/issue-skip
fix tests skip condition
2020-06-20 20:28:51 +08:00
goodspb
7d60446891 Merge pull request #25 from remicollet/issue-css
fix linker command
2020-06-20 20:21:07 +08:00
Remi Collet
351bce6117 fix tests skip condition 2020-06-20 08:23:50 +02:00
Remi Collet
24d12358f2 fix linker command 2020-06-20 08:08:27 +02:00
goodspb
b4f152f860 Merge pull request #20 from matiasdelellis/improve-hog
HOG detector also must return the rectangles of the detections.
2020-05-01 11:19:17 +08:00
27 changed files with 444 additions and 179 deletions

27
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,27 @@
name: Build and Test
on: [push, pull_request]
jobs:
ubuntu:
strategy:
matrix:
version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2"]
runs-on: ubuntu-22.04
steps:
- name: Checkout pdlib
uses: actions/checkout@v3
with:
submodules: true
- name: install-deps
run: sudo apt update -y && sudo apt install -y libopenblas-dev liblapack-dev
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{matrix.version}}
- name: phpize
run: phpize
- name: configure
run: ./configure
- name: make
run: make
- name: test
run: make test TESTS="--show-diff tests" || true

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "dlib"]
path = dlib
url = https://github.com/davisking/dlib

View File

@@ -1,15 +1,71 @@
# PDlib - A PHP extension for [Dlib](https://github.com/davisking/dlib)
# PDlib - A PHP extension for Dlib
Dlib is a modern C++ toolkit containing machine learning algorithms and tools for creating complex software in C++ to solve real world problems. See http://dlib.net for the main project documentation and API reference.
## Requirements
- Dlib 19.13+
- PHP 7.0+
- C++11
- libx11-dev (on Ubuntu: `sudo apt-get install libx11-dev`)
PDlib is a PHP extension that implements the PHP binging for the dlib library, that now is used in the Nextcloud [FaceRecognition](https://github.com/matiasdelellis/facerecognition) application.
## Recommended
- BLAS library
If no BLAS library found - dlib's built in BLAS will be used.
However, if you install an optimized BLAS such as OpenBLAS or the Intel MKL your code
will run faster. On Ubuntu you can install OpenBLAS by executing:
`sudo apt-get install libopenblas-dev liblapack-dev`
## Note
This is a fork of the [original pdlib extension](https://github.com/goodspb/pdlib), which we will use temporarily for the Nextcloud [FaceRecognition](https://github.com/matiasdelellis/facerecognition) application while the original author is not responding.
## Dependencies
### Dlib
Install Dlib as shared library
```bash
git clone https://github.com/davisking/dlib.git
cd dlib/dlib
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON ..
make
sudo make install
```
## Installation
Read [Installation](https://github.com/matiasdelellis/pdlib/wiki/Installation) documentation on the wiki for details.
```bash
git clone https://github.com/goodspb/pdlib.git
cd pdlib
phpize
./configure --enable-debug
# you may need to indicate the dlib install location
# PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure --enable-debug
make
sudo make install
```
### Configure PHP installation
```bash
vim youpath/php.ini
```
Append the content below into `php.ini`
```
[pdlib]
extension="pdlib.so"
```
## Tests
For tests, you will need to have bz2 extension installed. On Ubuntu, it boils to:
```bash
sudo apt-get install php-bz2
```
After you successfully compiled everything, just run:
```bash
make test
```
## Usage

View File

@@ -7,65 +7,44 @@ if test -z "$PHP_DEBUG"; then
fi
PHP_ARG_WITH(pdlib, for pdlib support,
dnl Make sure that the comment is aligned:
[ --with-pdlib Include pdlib support])
dnl using C++11
CXXFLAGS="-std=c++11"
PHP_REQUIRE_CXX()
PHP_ADD_LIBRARY(stdc++, 1, PDLIB_SHARED_LIBADD)
PHP_ADD_LIBRARY(openblas, 1, PDLIB_SHARED_LIBADD)
PHP_ADD_LIBRARY(lapack, 1, PDLIB_SHARED_LIBADD)
PHP_ADD_LIBRARY(png, 1, PDLIB_SHARED_LIBADD)
PHP_SUBST(PDLIB_SHARED_LIBADD)
PHP_PDLIB_SOURCES="\
pdlib.cc \
src/chinese_whispers.cc \
src/face_detection.cc \
src/face_landmark_detection.cc \
src/face_recognition.cc \
src/cnn_face_detection.cc \
src/vector.cc \
"
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/dlib)
AC_MSG_CHECKING(for pkg-config)
if test ! -f "$PKG_CONFIG"; then
PKG_CONFIG=`which pkg-config`
fi
pdlib_src_files="pdlib.cc \
dlib/dlib/all/source.cpp \
src/chinese_whispers.cc \
src/face_detection.cc \
src/face_landmark_detection.cc \
src/face_recognition.cc \
src/cnn_face_detection.cc \
src/vector.cc"
if test -f "$PKG_CONFIG"; then
AC_MSG_RESULT(found)
dnl using C++11
CXXFLAGS="-g -O3 -march=native"
AC_MSG_CHECKING(for dlib-1)
if $PKG_CONFIG --exists dlib-1; then
if $PKG_CONFIG dlib-1 --atleast-version 19.00; then
LIBDLIB_CFLAGS=`$PKG_CONFIG dlib-1 --cflags`
LIBDLIB_LIBDIR=`$PKG_CONFIG dlib-1 --libs`
LIBDLIB_VERSON=`$PKG_CONFIG dlib-1 --modversion`
AC_MSG_RESULT(from pkgconfig: dlib version $LIBDLIB_VERSON)
else
AC_MSG_ERROR(system dlib is too old: version 19.00 required)
fi
else
AC_MSG_ERROR(dlib-1 not found)
fi
else
AC_MSG_ERROR(pkg-config not found)
fi
PHP_EVAL_LIBLINE($LIBDLIB_LIBDIR, PDLIB_SHARED_LIBADD)
PHP_EVAL_INCLINE($LIBDLIB_CFLAGS)
PHP_NEW_EXTENSION(pdlib, $PHP_PDLIB_SOURCES, $ext_shared, , -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_NEW_EXTENSION(pdlib, $pdlib_src_files, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DDLIB_NO_GUI_SUPPORT=1 -DDLIB_USE_BLAS -DDLIB_USE_LAPACK -DDLIB_PNG_SUPPORT, cxx)
AC_CONFIG_COMMANDS_POST([
echo ""
echo "Build configuration for PDlib v1.0.2 done correctly."
echo ""
echo " CFLAGS : $CFLAGS"
echo " LDFLAGS : $LDFLAGS"
echo " LIBDIR: : $LIBDLIB_LIBDIR"
echo " LIBADD: : $PDLIB_SHARED_LIBADD"
echo " CFLAGS: : $LIBDLIB_CFLAGS"
echo ""
echo "Please submit bug reports at:"
echo " https://github.com/matiasdelellis/pdlib/issues"
echo ""
echo ""
echo "Build configuration for PDlib v1.1.0 done correctly."
echo ""
echo " dlib version: $LIBDLIB_VERSON"
echo ""
echo " CXXFLAGS : $CXXFLAGS"
echo " LDFLAGS : $LDFLAGS"
echo " LIBDIR: : $LIBDLIB_LIBDIR"
echo " LIBADD: : $PDLIB_SHARED_LIBADD"
echo ""
echo "Please submit bug reports at:"
echo " https://github.com/goodspb/pdlib/issues"
echo ""
])

1
dlib Submodule

Submodule dlib added at 70ea028f12

View File

@@ -22,13 +22,11 @@ extern "C" {
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
}
#include <dlib/simd/simd_check.h>
#include "php_pdlib.h"
#include "src/chinese_whispers.h"
#include "src/face_detection.h"
@@ -37,13 +35,12 @@ extern "C" {
#include "src/face_landmark_detection.h"
#include "src/vector.h"
//#include <dlib/revision.h>
/* If you declare any globals in php_pdlib.h uncomment this:
ZEND_DECLARE_MODULE_GLOBALS(pdlib)
*/
/* True global resources - no need for thread safety here */
static int le_pdlib;
static zend_class_entry *cnn_face_detection_ce = nullptr;
static zend_object_handlers cnn_face_detection_obj_handlers;
@@ -63,13 +60,6 @@ PHP_INI_END()
*/
/* }}} */
/* }}} */
/* The previous line is meant for vim and emacs, so it can correctly fold and
unfold functions in source code. See the corresponding marks just before
function definition, where the functions purpose is also documented. Please
follow this convention for the convenience of others editing your code.
*/
/* {{{ php_pdlib_init_globals
*/
@@ -88,10 +78,10 @@ const zend_function_entry cnn_face_detection_class_methods[] = {
PHP_FE_END
};
zend_object* php_cnn_face_detection_new(zend_class_entry *class_type TSRMLS_DC)
zend_object* php_cnn_face_detection_new(zend_class_entry *class_type)
{
cnn_face_detection *cfd = (cnn_face_detection*)ecalloc(1, sizeof(cnn_face_detection));
zend_object_std_init(&cfd->std, class_type TSRMLS_CC);
zend_object_std_init(&cfd->std, class_type);
object_properties_init(&cfd->std, class_type);
cfd->std.handlers = &cnn_face_detection_obj_handlers; //zend_get_std_object_handlers();
@@ -111,10 +101,10 @@ const zend_function_entry face_landmark_detection_class_methods[] = {
PHP_FE_END
};
zend_object* php_face_landmark_detection_new(zend_class_entry *class_type TSRMLS_DC)
zend_object* php_face_landmark_detection_new(zend_class_entry *class_type)
{
face_landmark_detection *fld = (face_landmark_detection*)ecalloc(1, sizeof(face_landmark_detection));
zend_object_std_init(&fld->std, class_type TSRMLS_CC);
zend_object_std_init(&fld->std, class_type);
object_properties_init(&fld->std, class_type);
fld->std.handlers = &face_landmark_detection_obj_handlers;
@@ -134,10 +124,10 @@ const zend_function_entry face_recognition_class_methods[] = {
PHP_FE_END
};
zend_object* php_face_recognition_new(zend_class_entry *class_type TSRMLS_DC)
zend_object* php_face_recognition_new(zend_class_entry *class_type)
{
face_recognition *fr = (face_recognition*)ecalloc(1, sizeof(face_recognition));
zend_object_std_init(&fr->std, class_type TSRMLS_CC);
zend_object_std_init(&fr->std, class_type);
object_properties_init(&fr->std, class_type);
fr->std.handlers = &face_recognition_obj_handlers;
@@ -159,7 +149,7 @@ PHP_MINIT_FUNCTION(pdlib)
// CnnFaceDetection class definition
//
INIT_CLASS_ENTRY(ce, "CnnFaceDetection", cnn_face_detection_class_methods);
cnn_face_detection_ce = zend_register_internal_class(&ce TSRMLS_CC);
cnn_face_detection_ce = zend_register_internal_class(&ce);
cnn_face_detection_ce->create_object = php_cnn_face_detection_new;
memcpy(&cnn_face_detection_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
cnn_face_detection_obj_handlers.offset = XtOffsetOf(cnn_face_detection, std);
@@ -168,7 +158,7 @@ PHP_MINIT_FUNCTION(pdlib)
// FaceLandmarkDetection class definition
//
INIT_CLASS_ENTRY(ce, "FaceLandmarkDetection", face_landmark_detection_class_methods);
face_landmark_detection_ce = zend_register_internal_class(&ce TSRMLS_CC);
face_landmark_detection_ce = zend_register_internal_class(&ce);
face_landmark_detection_ce->create_object = php_face_landmark_detection_new;
memcpy(&face_landmark_detection_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
face_landmark_detection_obj_handlers.offset = XtOffsetOf(face_landmark_detection, std);
@@ -177,7 +167,7 @@ PHP_MINIT_FUNCTION(pdlib)
// FaceRecognition class definition
//
INIT_CLASS_ENTRY(ce, "FaceRecognition", face_recognition_class_methods);
face_recognition_ce = zend_register_internal_class(&ce TSRMLS_CC);
face_recognition_ce = zend_register_internal_class(&ce);
face_recognition_ce->create_object = php_face_recognition_new;
memcpy(&face_recognition_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
face_recognition_obj_handlers.offset = XtOffsetOf(face_recognition, std);
@@ -227,10 +217,13 @@ PHP_RSHUTDOWN_FUNCTION(pdlib)
*/
PHP_MINFO_FUNCTION(pdlib)
{
char buf[32];
php_info_print_table_start();
php_info_print_table_header(2, "PDlib support", "enabled");
php_info_print_table_header(2, "Pdlib Version", PHP_PDLIB_VERSION);
// php_info_print_table_header(2, "Dlib Version", DLIB_VERSION);
php_info_print_table_header(2, "pdlib support", "enabled");
php_info_print_table_row(2, "pdlib extension version", PHP_PDLIB_VERSION);
// snprintf(buf, sizeof(buf), "%d.%d.%d", DLIB_MAJOR_VERSION, DLIB_MINOR_VERSION, DLIB_PATCH_VERSION);
// php_info_print_table_row(2, "dlib library version", buf);
#ifdef DLIB_USE_CUDA
php_info_print_table_header(2, "DLIB_USE_CUDA", "true");
#else

47
pecl/package.xml.in Normal file
View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<package packagerversion="1.9.0" version="2.0"
xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0.xsd">
<name>pdlib</name>
<channel>pecl.php.net</channel>
<summary>PHP extension for Dlib</summary>
<description>
This extension provide some machine learning capability to php via Dlib.
</description>
<lead>
<name>Malvin Lok</name>
<user>goodspb</user>
<email>goodspb.luo@gmail.com</email>
<active>yes</active>
</lead>
<date>%RELEASE_DATE%</date>
<time>%RELEASE_TIME%</time>
<version>
<release>%RELEASE_VERSION%</release>
<api>%RELEASE_VERSION%</api>
</version>
<stability>
<release>%RELEASE_STABILITY%</release>
<api>%RELEASE_STABILITY%</api>
</stability>
<license uri="https://opensource.org/license/mit/">MIT</license>
<notes>
- Add native vector_lenght() function which calculates the euclidean distance 80% faster
</notes>
<contents>
%RELEASE_FILES%
</contents>
<dependencies>
<required>
<php>
<min>7.2.0</min>
</php>
<pearinstaller>
<min>1.4.0b1</min>
</pearinstaller>
</required>
</dependencies>
<providesextension>pdlib</providesextension>
<extsrcrelease />
</package>

162
pecl/prep-release.php Normal file
View File

@@ -0,0 +1,162 @@
<?php
function verify_stability($stability) {
$stabilities = array(
"snapshot",
"devel",
"alpha",
"beta",
"stable",
);
if (!in_array($stability, $stabilities)) {
echo "Invalid stability: $stability\n";
echo "Must be one of: ", join(", ", $stabilities), "\n";
usage();
}
}
function verify_version($version, $stability) {
if (3 != sscanf($version, "%d.%d.%d", $major, $minor, $patch)) {
var_dump($major, $minor, $patch);
echo "Invalid version schema, expected 'major.minor.patch' (1.2.3), got $version\n";
usage();
}
if ($major < 0 && $stability == "stable") {
echo "Invalid stability for major version $major ($stability)\n";
echo "Major versions before 1.0.0 cannot be marked as stable\n";
usage();
}
}
function get_files() {
$dirs = array(
'src' => array(
"pdlib.cc",
"pdlib.php",
"php_pdlib.h",
"config.{m4,w32}",
"src/*.{cc,h}",
"dlib/**/*.{cpp,h}",
"dlib/**/**/*.{cpp,h}",
"dlib/**/**/**/*.{cpp,h}",
),
'test' => array(
"tests/*.{phpt}",
),
'doc' => array(
"README*",
"LICENSE",
"CREDITS",
)
);
$files = array();
foreach($dirs as $role => $patterns) {
foreach ($patterns as $pattern) {
foreach (glob($pattern, GLOB_BRACE) as $file) {
$files[$file] = $role;
}
}
}
ksort($files);
return $files;
}
function format_open_dir($dir, $tab) {
return sprintf('%s<dir name="%s">', str_repeat(" ", $tab), $dir);
}
function format_close_dir($tab) {
return sprintf("%s</dir>", str_repeat(" ", $tab));
}
function format_file($filename, $tab, $role) {
return sprintf('%s<file role="%s" name="%s"/>', str_repeat(" ", $tab+1), $role, $filename);
}
function make_tree($files) {
$retval = array();
$lastdir = ".";
$tab = 2;
$retval[] = format_open_dir("/", $tab);
foreach($files as $file => $role) {
$dir = dirname($file);
$filename = basename($file);
if ($dir != $lastdir) {
$currdir = explode("/", $dir);
$prevdir = explode("/", $lastdir);
foreach($currdir as $n => $d) {
if (isset($prevdir[$n]) && $prevdir[$n] == $d) {
/* In case we are shorter then previous */
$n++;
continue;
}
break;
}
if ($lastdir != ".") {
foreach(array_reverse(array_slice($prevdir, $n)) as $close) {
$retval[] = format_close_dir($tab--);
}
}
foreach(array_slice($currdir, $n) as $open) {
$retval[] = format_open_dir($open, ++$tab);
}
}
$retval[] = format_file($filename, $tab, $role);
$lastdir = $dir;
}
foreach(array_reverse(explode("/", $lastdir)) as $close) {
$retval[] = format_close_dir($tab--);
}
$retval[] = format_close_dir($tab);
return $retval;
}
function usage() {
global $argv;
echo "Usage:\n\t";
echo $argv[0], " <version> <stability>\n";
exit(1);
}
if ($argc != 3) {
usage();
}
$VERSION = $argv[1];
$STABILITY = $argv[2];
/* 0.x.y. are developmental releases and cannot be stable */
if ((int)$VERSION < 1) {
$STABILITY = "devel";
}
/* A release candidate is a "beta" stability in terms of PECL */
if (stristr($VERSION, '-rc') !== false) {
$STABILITY = "beta";
}
verify_stability($STABILITY);
verify_version($VERSION, $STABILITY);
$currtime = new DateTime('now', new DateTimeZone('UTC'));
$DATE = $currtime->format('Y-m-d');
$TIME = $currtime->format('H:i:s');
$TREE = make_tree(get_files());
$contents = file_get_contents(__DIR__ . "/package.xml.in");
$REPLACE = array(
"%RELEASE_DATE%" => $DATE,
"%RELEASE_TIME%" => $TIME,
"%RELEASE_VERSION%" => $VERSION,
"%RELEASE_STABILITY%" => $STABILITY,
"%RELEASE_FILES%" => join("\n", $TREE),
);
$contents = str_replace(array_keys($REPLACE), array_values($REPLACE), $contents);
file_put_contents(__DIR__ . "/../package.xml", $contents);
echo "Wrote package.xml\n";

View File

@@ -31,8 +31,8 @@ extern "C" {
extern zend_module_entry pdlib_module_entry;
#define phpext_pdlib_ptr &pdlib_module_entry
#define PHP_PDLIB_NAME "pdlib"
#define PHP_PDLIB_VERSION "1.0.2"
#define PHP_PDLIB_VERSION "1.1.0"
#define PHP_PDLIB_NAME "pdlib"
#ifdef PHP_WIN32
# define PHP_PDLIB_API __declspec(dllexport)
@@ -67,13 +67,13 @@ ZEND_TSRMLS_CACHE_EXTERN()
/* Tries to find given key in array */ \
data##key = zend_hash_str_find(hashtable, #key, sizeof(#key)-1); \
if (data##key == nullptr) { \
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, #error_key_missing); \
zend_throw_exception_ex(zend_ce_exception, 0, #error_key_missing); \
return; \
} \
\
/* We also need to check proper type of value in associative array */ \
if (Z_TYPE_P(data##key) != IS_LONG) { \
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, #error_key_not_long); \
zend_throw_exception_ex(zend_ce_exception, 0, #error_key_not_long); \
return; \
} \
zend_long key = Z_LVAL_P(data##key); \

View File

@@ -17,11 +17,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
std::vector<sample_pair> edges;
std::vector<unsigned long> labels;
if(zend_parse_parameters(ZEND_NUM_ARGS(), "a", &edges_arg) == FAILURE){
zend_throw_exception_ex(
zend_ce_exception,
0 TSRMLS_CC,
"Unable to parse edges in dlib_chinese_whispers");
if(zend_parse_parameters_throw(ZEND_NUM_ARGS(), "a", &edges_arg) == FAILURE){
return;
}
@@ -43,7 +39,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
if (Z_TYPE_P(edge) != IS_ARRAY) {
zend_throw_exception_ex(
zend_ce_exception,
0 TSRMLS_CC,
0,
"Each edge provided in array needs to be numeric array of 2 elements");
return;
}
@@ -55,7 +51,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
if (zend_hash_num_elements(edge_hash) != 2) {
zend_throw_exception_ex(
zend_ce_exception,
0 TSRMLS_CC,
0,
"Edges need to contain exactly two elements");
return;
}
@@ -66,7 +62,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
!zend_hash_index_exists(edge_hash, 1)) {
zend_throw_exception_ex(
zend_ce_exception,
0 TSRMLS_CC,
0,
"Edge should be numeric array with integer keys");
return;
}
@@ -78,7 +74,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
if ((Z_TYPE_P(elem_i) != IS_LONG) || (Z_TYPE_P(elem_j) != IS_LONG)) {
zend_throw_exception_ex(
zend_ce_exception,
0 TSRMLS_CC,
0,
"Both elements in each edge must be of long type");
return;
}
@@ -97,7 +93,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
}
} catch (exception& e)
{
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what());
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
return;
}
}

View File

@@ -6,7 +6,7 @@
#define PHP_DLIB_CHINESE_WHISPERS_H
ZEND_BEGIN_ARG_INFO_EX(dlib_chinese_whispers_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, edges)
ZEND_ARG_ARRAY_INFO(0, edges, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(dlib_chinese_whispers);

View File

@@ -3,7 +3,6 @@
#include <zend_exceptions.h>
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/gui_widgets.h>
#include <dlib/image_io.h>
#include <dlib/dnn.h>
#include <iostream>
@@ -25,13 +24,12 @@ PHP_METHOD(CnnFaceDetection, __construct)
cnn_face_detection *cfd = Z_CNN_FACE_DETECTION_P(getThis());
if (NULL == cfd) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to find obj in CnnFaceDetection::__construct()");
php_error_docref(NULL, E_ERROR, "Unable to find obj in CnnFaceDetection::__construct()");
return;
}
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s",
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p",
&sz_cnn_face_detection_model_path, &cnn_face_detection_model_path_len) == FAILURE){
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse face_detection_model_path");
return;
}
@@ -42,7 +40,7 @@ PHP_METHOD(CnnFaceDetection, __construct)
deserialize(cnn_face_detection_model_path) >> *pnet;
cfd->net = pnet;
} catch (exception& e) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what());
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
return;
}
}
@@ -53,8 +51,7 @@ PHP_METHOD(CnnFaceDetection, detect)
size_t img_path_len;
long upsample_num = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &img_path, &img_path_len, &upsample_num) == FAILURE){
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse detect arguments");
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|l", &img_path, &img_path_len, &upsample_num) == FAILURE){
RETURN_FALSE;
}
@@ -77,7 +74,6 @@ PHP_METHOD(CnnFaceDetection, detect)
net_type *pnet = cfd->net;
auto dets = (*pnet)(img);
int rect_count = 0;
array_init(return_value);
// Scale the detection locations back to the original image size
@@ -101,7 +97,7 @@ PHP_METHOD(CnnFaceDetection, detect)
}
catch (exception& e)
{
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what());
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
return;
}
}

View File

@@ -23,13 +23,17 @@ typedef struct _cnn_face_detection {
} cnn_face_detection;
ZEND_BEGIN_ARG_INFO_EX(cnn_face_detection_ctor_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, cnn_face_detection_model_path)
ZEND_ARG_TYPE_INFO(0, cnn_face_detection_model_path, IS_STRING, 0)
ZEND_END_ARG_INFO()
PHP_METHOD(CnnFaceDetection, __construct);
ZEND_BEGIN_ARG_INFO_EX(cnn_face_detection_detect_arginfo, 0, 0, 2)
ZEND_ARG_INFO(0, img_path)
ZEND_ARG_INFO(0, upsample_num)
ZEND_BEGIN_ARG_INFO_EX(cnn_face_detection_detect_arginfo, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, img_path, IS_STRING, 0)
#if PHP_VERSION_ID < 80000
ZEND_ARG_TYPE_INFO(0, upsample_num, IS_LONG, 0)
#else
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, upsample_num, IS_LONG, 0, "0")
#endif
ZEND_END_ARG_INFO()
PHP_METHOD(CnnFaceDetection, detect);

View File

@@ -4,7 +4,6 @@
#include <zend_exceptions.h>
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/gui_widgets.h>
#include <dlib/image_io.h>
#include <iostream>
@@ -17,8 +16,7 @@ PHP_FUNCTION(dlib_face_detection)
size_t img_path_len;
long upsample_num = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &img_path, &img_path_len, &upsample_num) == FAILURE) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse dlib_face_detection arguments");
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|l", &img_path, &img_path_len, &upsample_num) == FAILURE) {
RETURN_FALSE;
}
try {

View File

@@ -6,8 +6,12 @@
#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_ARG_INFO(0, upsample_num)
ZEND_ARG_TYPE_INFO(0, img_path, IS_STRING, 0)
#if PHP_VERSION_ID < 80000
ZEND_ARG_TYPE_INFO(0, upsample_num, IS_LONG, 0)
#else
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, upsample_num, IS_LONG, 0, "0")
#endif
ZEND_END_ARG_INFO()
PHP_FUNCTION(dlib_face_detection);

View File

@@ -5,7 +5,6 @@
#include <zend_exceptions.h>
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/image_processing/render_face_detections.h>
#include <dlib/image_processing.h>
#include <dlib/image_io.h>
#include <iostream>
@@ -27,7 +26,7 @@ PHP_FUNCTION(dlib_face_landmark_detection)
char *img_path;
size_t shape_predictor_file_path_len, img_path_len;
if(zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &shape_predictor_file_path, &shape_predictor_file_path_len,
if(zend_parse_parameters_throw(ZEND_NUM_ARGS(), "ss", &shape_predictor_file_path, &shape_predictor_file_path_len,
&img_path, &img_path_len) == FAILURE){
RETURN_FALSE;
}
@@ -52,7 +51,7 @@ PHP_FUNCTION(dlib_face_landmark_detection)
zval ARRAY_NAME_WITH_INDEX(face, j);
array_init(&ARRAY_NAME_WITH_INDEX(face, j));
for (int k = 0; k < shape.num_parts(); k++) {
for (unsigned int k = 0; k < shape.num_parts(); k++) {
zval ARRAY_NAME_WITH_INDEX(part, k);
array_init(&ARRAY_NAME_WITH_INDEX(part, k));
dlib::point p = shape.part(k);
@@ -78,14 +77,13 @@ PHP_METHOD(FaceLandmarkDetection, __construct)
face_landmark_detection *fld = Z_FACE_LANDMARK_DETECTION_P(getThis());
if (nullptr == fld) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to find obj in FaceLandmarkDetection::__construct()");
php_error_docref(NULL, E_ERROR, "Unable to find obj in FaceLandmarkDetection::__construct()");
return;
}
// Parse predictor model's path
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s",
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p",
&sz_shape_predictor_file_path, &shape_predictor_file_path_len) == FAILURE){
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse shape_predictor_file_path");
return;
}
@@ -95,7 +93,7 @@ PHP_METHOD(FaceLandmarkDetection, __construct)
fld->sp = new shape_predictor;
deserialize(shape_predictor_file_path) >> *(fld->sp);
} catch (exception& e) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what());
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
return;
}
}
@@ -114,8 +112,7 @@ PHP_METHOD(FaceLandmarkDetection, detect)
// Parse path to image and bounding box. Bounding box is associative array of 4 elements - "top", "bottom", "left" and "right".
//
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sa", &img_path, &img_path_len, &bounding_box) == FAILURE){
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse detect arguments");
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "pa", &img_path, &img_path_len, &bounding_box) == FAILURE){
return;
}
@@ -123,7 +120,7 @@ PHP_METHOD(FaceLandmarkDetection, detect)
HashTable *bounding_box_hash = Z_ARRVAL_P(bounding_box);
uint32_t bounding_box_num_elements = zend_hash_num_elements(bounding_box_hash);
if (bounding_box_num_elements < 4) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Bounding box (second argument) needs to have at least 4 elements");
zend_throw_exception_ex(zend_ce_exception, 0, "Bounding box (second argument) needs to have at least 4 elements");
return;
}
@@ -151,7 +148,7 @@ PHP_METHOD(FaceLandmarkDetection, detect)
array_init(&rect_arr);
array_init(&parts_arr);
for (int i = 0; i < shape.num_parts(); i++) {
for (unsigned int i = 0; i < shape.num_parts(); i++) {
zval part;
array_init(&part);
dlib::point p = shape.part(i);
@@ -169,7 +166,7 @@ PHP_METHOD(FaceLandmarkDetection, detect)
add_assoc_zval(return_value, "rect", &rect_arr);
add_assoc_zval(return_value, "parts", &parts_arr);
} catch (exception& e) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what());
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
return;
}
}

View File

@@ -9,9 +9,9 @@
using namespace dlib;
ZEND_BEGIN_ARG_INFO_EX(dlib_face_landmark_detection_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, shape_predictor_file_path)
ZEND_ARG_INFO(0, img_path)
ZEND_BEGIN_ARG_INFO_EX(dlib_face_landmark_detection_arginfo, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, shape_predictor_file_path, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, img_path, IS_STRING, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(dlib_face_landmark_detection);
@@ -21,13 +21,13 @@ typedef struct _face_landmark_detection {
} face_landmark_detection;
ZEND_BEGIN_ARG_INFO_EX(face_landmark_detection_ctor_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, shape_predictor_file_path)
ZEND_ARG_TYPE_INFO(0, shape_predictor_file_path, IS_STRING, 0)
ZEND_END_ARG_INFO()
PHP_METHOD(FaceLandmarkDetection, __construct);
ZEND_BEGIN_ARG_INFO_EX(face_landmark_detection_detect_arginfo, 0, 0, 2)
ZEND_ARG_INFO(0, img_path)
ZEND_ARG_INFO(0, bounding_box)
ZEND_ARG_TYPE_INFO(0, img_path, IS_STRING, 0)
ZEND_ARG_ARRAY_INFO(0, bounding_box, 0)
ZEND_END_ARG_INFO()
PHP_METHOD(FaceLandmarkDetection, detect);

View File

@@ -22,13 +22,12 @@ PHP_METHOD(FaceRecognition, __construct)
face_recognition *fr = Z_FACE_RECOGNITION_P(getThis());
if (NULL == fr) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to find obj in FaceRecognition::__construct()");
php_error_docref(NULL, E_ERROR, "Unable to find obj in FaceRecognition::__construct()");
return;
}
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s",
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p",
&sz_face_recognition_model_path, &face_recognition_model_path_len) == FAILURE){
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse face_recognition_model_path");
return;
}
@@ -37,7 +36,7 @@ PHP_METHOD(FaceRecognition, __construct)
fr->net = new anet_type;
deserialize(face_recognition_model_path) >> *(fr->net);
} catch (exception& e) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what());
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
return;
}
}
@@ -73,25 +72,24 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
zval *shape;
long num_jitters = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sa|l", &img_path, &img_path_len, &shape, &num_jitters) == FAILURE){
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse computeDescriptor arguments");
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "pa|l", &img_path, &img_path_len, &shape, &num_jitters) == FAILURE){
return;
}
HashTable *shape_hash = Z_ARRVAL_P(shape);
uint32_t shape_hash_num_elements = zend_hash_num_elements(shape_hash);
if (shape_hash_num_elements != 2) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Shape (second argument) needs to have exactly 2 elements - keys \"rect\" and \"parts\"");
zend_throw_exception_ex(zend_ce_exception, 0, "Shape (second argument) needs to have exactly 2 elements - keys \"rect\" and \"parts\"");
return;
}
zval *rect_zval = zend_hash_str_find(shape_hash, "rect", sizeof("rect")-1);
if (rect_zval == nullptr) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Shape (second argument) array needs to have \"rect\" key"); \
zend_throw_exception_ex(zend_ce_exception, 0, "Shape (second argument) array needs to have \"rect\" key"); \
return;
}
if (Z_TYPE_P(rect_zval) != IS_ARRAY) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Value of shape's key \"rect\" must be array");
zend_throw_exception_ex(zend_ce_exception, 0, "Value of shape's key \"rect\" must be array");
return;
}
HashTable *rect_hash = Z_ARRVAL_P(rect_zval);
@@ -104,11 +102,11 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
zval *parts_zval = zend_hash_str_find(shape_hash, "parts", sizeof("parts")-1);
if (parts_zval == nullptr) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Shape (second argument) array needs to have \"parts\" key"); \
zend_throw_exception_ex(zend_ce_exception, 0, "Shape (second argument) array needs to have \"parts\" key"); \
return;
}
if (Z_TYPE_P(parts_zval) != IS_ARRAY) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Value of shape's key \"parts\" must be array");
zend_throw_exception_ex(zend_ce_exception, 0, "Value of shape's key \"parts\" must be array");
return;
}
HashTable *parts_hash = Z_ARRVAL_P(parts_zval);
@@ -117,7 +115,7 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
point parts_points[parts_count];
if ((parts_count != 5) && (parts_count != 68)) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC,
zend_throw_exception_ex(zend_ce_exception, 0,
"The full_object_detection must use the iBUG 300W 68 point face landmark style or dlib's 5 point style");
return;
}
@@ -137,17 +135,17 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
PARSE_POINT(x)
PARSE_POINT(y)
if (num_index > parts_count) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Internal error, bad parsing of parts array");
zend_throw_exception_ex(zend_ce_exception, 0, "Internal error, bad parsing of parts array");
return;
}
parts_points[num_index] = point(x, y);
} else {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Values from parts array must be arrays with \"x\" and \"y\" keys");
zend_throw_exception_ex(zend_ce_exception, 0, "Values from parts array must be arrays with \"x\" and \"y\" keys");
return;
}
break;
case HASH_KEY_IS_STRING:
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Parts array must be indexed and it contains string keys");
zend_throw_exception_ex(zend_ce_exception, 0, "Parts array must be indexed and it contains string keys");
return;
break;
}
@@ -183,7 +181,7 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
add_next_index_double(return_value, d);
}
} catch (exception& e) {
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, e.what());
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
return;
}
}

View File

@@ -44,14 +44,18 @@ typedef struct _face_recognition {
} face_recognition;
ZEND_BEGIN_ARG_INFO_EX(face_recognition_ctor_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, face_recognition_model_path)
ZEND_ARG_TYPE_INFO(0, face_recognition_model_path, IS_STRING, 0)
ZEND_END_ARG_INFO()
PHP_METHOD(FaceRecognition, __construct);
ZEND_BEGIN_ARG_INFO_EX(face_recognition_compute_descriptor_arginfo, 0, 0, 3)
ZEND_ARG_INFO(0, img_path)
ZEND_ARG_INFO(0, landmarks)
ZEND_ARG_INFO(0, num_jitters)
ZEND_BEGIN_ARG_INFO_EX(face_recognition_compute_descriptor_arginfo, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, img_path, IS_STRING, 0)
ZEND_ARG_ARRAY_INFO(0, landmarks, 0)
#if PHP_VERSION_ID < 80000
ZEND_ARG_TYPE_INFO(0, num_jitters, IS_LONG, 0)
#else
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, num_jitters, IS_LONG, 0, "1")
#endif
ZEND_END_ARG_INFO()
PHP_METHOD(FaceRecognition, computeDescriptor);

View File

@@ -13,24 +13,20 @@ PHP_FUNCTION(dlib_vector_length)
{
zval *x_arg, *y_arg;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "aa", &x_arg, &y_arg) == FAILURE) {
zend_throw_exception_ex(
zend_ce_exception,
0 TSRMLS_CC,
"Unable to parse arrays in dlib_vector_length");
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "aa", &x_arg, &y_arg) == FAILURE) {
return;
}
zval *elem_x, *elem_y;
double sum = 0.0;
int i, len;
unsigned int i, len;
len = zend_hash_num_elements(Z_ARRVAL_P(x_arg));
if (len != zend_hash_num_elements(Z_ARRVAL_P(y_arg))) {
zend_throw_exception_ex(
zend_ce_exception,
0 TSRMLS_CC,
0,
"The arrays have different sizes");
return;
}

View File

@@ -2,8 +2,8 @@
#define PHP_DLIB_VECTOR_H
ZEND_BEGIN_ARG_INFO_EX(dlib_vector_length_arginfo, 0, 0, 2)
ZEND_ARG_INFO(1, x_arg)
ZEND_ARG_INFO(1, y_arg)
ZEND_ARG_ARRAY_INFO(0, x_arg, 0)
ZEND_ARG_ARRAY_INFO(0, y_arg, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(dlib_vector_length);

View File

@@ -6,10 +6,9 @@ Args given to chinese_whispers functions is not correct
<?php
try {
dlib_chinese_whispers("foo");
} catch (Exception $e) {
} catch (Error $e) {
var_dump($e->getMessage());
}
?>
--EXPECTF--
Warning: dlib_chinese_whispers() expects parameter 1 to be array, string given in %s on line 3
string(46) "Unable to parse edges in dlib_chinese_whispers"
string(%d) "%s type array, string given"

View File

@@ -6,10 +6,10 @@ Testing CnnFaceDetection constructor without arguments
<?php
try {
new CnnFaceDetection();
} catch (Exception $e) {
} catch (Error $e) {
var_dump($e->getMessage());
}
?>
--EXPECTF--
Warning: CnnFaceDetection::__construct() expects exactly 1 parameter, 0 given in %s on line 3
string(41) "Unable to parse face_detection_model_path"
string(%d) "CnnFaceDetection::__construct() expects exactly 1 %s, 0 given"

View File

@@ -1,7 +1,10 @@
--TEST--
Frontal face detection.
--SKIPIF--
<?php if (!extension_loaded("pdlib") print "skip"; ?>
<?php
if (!extension_loaded("pdlib")) die('skip pdlib extension missing');
if (getenv("SKIP_SLOW_TESTS")) die('skip slow test');
?>
--FILE--
<?php
printf("Simple detection\n");
@@ -25,4 +28,4 @@ Faces found = 1
Face[0] in bounding box (left=214, top=194, right=393, bottom=373)
Detection with upsampling
Faces found = 1
Face[0] in bounding box (left=201, top=180, right=386, bottom=366)
Face[0] in bounding box (left=201, top=180, right=386, bottom=366)

View File

@@ -6,7 +6,7 @@ Testing FaceLandmarkDetection constructor without arguments
<?php
try {
new FaceLandmarkDetection();
} catch (Exception $e) {
} catch (Error $e) {
var_dump($e->getMessage());
}
try {
@@ -16,6 +16,5 @@ try {
}
?>
--EXPECTF--
Warning: FaceLandmarkDetection::__construct() expects exactly 1 parameter, 0 given in %s on line 3
string(41) "Unable to parse shape_predictor_file_path"
string(%d) "FaceLandmarkDetection::__construct() expects exactly 1 %s, 0 given"
string(45) "Unable to open non-existent file for reading."

View File

@@ -6,10 +6,9 @@ Testing FaceRecognition constructor without arguments
<?php
try {
new FaceRecognition();
} catch (Exception $e) {
} catch (Error $e) {
var_dump($e->getMessage());
}
?>
--EXPECTF--
Warning: FaceRecognition::__construct() expects exactly 1 parameter, 0 given in %s on line 3
string(43) "Unable to parse face_recognition_model_path"
string(%d) "FaceRecognition::__construct() expects exactly 1 %s, 0 given"

View File

@@ -1,7 +1,11 @@
--TEST--
Full test for face recognition - download models, detect faces, landmark detection and face recognition.
--SKIPIF--
<?php if (!extension_loaded("pdlib") || (function_exists("bzopen"))) print "skip"; ?>
<?php
if (!extension_loaded("pdlib")) die('skip pdlib extension missing');
if (!function_exists("bzopen")) die('skip bz2 extension missing');
if (getenv("SKIP_ONLINE_TESTS")) die('skip online test');
?>
--FILE--
<?php
$models = array(
@@ -55,6 +59,6 @@ Processing prediction model
Processing recognition model
Detection
Faces found = 1
Face[0] in bounding box (left=187, top=186, right=357, bottom=355)
Face[0] in bounding box (left=191, top=200, right=355, bottom=363)
Since we used model with 5 shape predictions, we found 5 landmark parts
Descriptor is vector of 128 dimensions
Descriptor is vector of 128 dimensions