Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3b91453bb | ||
|
|
3e050a4772 | ||
|
|
16d19188c3 | ||
|
|
9d351afd07 | ||
|
|
ca007e400a | ||
|
|
2b06ea45c4 | ||
|
|
c9e1015197 | ||
|
|
76da4d9b84 | ||
|
|
75adc6f801 | ||
|
|
4a2e4ff112 | ||
|
|
78819eb815 | ||
|
|
e69df35435 | ||
|
|
a5e7cf3535 | ||
|
|
80f8101e15 |
28
.travis.yml
Normal file
28
.travis.yml
Normal 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
|
||||||
66
README.md
66
README.md
@@ -1,69 +1,15 @@
|
|||||||
# PDlib - A PHP extension for Dlib
|
# PDlib - A PHP extension for [Dlib](https://github.com/davisking/dlib)
|
||||||
|
|
||||||
## Requirements
|
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.
|
||||||
- Dlib 19.13+
|
|
||||||
- PHP 7.0+
|
|
||||||
- C++11
|
|
||||||
- libx11-dev (on Ubuntu: `sudo apt-get install libx11-dev`)
|
|
||||||
|
|
||||||
## Recommended
|
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.
|
||||||
- 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`
|
|
||||||
|
|
||||||
## Dependencies
|
## 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.
|
||||||
### 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
|
## Installation
|
||||||
|
|
||||||
```bash
|
Read [Installation](https://github.com/matiasdelellis/pdlib/wiki/Installation) documentation on the wiki for details.
|
||||||
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
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|||||||
98
config.m4
98
config.m4
@@ -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
|
if test -z "$PHP_DEBUG"; then
|
||||||
AC_ARG_ENABLE(debug,
|
AC_ARG_ENABLE(debug,
|
||||||
[ --enable-debug compile with debugging symbols],[
|
[ --enable-debug compile with debugging symbols],[
|
||||||
@@ -14,42 +7,65 @@ if test -z "$PHP_DEBUG"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
PHP_ARG_WITH(pdlib, for pdlib support,
|
PHP_ARG_WITH(pdlib, for pdlib support,
|
||||||
dnl Make sure that the comment is aligned:
|
|
||||||
[ --with-pdlib Include pdlib support])
|
[ --with-pdlib Include pdlib support])
|
||||||
|
|
||||||
if test "$PHP_PDLIB" != "no"; then
|
dnl using C++11
|
||||||
dnl using C++11
|
CXXFLAGS="-std=c++11"
|
||||||
CXXFLAGS="-std=c++11"
|
PHP_REQUIRE_CXX()
|
||||||
PHP_REQUIRE_CXX()
|
PHP_ADD_LIBRARY(stdc++, 1, PDLIB_SHARED_LIBADD)
|
||||||
PHP_ADD_LIBRARY(stdc++, 1, PDLIB_SHARED_LIBADD)
|
PHP_SUBST(PDLIB_SHARED_LIBADD)
|
||||||
PHP_SUBST(PDLIB_SHARED_LIBADD)
|
|
||||||
|
|
||||||
pdlib_src_files="pdlib.cc \
|
PHP_PDLIB_SOURCES="\
|
||||||
src/chinese_whispers.cc \
|
pdlib.cc \
|
||||||
src/face_detection.cc \
|
src/chinese_whispers.cc \
|
||||||
src/face_landmark_detection.cc \
|
src/face_detection.cc \
|
||||||
src/face_recognition.cc \
|
src/face_landmark_detection.cc \
|
||||||
src/cnn_face_detection.cc "
|
src/face_recognition.cc \
|
||||||
|
src/cnn_face_detection.cc \
|
||||||
|
src/vector.cc \
|
||||||
|
"
|
||||||
|
|
||||||
AC_MSG_CHECKING(for pkg-config)
|
AC_MSG_CHECKING(for pkg-config)
|
||||||
if test ! -f "$PKG_CONFIG"; then
|
if test ! -f "$PKG_CONFIG"; then
|
||||||
PKG_CONFIG=`which pkg-config`
|
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)
|
|
||||||
fi
|
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 ""
|
||||||
|
])
|
||||||
74
pdlib.cc
74
pdlib.cc
@@ -22,17 +22,20 @@ extern "C" {
|
|||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "php.h"
|
#include "php.h"
|
||||||
#include "php_ini.h"
|
#include "php_ini.h"
|
||||||
#include "ext/standard/info.h"
|
#include "ext/standard/info.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <dlib/simd/simd_check.h>
|
||||||
|
|
||||||
#include "php_pdlib.h"
|
#include "php_pdlib.h"
|
||||||
#include "src/chinese_whispers.h"
|
#include "src/chinese_whispers.h"
|
||||||
#include "src/face_detection.h"
|
#include "src/face_detection.h"
|
||||||
#include "src/face_recognition.h"
|
#include "src/face_recognition.h"
|
||||||
#include "src/cnn_face_detection.h"
|
#include "src/cnn_face_detection.h"
|
||||||
#include "src/face_landmark_detection.h"
|
#include "src/face_landmark_detection.h"
|
||||||
|
#include "src/vector.h"
|
||||||
|
|
||||||
/* If you declare any globals in php_pdlib.h uncomment this:
|
/* If you declare any globals in php_pdlib.h uncomment this:
|
||||||
ZEND_DECLARE_MODULE_GLOBALS(pdlib)
|
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
|
/* 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
|
unfold functions in source code. See the corresponding marks just before
|
||||||
@@ -246,7 +228,49 @@ PHP_RSHUTDOWN_FUNCTION(pdlib)
|
|||||||
PHP_MINFO_FUNCTION(pdlib)
|
PHP_MINFO_FUNCTION(pdlib)
|
||||||
{
|
{
|
||||||
php_info_print_table_start();
|
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();
|
php_info_print_table_end();
|
||||||
|
|
||||||
/* Remove comments if you have entries in php.ini
|
/* 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[].
|
* Every user visible function must have an entry in pdlib_functions[].
|
||||||
*/
|
*/
|
||||||
const zend_function_entry 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_chinese_whispers, dlib_chinese_whispers_arginfo)
|
||||||
PHP_FE(dlib_face_detection, dlib_face_detection_arginfo)
|
PHP_FE(dlib_face_detection, dlib_face_detection_arginfo)
|
||||||
PHP_FE(dlib_face_landmark_detection, dlib_face_landmark_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[] */
|
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 = {
|
zend_module_entry pdlib_module_entry = {
|
||||||
STANDARD_MODULE_HEADER,
|
STANDARD_MODULE_HEADER,
|
||||||
"pdlib",
|
PHP_PDLIB_NAME,
|
||||||
pdlib_functions,
|
pdlib_functions,
|
||||||
PHP_MINIT(pdlib),
|
PHP_MINIT(pdlib),
|
||||||
PHP_MSHUTDOWN(pdlib),
|
PHP_MSHUTDOWN(pdlib),
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ extern "C" {
|
|||||||
extern zend_module_entry pdlib_module_entry;
|
extern zend_module_entry pdlib_module_entry;
|
||||||
#define phpext_pdlib_ptr &pdlib_module_entry
|
#define phpext_pdlib_ptr &pdlib_module_entry
|
||||||
|
|
||||||
#define PHP_PDLIB_VERSION "1.0.1" /* Replace with version number for your extension */
|
#define PHP_PDLIB_NAME "pdlib"
|
||||||
|
#define PHP_PDLIB_VERSION "1.0.2"
|
||||||
|
|
||||||
#ifdef PHP_WIN32
|
#ifdef PHP_WIN32
|
||||||
# define PHP_PDLIB_API __declspec(dllexport)
|
# define PHP_PDLIB_API __declspec(dllexport)
|
||||||
|
|||||||
47
src/vector.cc
Normal file
47
src/vector.cc
Normal 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
10
src/vector.h
Normal 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
|
||||||
20
tests/vector_length.phpt
Normal file
20
tests/vector_length.phpt
Normal 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
10
tests/version.phpt
Normal 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"
|
||||||
Reference in New Issue
Block a user