26 Commits
v1.0 ... v1.0.2

Author SHA1 Message Date
Matias De lellis
d3b91453bb Dont install useless php extension 2020-04-24 11:57:07 -03:00
Matias De lellis
3e050a4772 Improve travis 2020-04-24 11:40:40 -03:00
Matias De lellis
16d19188c3 Improve travis 2020-04-24 11:10:33 -03:00
Matias De lellis
9d351afd07 Test on tavis. 2020-04-24 10:41:21 -03:00
Matias De lellis
ca007e400a Append more information to phpinfo()
If you think it works slow, make sure it is compiled with any of these instructions

> pdlib
>
> PDlib support => enabled
> Pdlib Version => 1.0.2
> DLIB_USE_CUDA => false
> DLIB_USE_BLAS => true
> DLIB_USE_LAPACK => true
> USE_AVX_INSTRUCTIONS => false
> USE_AVX2_INSTRUCTIONS => false
> USE_NEON_INSTRUCTIONS => false
> USE_SSE2_INSTRUCTIONS => true
> USE_SSE4_INSTRUCTIONS => false
2020-04-19 20:27:51 -03:00
Matias De lellis
2b06ea45c4 Improve messages when configure build. 2020-04-19 19:26:22 -03:00
matiasdelellis
c9e1015197 Merge pull request #2 from matiasdelellis/dlib_length
Dlib length
2020-04-14 20:05:40 -03:00
Matias De lellis
76da4d9b84 Multiply directly instead of using pow ($number, 2);
This small optimization allows us to improve from:

 OLD php: 0.012100038051605 Sec.
 New native: 0.0096198790073395 Sec.

(This is already 20 percent faster)

..to:
 OLD php: 0.012276937961578 Sec.
 New native: 0.0022540950775146 Sec.

What is 80 percent faster than our PHP class.
2020-04-14 10:45:13 -03:00
Matias De lellis
75adc6f801 Use references as an attempt to optimize. 2020-04-14 10:26:26 -03:00
Matias De lellis
4a2e4ff112 Implement dlib_vector_length to calculate the euclidean distance of the vectors
It not use the 'length' native versions of dlib, due I have to convert the
array to the vector, which will take the same time, and then I will use the
native method.
2020-04-14 09:45:16 -03:00
matiasdelellis
78819eb815 More description 2020-04-13 18:54:24 -03:00
matiasdelellis
e69df35435 Explain why the fork 2020-04-13 18:39:48 -03:00
matiasdelellis
a5e7cf3535 Move Instalation doc to wiki 2020-04-13 18:33:54 -03:00
matiasdelellis
80f8101e15 Merge pull request #1 from matiasdelellis/improve-hog
Improve hog
2020-04-13 18:23:59 -03:00
Matias De lellis
dfd6a952fb upsample_num as references 2020-03-07 12:55:39 -03:00
Matias De lellis
cd4e7bcbdf Dont upsamply by default in CNN, and optional argument on fhog for that. 2020-03-07 10:46:12 -03:00
Matias De lellis
afc9164127 HOG detector also must return the rectangles of the detections. 2020-02-29 14:04:41 -03:00
goodspb
1e492f2e12 Merge pull request #18 from stalker314314/fixing-tests-on-different-environments
Fixing tests on different environments
2020-01-31 11:25:09 +08:00
Branko Kokanovic
a83750a4ff Fixing tests, closes #14 2019-11-28 23:14:34 +01:00
goodspb
c08a7608a2 Merge pull request #13 from SlavikCA/patch-1
README: requirement of libx11-dev; recommendation of BLAS
2019-01-06 17:37:36 +08:00
Slavik
fcb54ace66 README: requirement of libx11-dev; recommendation of BLAS 2019-01-05 23:55:22 -08:00
goodspb
606a6717ea Merge pull request #11 from stalker314314/patch-1
Fix git -> https in README
2019-01-01 11:06:15 +08:00
Branko Kokanovic
0fd67af03e Fix git -> https in README
People usually don't have access to Github for DLib, so previous command will not work out-of-box. Better to suggest https:// alternative
2018-12-30 19:29:39 +00:00
Branko Kokanovic
54f3b75139 Merge pull request #9 from goodspb/master
refresh
2018-08-30 21:19:36 +02:00
Branko Kokanovic
ac67a9992d Merge pull request #6 from goodspb/master
refresh
2018-08-29 00:42:25 +02:00
Branko Kokanovic
9e429a772a Merge branch 'goodspb-master' 2018-08-29 00:40:55 +02:00
18 changed files with 303 additions and 143 deletions

13
.gitignore vendored
View File

@@ -28,12 +28,11 @@ missing
mkinstalldirs
modules
run-tests.php
tests/*/*.diff
tests/*/*.out
tests/*/*.php
tests/*/*.exp
tests/*/*.log
tests/*/*.sh
tests/*.diff
tests/*.out
tests/*.php
tests/*.exp
tests/*.log
tests/*.sh
.idea
cmake-build-debug

28
.travis.yml Normal file
View File

@@ -0,0 +1,28 @@
dist: bionic
sudo: false
language: php
php:
- 7.1
- 7.2
- 7.3
- 7.4
before_install:
- sudo sh -c 'echo "deb https://repo.delellis.com.ar bionic bionic" > /etc/apt/sources.list.d/20-pdlib.list'
- wget -qO - https://repo.delellis.com.ar/repo.gpg.key | sudo apt-key add -
- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 762E3157
- sudo apt update
- sudo apt-get install libdlib-dev
- phpize
- ./configure --enable-debug
- make
- sudo make install
- echo "extension=pdlib.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
script:
- export TEST_PHP_EXECUTABLE=`which php`
- export NO_INTERACTION=1
- php run-tests.php -q --show-diff

View File

@@ -1,61 +1,15 @@
# PDlib - A PHP extension for Dlib
# PDlib - A PHP extension for [Dlib](https://github.com/davisking/dlib)
## Requirements
- Dlib 19.13+
- PHP 7.0+
- C++11
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.
## Dependencies
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.
### Dlib
Install Dlib as shared library
```bash
git clone git@github.com:davisking/dlib.git
cd dlib/dlib
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON ..
make
sudo make install
```
## 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.
## Installation
```bash
git clone https://github.com/goodspb/pdlib.git
cd pdlib
phpize
./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
```
Read [Installation](https://github.com/matiasdelellis/pdlib/wiki/Installation) documentation on the wiki for details.
## Usage
@@ -92,9 +46,8 @@ If you want to use HOG based approach:
<?php
// face detection
$faceCount = dlib_face_detection("~/a.jpg");
// how mary face in the picture.
var_dump($faceCount);
detected_faces = dlib_face_detection("image.jpg");
// $detected_faces is indexed array, where values are assoc arrays with "top", "bottom", "left" and "right" values
```
If you want to use CNN approach (and CNN model):

View File

@@ -1,10 +1,3 @@
dnl $Id$
dnl config.m4 for extension pdlib
dnl Comments in this file start with the string 'dnl'.
dnl Remove where necessary. This file will not work
dnl without editing.
if test -z "$PHP_DEBUG"; then
AC_ARG_ENABLE(debug,
[ --enable-debug compile with debugging symbols],[
@@ -14,42 +7,65 @@ 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])
if test "$PHP_PDLIB" != "no"; then
dnl using C++11
CXXFLAGS="-std=c++11"
PHP_REQUIRE_CXX()
PHP_ADD_LIBRARY(stdc++, 1, PDLIB_SHARED_LIBADD)
PHP_SUBST(PDLIB_SHARED_LIBADD)
dnl using C++11
CXXFLAGS="-std=c++11"
PHP_REQUIRE_CXX()
PHP_ADD_LIBRARY(stdc++, 1, PDLIB_SHARED_LIBADD)
PHP_SUBST(PDLIB_SHARED_LIBADD)
pdlib_src_files="pdlib.cc \
src/chinese_whispers.cc \
src/face_detection.cc \
src/face_landmark_detection.cc \
src/face_recognition.cc \
src/cnn_face_detection.cc "
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 \
"
AC_MSG_CHECKING(for pkg-config)
if test ! -f "$PKG_CONFIG"; then
PKG_CONFIG=`which pkg-config`
fi
if test -x "$PKG_CONFIG" && $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(pkg-config not found)
fi
PHP_EVAL_LIBLINE($LIBDLIB_LIBDIR, PDLIB_SHARED_LIBADD)
PHP_EVAL_INCLINE($LIBDLIB_CFLAGS)
PHP_NEW_EXTENSION(pdlib, $pdlib_src_files, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
AC_MSG_CHECKING(for pkg-config)
if test ! -f "$PKG_CONFIG"; then
PKG_CONFIG=`which pkg-config`
fi
if test -f "$PKG_CONFIG"; then
AC_MSG_RESULT(found)
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)
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 ""
])

View File

@@ -22,17 +22,20 @@ 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"
#include "src/face_recognition.h"
#include "src/cnn_face_detection.h"
#include "src/face_landmark_detection.h"
#include "src/vector.h"
/* If you declare any globals in php_pdlib.h uncomment this:
ZEND_DECLARE_MODULE_GLOBALS(pdlib)
@@ -60,27 +63,6 @@ PHP_INI_END()
*/
/* }}} */
/* Remove the following function when you have successfully modified config.m4
so that your module can be compiled into PHP, it exists only for testing
purposes. */
/* Every user-visible function in PHP should document itself in the source */
/* {{{ proto string confirm_pdlib_compiled(string arg)
Return a string to confirm that the module is compiled in */
PHP_FUNCTION(confirm_pdlib_compiled)
{
char *arg = NULL;
size_t arg_len, len;
zend_string *strg;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &arg, &arg_len) == FAILURE) {
return;
}
strg = strpprintf(0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "pdlib", arg);
RETURN_STR(strg);
}
/* }}} */
/* 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
@@ -246,7 +228,49 @@ PHP_RSHUTDOWN_FUNCTION(pdlib)
PHP_MINFO_FUNCTION(pdlib)
{
php_info_print_table_start();
php_info_print_table_header(2, "pdlib support", "enabled");
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);
#ifdef DLIB_USE_CUDA
php_info_print_table_header(2, "DLIB_USE_CUDA", "true");
#else
php_info_print_table_header(2, "DLIB_USE_CUDA", "false");
#endif
#ifdef DLIB_USE_BLAS
php_info_print_table_header(2, "DLIB_USE_BLAS", "true");
#else
php_info_print_table_header(2, "DLIB_USE_BLAS", "false");
#endif
#ifdef DLIB_USE_LAPACK
php_info_print_table_header(2, "DLIB_USE_LAPACK", "true");
#else
php_info_print_table_header(2, "DLIB_USE_LAPACK", "false");
#endif
#ifdef DLIB_HAVE_AVX
php_info_print_table_header(2, "USE_AVX_INSTRUCTIONS", "true");
#else
php_info_print_table_header(2, "USE_AVX_INSTRUCTIONS", "false");
#endif
#ifdef DLIB_HAVE_AVX2
php_info_print_table_header(2, "USE_AVX2_INSTRUCTIONS", "true");
#else
php_info_print_table_header(2, "USE_AVX2_INSTRUCTIONS", "false");
#endif
#ifdef DLIB_HAVE_NEON
php_info_print_table_header(2, "USE_NEON_INSTRUCTIONS", "true");
#else
php_info_print_table_header(2, "USE_NEON_INSTRUCTIONS", "false");
#endif
#ifdef DLIB_HAVE_SSE2
php_info_print_table_header(2, "USE_SSE2_INSTRUCTIONS", "true");
#else
php_info_print_table_header(2, "USE_SSE2_INSTRUCTIONS", "false");
#endif
#ifdef DLIB_HAVE_SSE41
php_info_print_table_header(2, "USE_SSE4_INSTRUCTIONS", "true");
#else
php_info_print_table_header(2, "USE_SSE4_INSTRUCTIONS", "false");
#endif
php_info_print_table_end();
/* Remove comments if you have entries in php.ini
@@ -260,10 +284,10 @@ PHP_MINFO_FUNCTION(pdlib)
* Every user visible function must have an entry in pdlib_functions[].
*/
const zend_function_entry pdlib_functions[] = {
PHP_FE(confirm_pdlib_compiled, NULL)
PHP_FE(dlib_chinese_whispers, dlib_chinese_whispers_arginfo)
PHP_FE(dlib_face_detection, dlib_face_detection_arginfo)
PHP_FE(dlib_face_landmark_detection, dlib_face_landmark_detection_arginfo)
PHP_FE(dlib_vector_length, dlib_vector_length_arginfo)
PHP_FE_END /* Must be the last line in pdlib_functions[] */
};
/* }}} */
@@ -272,7 +296,7 @@ const zend_function_entry pdlib_functions[] = {
*/
zend_module_entry pdlib_module_entry = {
STANDARD_MODULE_HEADER,
"pdlib",
PHP_PDLIB_NAME,
pdlib_functions,
PHP_MINIT(pdlib),
PHP_MSHUTDOWN(pdlib),

View File

@@ -31,7 +31,8 @@ extern "C" {
extern zend_module_entry pdlib_module_entry;
#define phpext_pdlib_ptr &pdlib_module_entry
#define PHP_PDLIB_VERSION "0.1.0" /* Replace with version number for your extension */
#define PHP_PDLIB_NAME "pdlib"
#define PHP_PDLIB_VERSION "1.0.2"
#ifdef PHP_WIN32
# define PHP_PDLIB_API __declspec(dllexport)

View File

@@ -51,7 +51,7 @@ PHP_METHOD(CnnFaceDetection, detect)
{
char *img_path;
size_t img_path_len;
long upsample_num = 1;
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");

View File

@@ -2,6 +2,7 @@
#include "../php_pdlib.h"
#include "face_detection.h"
#include <zend_exceptions.h>
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/gui_widgets.h>
#include <dlib/image_io.h>
@@ -14,19 +15,41 @@ PHP_FUNCTION(dlib_face_detection)
{
char *img_path;
size_t img_path_len;
long upsample_num = 0;
if(zend_parse_parameters(ZEND_NUM_ARGS(), "s", &img_path, &img_path_len) == FAILURE){
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");
RETURN_FALSE;
}
try {
frontal_face_detector detector = get_frontal_face_detector();
pyramid_down<2> pyr;
array2d<unsigned char> img;
load_image(img, img_path);
pyramid_up(img);
unsigned int levels = upsample_num;
while (levels > 0) {
levels--;
pyramid_up(img, pyr);
}
array_init(return_value);
std::vector<rectangle> dets = detector(img);
RETURN_LONG(dets.size());
for (unsigned long i = 0; i < dets.size(); ++i) {
rectangle rect = pyr.rect_down(dets[i], upsample_num);
zval rect_arr;
array_init(&rect_arr);
add_assoc_long(&rect_arr, "left", rect.left());
add_assoc_long(&rect_arr, "top", rect.top());
add_assoc_long(&rect_arr, "right", rect.right());
add_assoc_long(&rect_arr, "bottom", rect.bottom());
// Add this assoc array to returned array
//
add_next_index_zval(return_value, &rect_arr);
}
}
catch (exception& e)
{

View File

@@ -7,6 +7,7 @@
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_END_ARG_INFO()
PHP_FUNCTION(dlib_face_detection);

47
src/vector.cc Normal file
View File

@@ -0,0 +1,47 @@
#include "../php_pdlib.h"
#include "vector.h"
#include <cmath>
#include <zend_exceptions.h>
#include <iostream>
using namespace std;
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");
return;
}
zval *elem_x, *elem_y;
double sum = 0.0;
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,
"The arrays have different sizes");
return;
}
for (i = 0 ; i < len ; i++) {
elem_x = zend_hash_index_find(Z_ARRVAL_P(x_arg), i);
elem_y = zend_hash_index_find(Z_ARRVAL_P(y_arg), i);
sum += (Z_DVAL_P(elem_x) - Z_DVAL_P(elem_y))*(Z_DVAL_P(elem_x) - Z_DVAL_P(elem_y));
}
RETURN_DOUBLE(sqrt(sum));
}

10
src/vector.h Normal file
View File

@@ -0,0 +1,10 @@
#ifndef PHP_DLIB_VECTOR_H
#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_END_ARG_INFO()
PHP_FUNCTION(dlib_vector_length);
#endif //PHP_DLIB_VECTOR_H

View File

@@ -10,6 +10,6 @@ try {
var_dump($e->getMessage());
}
?>
--EXPECT--
Warning: dlib_chinese_whispers() expects parameter 1 to be array, string given in /home/branko/pdlib/tests/chinese_whispers_wrong_arg_type_error.php on line 3
--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"

View File

@@ -10,6 +10,6 @@ try {
var_dump($e->getMessage());
}
?>
--EXPECT--
Warning: CnnFaceDetection::__construct() expects exactly 1 parameter, 0 given in /home/branko/pdlib/tests/cnn_face_detection_ctor_error.php on line 3
--EXPECTF--
Warning: CnnFaceDetection::__construct() expects exactly 1 parameter, 0 given in %s on line 3
string(41) "Unable to parse face_detection_model_path"

View File

@@ -0,0 +1,28 @@
--TEST--
Frontal face detection.
--SKIPIF--
<?php if (!extension_loaded("pdlib") print "skip"; ?>
--FILE--
<?php
printf("Simple detection\n");
$detected_faces = dlib_face_detection(__DIR__ . "/lenna.jpg");
printf("Faces found = %d\n", count($detected_faces));
foreach($detected_faces as $index => $detected_face) {
printf("Face[%d] in bounding box (left=%d, top=%d, right=%d, bottom=%d)\n", $index,
$detected_face["left"], $detected_face["top"], $detected_face["right"], $detected_face["bottom"]);
}
printf("Detection with upsampling\n");
$detected_faces = dlib_face_detection(__DIR__ . "/lenna.jpg", 1);
printf("Faces found = %d\n", count($detected_faces));
foreach($detected_faces as $index => $detected_face) {
printf("Face[%d] in bounding box (left=%d, top=%d, right=%d, bottom=%d)\n", $index,
$detected_face["left"], $detected_face["top"], $detected_face["right"], $detected_face["bottom"]);
}
?>
--EXPECT--
Simple detection
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)

View File

@@ -15,7 +15,7 @@ try {
var_dump($e->getMessage());
}
?>
--EXPECT--
Warning: FaceLandmarkDetection::__construct() expects exactly 1 parameter, 0 given in /home/branko/pdlib/tests/face_landmark_detection_ctor_error.php on line 3
--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(45) "Unable to open non-existent file for reading."
string(45) "Unable to open non-existent file for reading."

View File

@@ -10,6 +10,6 @@ try {
var_dump($e->getMessage());
}
?>
--EXPECT--
Warning: FaceRecognition::__construct() expects exactly 1 parameter, 0 given in /home/branko/pdlib/tests/face_recognition_ctor_error.php on line 3
string(43) "Unable to parse face_recognition_model_path"
--EXPECTF--
Warning: FaceRecognition::__construct() expects exactly 1 parameter, 0 given in %s on line 3
string(43) "Unable to parse face_recognition_model_path"

20
tests/vector_length.phpt Normal file
View File

@@ -0,0 +1,20 @@
--TEST--
Basic tests for dlib_vector_length
--SKIPIF--
<?php if (!extension_loaded("pdlib")) print "skip"; ?>
--FILE--
<?php
$vectorAL = [0.0, 0.0];
$vectorAR = [0.0, 1.0];
var_dump(dlib_vector_length($vectorAL, $vectorAR));
$vectorBL = [0.0, 0.0, -1.0];
$vectorBR = [0.0, 0.0, 1.0];
var_dump(dlib_vector_length($vectorBL, $vectorBR));
$vectorCL = [0.0, 2.5, 1.0];
$vectorCR = [0.0, 1.0, 1.0];
var_dump(dlib_vector_length($vectorCL, $vectorCR));
?>
--EXPECT--
float(1)
float(2)
float(1.5)

10
tests/version.phpt Normal file
View File

@@ -0,0 +1,10 @@
--TEST--
Just test php extension version
--SKIPIF--
<?php if (!extension_loaded("pdlib")) print "skip"; ?>
--FILE--
<?php
var_dump(phpversion('pdlib'));
?>
--EXPECT--
string(5) "1.0.2"