Initial commit

Esse commit está contido em:
Michael Maclean
2010-12-26 16:12:31 +00:00
commit 14cac554fa
8 arquivos alterados com 399 adições e 0 exclusões
+1
Ver Arquivo
@@ -0,0 +1 @@
opencv
Ver Arquivo
+78
Ver Arquivo
@@ -0,0 +1,78 @@
dnl
dnl $ Id: opencv 1.0.1$
dnl
PHP_ARG_WITH(opencv, for OpenCV support,
[ --with-opencv Enable OpenCV support], yes)
if test "$PHP_OPENCV" != "no"; then
export OLD_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS $INCLUDES -DHAVE_OPENCV"
AC_MSG_CHECKING(PHP version)
AC_TRY_COMPILE([#include <php_version.h>], [
#if PHP_VERSION_ID < 50200
#error this extension requires at least PHP version 5.2.0
#endif
],
[AC_MSG_RESULT(ok)],
[AC_MSG_ERROR([need at least PHP 5.2.0])])
export CPPFLAGS="$OLD_CPPFLAGS"
PHP_SUBST(OPENCV_SHARED_LIBADD)
AC_DEFINE(HAVE_OPENCV, 1, [ ])
PHP_NEW_EXTENSION(opencv, opencv.c, $ext_shared)
EXT_OPENCV_HEADERS="php_opencv_api.h"
ifdef([PHP_INSTALL_HEADERS], [
PHP_INSTALL_HEADERS(ext/opencv, $EXT_OPENCV_HEADERS)
])
if test "$PHP_OPENCV" != "no"; then
OPENCV_CHECK_DIR=$PHP_OPENCV
OPENCV_TEST_FILE=/include/opencv.h
OPENCV_LIBNAME=opencv
fi
condition="$OPENCV_CHECK_DIR$OPENCV_TEST_FILE"
if test -r $condition; then
OPENCV_DIR=$OPENCV_CHECK_DIR
CFLAGS="$CFLAGS -I$OPENCV_DIR/include"
LDFLAGS=`$OPENCV_DIR/bin/opencv-config --libs`
else
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 opencv)
if $PKG_CONFIG --exists opencv; then
if $PKG_CONFIG --atleast-version=2.1.0 opencv; then
opencv_version_full=`$PKG_CONFIG --modversion opencv`
AC_MSG_RESULT([found $opencv_version_full])
OPENCV_LIBS="$LDFLAGS `$PKG_CONFIG --libs opencv`"
OPENCV_INCS="$CFLAGS `$PKG_CONFIG --cflags-only-I opencv`"
PHP_EVAL_INCLINE($OPENCV_INCS)
PHP_EVAL_LIBLINE($OPENCV_LIBS, OPENCV_SHARED_LIBADD)
AC_DEFINE(HAVE_OPENCV, 1, [whether opencv exists in the system])
else
AC_MSG_RESULT(too old)
AC_MSG_ERROR(Ooops ! You need at least opencv 2.1.0)
fi
else
AC_MSG_RESULT(not found)
AC_MSG_ERROR(Ooops ! no opencv detected in the system)
fi
else
AC_MSG_RESULT(not found)
AC_MSG_ERROR(Ooops ! no pkg-config found .... )
fi
fi
fi
+13
Ver Arquivo
@@ -0,0 +1,13 @@
// $Id$
// vim:ft=javascript
// If your extension references something external, use ARG_WITH
// ARG_WITH("opencv", "for opencv support", "no");
// Otherwise, use ARG_ENABLE
// ARG_ENABLE("opencv", "enable opencv support", "no");
if (PHP_OPENCV != "no") {
EXTENSION("opencv", "opencv.c");
}
+182
Ver Arquivo
@@ -0,0 +1,182 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2010 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: |
+----------------------------------------------------------------------+
*/
/* $Id: header 297205 2010-03-30 21:09:07Z johannes $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_opencv.h"
/* If you declare any globals in php_opencv.h uncomment this:
ZEND_DECLARE_MODULE_GLOBALS(opencv)
*/
/* True global resources - no need for thread safety here */
static int le_opencv;
/* {{{ opencv_functions[]
*
* Every user visible function must have an entry in opencv_functions[].
*/
const zend_function_entry opencv_functions[] = {
PHP_FE(confirm_opencv_compiled, NULL) /* For testing, remove later. */
{NULL, NULL, NULL} /* Must be the last line in opencv_functions[] */
};
/* }}} */
/* {{{ opencv_module_entry
*/
zend_module_entry opencv_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
"opencv",
opencv_functions,
PHP_MINIT(opencv),
PHP_MSHUTDOWN(opencv),
PHP_RINIT(opencv), /* Replace with NULL if there's nothing to do at request start */
PHP_RSHUTDOWN(opencv), /* Replace with NULL if there's nothing to do at request end */
PHP_MINFO(opencv),
#if ZEND_MODULE_API_NO >= 20010901
"0.1", /* Replace with version number for your extension */
#endif
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#ifdef COMPILE_DL_OPENCV
ZEND_GET_MODULE(opencv)
#endif
/* {{{ PHP_INI
*/
/* Remove comments and fill if you need to have entries in php.ini
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("opencv.global_value", "42", PHP_INI_ALL, OnUpdateLong, global_value, zend_opencv_globals, opencv_globals)
STD_PHP_INI_ENTRY("opencv.global_string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_opencv_globals, opencv_globals)
PHP_INI_END()
*/
/* }}} */
/* {{{ php_opencv_init_globals
*/
/* Uncomment this function if you have INI entries
static void php_opencv_init_globals(zend_opencv_globals *opencv_globals)
{
opencv_globals->global_value = 0;
opencv_globals->global_string = NULL;
}
*/
/* }}} */
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(opencv)
{
/* If you have INI entries, uncomment these lines
REGISTER_INI_ENTRIES();
*/
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MSHUTDOWN_FUNCTION(opencv)
{
/* uncomment this line if you have INI entries
UNREGISTER_INI_ENTRIES();
*/
return SUCCESS;
}
/* }}} */
/* Remove if there's nothing to do at request start */
/* {{{ PHP_RINIT_FUNCTION
*/
PHP_RINIT_FUNCTION(opencv)
{
return SUCCESS;
}
/* }}} */
/* Remove if there's nothing to do at request end */
/* {{{ PHP_RSHUTDOWN_FUNCTION
*/
PHP_RSHUTDOWN_FUNCTION(opencv)
{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(opencv)
{
php_info_print_table_start();
php_info_print_table_header(2, "opencv support", "enabled");
php_info_print_table_end();
/* Remove comments if you have entries in php.ini
DISPLAY_INI_ENTRIES();
*/
}
/* }}} */
/* Remove the following function when you have succesfully 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_opencv_compiled(string arg)
Return a string to confirm that the module is compiled in */
PHP_FUNCTION(confirm_opencv_compiled)
{
char *arg = NULL;
int arg_len, len;
char *strg;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {
return;
}
len = spprintf(&strg, 0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "opencv", arg);
RETURN_STRINGL(strg, len, 0);
}
/* }}} */
/* 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.
*/
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
+21
Ver Arquivo
@@ -0,0 +1,21 @@
<?php
$br = (php_sapi_name() == "cli")? "":"<br>";
if(!extension_loaded('opencv')) {
dl('opencv.' . PHP_SHLIB_SUFFIX);
}
$module = 'opencv';
$functions = get_extension_funcs($module);
echo "Functions available in the test extension:$br\n";
foreach($functions as $func) {
echo $func."$br\n";
}
echo "$br\n";
$function = 'confirm_' . $module . '_compiled';
if (extension_loaded($module)) {
$str = $function($module);
} else {
$str = "Module $module is not compiled into PHP";
}
echo "$str\n";
?>
+83
Ver Arquivo
@@ -0,0 +1,83 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2010 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: |
+----------------------------------------------------------------------+
*/
/* $Id: header 297205 2010-03-30 21:09:07Z johannes $ */
#ifndef PHP_OPENCV_H
#define PHP_OPENCV_H
extern zend_module_entry opencv_module_entry;
#define phpext_opencv_ptr &opencv_module_entry
#ifdef PHP_WIN32
# define PHP_OPENCV_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_OPENCV_API __attribute__ ((visibility("default")))
#else
# define PHP_OPENCV_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
PHP_MINIT_FUNCTION(opencv);
PHP_MSHUTDOWN_FUNCTION(opencv);
PHP_RINIT_FUNCTION(opencv);
PHP_RSHUTDOWN_FUNCTION(opencv);
PHP_MINFO_FUNCTION(opencv);
PHP_FUNCTION(confirm_opencv_compiled); /* For testing, remove later. */
/*
Declare any global variables you may need between the BEGIN
and END macros here:
ZEND_BEGIN_MODULE_GLOBALS(opencv)
long global_value;
char *global_string;
ZEND_END_MODULE_GLOBALS(opencv)
*/
/* In every utility function you add that needs to use variables
in php_opencv_globals, call TSRMLS_FETCH(); after declaring other
variables used by that function, or better yet, pass in TSRMLS_CC
after the last function argument and declare your utility function
with TSRMLS_DC after the last declared argument. Always refer to
the globals in your function as OPENCV_G(variable). You are
encouraged to rename these macros something shorter, see
examples in any other php module directory.
*/
#ifdef ZTS
#define OPENCV_G(v) TSRMG(opencv_globals_id, zend_opencv_globals *, v)
#else
#define OPENCV_G(v) (opencv_globals.v)
#endif
#endif /* PHP_OPENCV_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
+21
Ver Arquivo
@@ -0,0 +1,21 @@
--TEST--
Check for opencv presence
--SKIPIF--
<?php if (!extension_loaded("opencv")) print "skip"; ?>
--FILE--
<?php
echo "opencv extension is available";
/*
you can add regression tests for your extension here
the output of your test code has to be equal to the
text in the --EXPECT-- section below for the tests
to pass, differences between the output and the
expected text are interpreted as failure
see php5/README.TESTING for further information on
writing regression tests
*/
?>
--EXPECT--
opencv extension is available