Skip to content

Commit 5c3c004

Browse files
committed
Create Project
0 parents  commit 5c3c004

9 files changed

+409
-0
lines changed

.gitignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.deps
2+
*.lo
3+
*.la
4+
.libs
5+
acinclude.m4
6+
aclocal.m4
7+
autom4te.cache
8+
build
9+
config.guess
10+
config.h
11+
config.h.in
12+
config.log
13+
config.nice
14+
config.status
15+
config.sub
16+
configure
17+
configure.in
18+
include
19+
install-sh
20+
libtool
21+
ltmain.sh
22+
Makefile
23+
Makefile.fragments
24+
Makefile.global
25+
Makefile.objects
26+
missing
27+
mkinstalldirs
28+
modules
29+
run-tests.php
30+
tests/*/*.diff
31+
tests/*/*.out
32+
tests/*/*.php
33+
tests/*/*.exp
34+
tests/*/*.log
35+
tests/*/*.sh

CREDITS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
opencv

EXPERIMENTAL

Whitespace-only changes.

config.m4

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
dnl $Id$
2+
dnl config.m4 for extension opencv
3+
4+
dnl Comments in this file start with the string 'dnl'.
5+
dnl Remove where necessary. This file will not work
6+
dnl without editing.
7+
8+
dnl If your extension references something external, use with:
9+
10+
dnl PHP_ARG_WITH(opencv, for opencv support,
11+
dnl Make sure that the comment is aligned:
12+
dnl [ --with-opencv Include opencv support])
13+
14+
dnl Otherwise use enable:
15+
16+
dnl PHP_ARG_ENABLE(opencv, whether to enable opencv support,
17+
dnl Make sure that the comment is aligned:
18+
dnl [ --enable-opencv Enable opencv support])
19+
20+
if test "$PHP_OPENCV" != "no"; then
21+
dnl Write more examples of tests here...
22+
23+
dnl # --with-opencv -> check with-path
24+
dnl SEARCH_PATH="/usr/local /usr" # you might want to change this
25+
dnl SEARCH_FOR="/include/opencv.h" # you most likely want to change this
26+
dnl if test -r $PHP_OPENCV/$SEARCH_FOR; then # path given as parameter
27+
dnl OPENCV_DIR=$PHP_OPENCV
28+
dnl else # search default path list
29+
dnl AC_MSG_CHECKING([for opencv files in default path])
30+
dnl for i in $SEARCH_PATH ; do
31+
dnl if test -r $i/$SEARCH_FOR; then
32+
dnl OPENCV_DIR=$i
33+
dnl AC_MSG_RESULT(found in $i)
34+
dnl fi
35+
dnl done
36+
dnl fi
37+
dnl
38+
dnl if test -z "$OPENCV_DIR"; then
39+
dnl AC_MSG_RESULT([not found])
40+
dnl AC_MSG_ERROR([Please reinstall the opencv distribution])
41+
dnl fi
42+
43+
dnl # --with-opencv -> add include path
44+
dnl PHP_ADD_INCLUDE($OPENCV_DIR/include)
45+
46+
dnl # --with-opencv -> check for lib and symbol presence
47+
dnl LIBNAME=opencv # you may want to change this
48+
dnl LIBSYMBOL=opencv # you most likely want to change this
49+
50+
dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
51+
dnl [
52+
dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $OPENCV_DIR/$PHP_LIBDIR, OPENCV_SHARED_LIBADD)
53+
dnl AC_DEFINE(HAVE_OPENCVLIB,1,[ ])
54+
dnl ],[
55+
dnl AC_MSG_ERROR([wrong opencv lib version or lib not found])
56+
dnl ],[
57+
dnl -L$OPENCV_DIR/$PHP_LIBDIR -lm
58+
dnl ])
59+
dnl
60+
dnl PHP_SUBST(OPENCV_SHARED_LIBADD)
61+
62+
PHP_NEW_EXTENSION(opencv, opencv.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
63+
fi

config.w32

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// $Id$
2+
// vim:ft=javascript
3+
4+
// If your extension references something external, use ARG_WITH
5+
// ARG_WITH("opencv", "for opencv support", "no");
6+
7+
// Otherwise, use ARG_ENABLE
8+
// ARG_ENABLE("opencv", "enable opencv support", "no");
9+
10+
if (PHP_OPENCV != "no") {
11+
EXTENSION("opencv", "opencv.c", PHP_EXTNAME_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
12+
}
13+

opencv.c

+184
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| PHP Version 7 |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) 1997-2017 The PHP Group |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 3.01 of the PHP license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available through the world-wide-web at the following url: |
10+
| http://www.php.net/license/3_01.txt |
11+
| If you did not receive a copy of the PHP license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| license@php.net so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
| Author: |
16+
+----------------------------------------------------------------------+
17+
*/
18+
19+
/* $Id$ */
20+
21+
#ifdef HAVE_CONFIG_H
22+
#include "config.h"
23+
#endif
24+
25+
#include "php.h"
26+
#include "php_ini.h"
27+
#include "ext/standard/info.h"
28+
#include "php_opencv.h"
29+
30+
/* If you declare any globals in php_opencv.h uncomment this:
31+
ZEND_DECLARE_MODULE_GLOBALS(opencv)
32+
*/
33+
34+
/* True global resources - no need for thread safety here */
35+
static int le_opencv;
36+
37+
/* {{{ PHP_INI
38+
*/
39+
/* Remove comments and fill if you need to have entries in php.ini
40+
PHP_INI_BEGIN()
41+
STD_PHP_INI_ENTRY("opencv.global_value", "42", PHP_INI_ALL, OnUpdateLong, global_value, zend_opencv_globals, opencv_globals)
42+
STD_PHP_INI_ENTRY("opencv.global_string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_opencv_globals, opencv_globals)
43+
PHP_INI_END()
44+
*/
45+
/* }}} */
46+
47+
/* Remove the following function when you have successfully modified config.m4
48+
so that your module can be compiled into PHP, it exists only for testing
49+
purposes. */
50+
51+
/* Every user-visible function in PHP should document itself in the source */
52+
/* {{{ proto string confirm_opencv_compiled(string arg)
53+
Return a string to confirm that the module is compiled in */
54+
PHP_FUNCTION(confirm_opencv_compiled)
55+
{
56+
char *arg = NULL;
57+
size_t arg_len, len;
58+
zend_string *strg;
59+
60+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &arg, &arg_len) == FAILURE) {
61+
return;
62+
}
63+
64+
strg = strpprintf(0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "opencv", arg);
65+
66+
RETURN_STR(strg);
67+
}
68+
/* }}} */
69+
/* The previous line is meant for vim and emacs, so it can correctly fold and
70+
unfold functions in source code. See the corresponding marks just before
71+
function definition, where the functions purpose is also documented. Please
72+
follow this convention for the convenience of others editing your code.
73+
*/
74+
75+
76+
/* {{{ php_opencv_init_globals
77+
*/
78+
/* Uncomment this function if you have INI entries
79+
static void php_opencv_init_globals(zend_opencv_globals *opencv_globals)
80+
{
81+
opencv_globals->global_value = 0;
82+
opencv_globals->global_string = NULL;
83+
}
84+
*/
85+
/* }}} */
86+
87+
/* {{{ PHP_MINIT_FUNCTION
88+
*/
89+
PHP_MINIT_FUNCTION(opencv)
90+
{
91+
/* If you have INI entries, uncomment these lines
92+
REGISTER_INI_ENTRIES();
93+
*/
94+
return SUCCESS;
95+
}
96+
/* }}} */
97+
98+
/* {{{ PHP_MSHUTDOWN_FUNCTION
99+
*/
100+
PHP_MSHUTDOWN_FUNCTION(opencv)
101+
{
102+
/* uncomment this line if you have INI entries
103+
UNREGISTER_INI_ENTRIES();
104+
*/
105+
return SUCCESS;
106+
}
107+
/* }}} */
108+
109+
/* Remove if there's nothing to do at request start */
110+
/* {{{ PHP_RINIT_FUNCTION
111+
*/
112+
PHP_RINIT_FUNCTION(opencv)
113+
{
114+
#if defined(COMPILE_DL_OPENCV) && defined(ZTS)
115+
ZEND_TSRMLS_CACHE_UPDATE();
116+
#endif
117+
return SUCCESS;
118+
}
119+
/* }}} */
120+
121+
/* Remove if there's nothing to do at request end */
122+
/* {{{ PHP_RSHUTDOWN_FUNCTION
123+
*/
124+
PHP_RSHUTDOWN_FUNCTION(opencv)
125+
{
126+
return SUCCESS;
127+
}
128+
/* }}} */
129+
130+
/* {{{ PHP_MINFO_FUNCTION
131+
*/
132+
PHP_MINFO_FUNCTION(opencv)
133+
{
134+
php_info_print_table_start();
135+
php_info_print_table_header(2, "opencv support", "enabled");
136+
php_info_print_table_end();
137+
138+
/* Remove comments if you have entries in php.ini
139+
DISPLAY_INI_ENTRIES();
140+
*/
141+
}
142+
/* }}} */
143+
144+
/* {{{ opencv_functions[]
145+
*
146+
* Every user visible function must have an entry in opencv_functions[].
147+
*/
148+
const zend_function_entry opencv_functions[] = {
149+
PHP_FE(confirm_opencv_compiled, NULL) /* For testing, remove later. */
150+
PHP_FE_END /* Must be the last line in opencv_functions[] */
151+
};
152+
/* }}} */
153+
154+
/* {{{ opencv_module_entry
155+
*/
156+
zend_module_entry opencv_module_entry = {
157+
STANDARD_MODULE_HEADER,
158+
"opencv",
159+
opencv_functions,
160+
PHP_MINIT(opencv),
161+
PHP_MSHUTDOWN(opencv),
162+
PHP_RINIT(opencv), /* Replace with NULL if there's nothing to do at request start */
163+
PHP_RSHUTDOWN(opencv), /* Replace with NULL if there's nothing to do at request end */
164+
PHP_MINFO(opencv),
165+
PHP_OPENCV_VERSION,
166+
STANDARD_MODULE_PROPERTIES
167+
};
168+
/* }}} */
169+
170+
#ifdef COMPILE_DL_OPENCV
171+
#ifdef ZTS
172+
ZEND_TSRMLS_CACHE_DEFINE()
173+
#endif
174+
ZEND_GET_MODULE(opencv)
175+
#endif
176+
177+
/*
178+
* Local variables:
179+
* tab-width: 4
180+
* c-basic-offset: 4
181+
* End:
182+
* vim600: noet sw=4 ts=4 fdm=marker
183+
* vim<600: noet sw=4 ts=4
184+
*/

opencv.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
$br = (php_sapi_name() == "cli")? "":"<br>";
3+
4+
if(!extension_loaded('opencv')) {
5+
dl('opencv.' . PHP_SHLIB_SUFFIX);
6+
}
7+
$module = 'opencv';
8+
$functions = get_extension_funcs($module);
9+
echo "Functions available in the test extension:$br\n";
10+
foreach($functions as $func) {
11+
echo $func."$br\n";
12+
}
13+
echo "$br\n";
14+
$function = 'confirm_' . $module . '_compiled';
15+
if (extension_loaded($module)) {
16+
$str = $function($module);
17+
} else {
18+
$str = "Module $module is not compiled into PHP";
19+
}
20+
echo "$str\n";
21+
?>

php_opencv.h

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| PHP Version 7 |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) 1997-2017 The PHP Group |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 3.01 of the PHP license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available through the world-wide-web at the following url: |
10+
| http://www.php.net/license/3_01.txt |
11+
| If you did not receive a copy of the PHP license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| license@php.net so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
| Author: |
16+
+----------------------------------------------------------------------+
17+
*/
18+
19+
/* $Id$ */
20+
21+
#ifndef PHP_OPENCV_H
22+
#define PHP_OPENCV_H
23+
24+
extern zend_module_entry opencv_module_entry;
25+
#define phpext_opencv_ptr &opencv_module_entry
26+
27+
#define PHP_OPENCV_VERSION "0.1.0" /* Replace with version number for your extension */
28+
29+
#ifdef PHP_WIN32
30+
# define PHP_OPENCV_API __declspec(dllexport)
31+
#elif defined(__GNUC__) && __GNUC__ >= 4
32+
# define PHP_OPENCV_API __attribute__ ((visibility("default")))
33+
#else
34+
# define PHP_OPENCV_API
35+
#endif
36+
37+
#ifdef ZTS
38+
#include "TSRM.h"
39+
#endif
40+
41+
/*
42+
Declare any global variables you may need between the BEGIN
43+
and END macros here:
44+
45+
ZEND_BEGIN_MODULE_GLOBALS(opencv)
46+
zend_long global_value;
47+
char *global_string;
48+
ZEND_END_MODULE_GLOBALS(opencv)
49+
*/
50+
51+
/* Always refer to the globals in your function as OPENCV_G(variable).
52+
You are encouraged to rename these macros something shorter, see
53+
examples in any other php module directory.
54+
*/
55+
#define OPENCV_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(opencv, v)
56+
57+
#if defined(ZTS) && defined(COMPILE_DL_OPENCV)
58+
ZEND_TSRMLS_CACHE_EXTERN()
59+
#endif
60+
61+
#endif /* PHP_OPENCV_H */
62+
63+
64+
/*
65+
* Local variables:
66+
* tab-width: 4
67+
* c-basic-offset: 4
68+
* End:
69+
* vim600: noet sw=4 ts=4 fdm=marker
70+
* vim<600: noet sw=4 ts=4
71+
*/

0 commit comments

Comments
 (0)