From 7a6fa7d80cbec44291fb97d9e7b14443eaecb949 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Mar 06 2018 00:56:29 +0000 Subject: Update to latest git for OpenCV 3.x and PHP 7 compat Note, comes with a license change back from BSD to PHP. --- diff --git a/.gitignore b/.gitignore index 671d892..dbb92bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ facedetect-1.0.0.tar.gz /facedetect-1.0.1.tar.gz /facedetect-1.1.0.tar.gz +/PHP-Facedetect-263435feaad13f187831428524c478e61eb2fb9d.tar.gz diff --git a/php-facedetect-pkgconfig.patch b/php-facedetect-pkgconfig.patch deleted file mode 100644 index 1cf1c15..0000000 --- a/php-facedetect-pkgconfig.patch +++ /dev/null @@ -1,78 +0,0 @@ -Patch to retrieve build options from pkg-config output. - -"pkg-config opencv --libs" is used (PHP_EVAL_LIBLINE) -"pkg-config opencv --variable=includedir_new is used (PHP_ADD_INCLUDE) -"pkg-config opencv --modversion" is used for debug - -"pkg-config opencv --clags" cannot be used (PHP_EVAL_INCLINE) -as it returns "-I/usr/include/opencv" and code use some headers -from both /usr/include/opencv and /usr/include/opencv2 - - ---- config.m4.pkgconfig 2016-11-24 08:14:58.908874982 +0100 -+++ config.m4 2016-11-24 08:32:22.836425511 +0100 -@@ -1,50 +1,23 @@ - PHP_ARG_WITH(facedetect, for facedetect support, [ --with-facedetect Enable facedetect support]) - - if test "$PHP_FACEDETECT" != "no"; then -- SEARCH_PATH="/usr/local /usr /opt/local" -- SEARCH_FOR="/include/opencv2/core/core_c.h" -- -- if test -r $PHP_FACEDETECT/$SEARCH_FOR; then -- FACEDETECT_DIR=$PHP_FACEDETECT -+ AC_PATH_PROG(PKG_CONFIG, pkg-config, no) -+ AC_MSG_CHECKING(for opencv) -+ if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists opencv; then -+ CV_INCLUDE=`$PKG_CONFIG opencv --variable=includedir_new` -+ CV_LIBRARY=`$PKG_CONFIG opencv --libs` -+ CV_VERSION=`$PKG_CONFIG opencv --modversion` -+ if $PKG_CONFIG opencv --atleast-version=2.2.0 ; then -+ AC_MSG_RESULT($CV_VERSION) -+ else -+ AC_MSG_ERROR(opencv version is too old) -+ fi -+ PHP_EVAL_LIBLINE($CV_LIBRARY, FACEDETECT_SHARED_LIBADD) -+ PHP_ADD_INCLUDE($CV_INCLUDE) - else -- AC_MSG_CHECKING([for facedetect in default path]) -- for i in $SEARCH_PATH ; do -- if test -r $i/$SEARCH_FOR; then -- FACEDETECT_DIR=$i -- AC_MSG_RESULT(found in $i) -- break -- fi -- done -- fi -- -- if test -z "$FACEDETECT_DIR"; then -- AC_MSG_RESULT([not found]) -- AC_MSG_ERROR([Please reinstall the OpenCV distribution]) -+ AC_MSG_ERROR(Please reinstall opencv) - fi - -- PHP_ADD_INCLUDE($FACEDETECT_DIR/include) -- -- AC_CHECK_HEADER([$FACEDETECT_DIR/include/opencv2/core/core_c.h], [], AC_MSG_ERROR('opencv/core/core_c.h' header not found)) -- AC_CHECK_HEADER([$FACEDETECT_DIR/include/opencv2/imgproc/imgproc_c.h], [], AC_MSG_ERROR('opencv/imgproc/imgproc_c.h' header not found)) -- AC_CHECK_HEADER([$FACEDETECT_DIR/include/opencv2/photo/photo_c.h], [], AC_MSG_ERROR('opencv/photo/photo_c.h' header not found)) -- AC_CHECK_HEADER([$FACEDETECT_DIR/include/opencv2/objdetect/objdetect_c.h], [], AC_MSG_ERROR('opencv/objdetect/objdetect_c.h' header not found)) -- -- PHP_CHECK_LIBRARY(opencv_core, cvLoad, -- [ -- PHP_ADD_LIBRARY_WITH_PATH(opencv_core, $FACEDETECT_DIR/lib, FACEDETECT_SHARED_LIBADD) -- PHP_CHECK_LIBRARY(opencv_objdetect, cvHaarDetectObjects, -- [ -- PHP_ADD_LIBRARY_WITH_PATH(opencv_objdetect, $FACEDETECT_DIR/lib, FACEDETECT_SHARED_LIBADD) -- AC_DEFINE(HAVE_FACEDETECT, 1, [ ]) -- ],[ -- AC_MSG_ERROR([Wrong OpenCV version or OpenCV not found]) -- ],[ -- ]) -- ],[ -- AC_MSG_ERROR([wrong OpenCV version or OpenCV not found]) -- ],[ -- ]) -- - PHP_SUBST(FACEDETECT_SHARED_LIBADD) - AC_DEFINE(HAVE_FACEDETECT, 1, [ ]) - PHP_NEW_EXTENSION(facedetect, facedetect.c, $ext_shared) diff --git a/php-facedetect.spec b/php-facedetect.spec index e70c3ed..dba6d47 100644 --- a/php-facedetect.spec +++ b/php-facedetect.spec @@ -4,21 +4,24 @@ %global ini_name 40-facedetect.ini %endif +%global github_owner infusion +%global github_name PHP-Facedetect +%global github_commit 263435feaad13f187831428524c478e61eb2fb9d +%global commitdate 20180305 +%global shortcommit %(c=%{github_commit}; echo ${c:0:7}) + Name: php-facedetect -Version: 1.1.0 -Release: 11%{?dist} +Version: 1.2.0 +Release: 0.1.%{commitdate}git%{shortcommit}%{?dist} Summary: PHP extension to access the OpenCV library Group: Development/Languages -License: BSD +License: PHP URL: http://www.xarg.org/project/php-facedetect/ -Source0: https://github.com/infusion/PHP-Facedetect/archive/v%{version}/facedetect-%{version}.tar.gz -Patch4: v1.1.0...f1c9d0f_part1.diff -Patch5: v1.1.0...f1c9d0f_part2.diff -# Use pkg-config to retrieve build options -Patch6: %{name}-pkgconfig.patch - -BuildRequires: php-devel -BuildRequires: pkgconfig(opencv) >= 2.2.0 +Source0: https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{github_name}-%{github_commit}.tar.gz + +BuildRequires: gcc-c++ +BuildRequires: php-devel +BuildRequires: pkgconfig(opencv) >= 3.0.0 Requires: opencv Requires: php(zend-abi) = %{php_zend_api} Requires: php(api) = %{php_core_api} @@ -33,12 +36,7 @@ of their coordinates. %prep -%setup -q -n PHP-Facedetect-%{version} -%patch4 -p1 -b .license -%if 0%{?fedora} >= 25 -%patch5 -p1 -b .opencv3 -%patch6 -p0 -b .pkgconfig -%endif +%setup -q -n %{github_name}-%{github_commit} %{__cat} <<'EOF' >%{ini_name} extension=facedetect.so @@ -68,6 +66,11 @@ php --no-php-ini \ %{php_extdir}/facedetect.so %changelog +* Mon Mar 05 2018 Adam Williamson - 1.2.0-0.1.20180305git263435f +- Bump to latest git (PHP 7, OpenCV 3.x compat) +- BuildRequires gcc-c++ +- License change back to PHP + * Fri Feb 09 2018 Fedora Release Engineering - 1.1.0-11 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild diff --git a/sources b/sources index c3014c3..5216710 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -4ce5e01bf0933957b37f0d0c5735393a facedetect-1.1.0.tar.gz +SHA512 (PHP-Facedetect-263435feaad13f187831428524c478e61eb2fb9d.tar.gz) = 08a7fc7e8631ea3d792b91d485b0219175dca6c6ee7bce74385d000bdfb5b08cd038f148ce48ae5d249a8e1f986f458bc65fe585d96f902da8078aa3f05743f3 diff --git a/v1.1.0...f1c9d0f_part1.diff b/v1.1.0...f1c9d0f_part1.diff deleted file mode 100644 index f70b7f6..0000000 --- a/v1.1.0...f1c9d0f_part1.diff +++ /dev/null @@ -1,83 +0,0 @@ -diff --git a/LICENSE b/LICENSE -new file mode 100644 -index 0000000..d8662fc ---- /dev/null -+++ b/LICENSE -@@ -0,0 +1,24 @@ -+Copyright (c) 2009, Robert Eisele -+All rights reserved. -+ -+Redistribution and use in source and binary forms, with or without -+modification, are permitted provided that the following conditions are met: -+ * Redistributions of source code must retain the above copyright -+ notice, this list of conditions and the following disclaimer. -+ * Redistributions in binary form must reproduce the above copyright -+ notice, this list of conditions and the following disclaimer in the -+ documentation and/or other materials provided with the distribution. -+ * Neither the name of the nor the -+ names of its contributors may be used to endorse or promote products -+ derived from this software without specific prior written permission. -+ -+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -diff --git a/facedetect.c b/facedetect.c -index ab49c9d..6bc73f6 100644 ---- a/facedetect.c -+++ b/facedetect.c -@@ -2,21 +2,18 @@ - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ -- | This source file is subject to version 3.0 of the PHP license, | -+ | This source file is subject to BSD 3-Clause 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_0.txt. | -- | If you did not receive a copy of the PHP license and are unable to | -+ | http://opensource.org/licenses/BSD-3-Clause. | -+ | If you did not receive a copy of the BSD 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. | -+ | robert@xarg.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Robert Eisele | - +----------------------------------------------------------------------+ - */ --// http://www.santyago.pl/files/facedetect-1.0.1-opencv-2.2.0.patch --// - face recog lib embedden http://libface.sourceforge.net/file/Examples.html --// - http://www.cognotics.com/opencv/servo_2007_series/part_5/index.html --// - opencv 2.2 kompatibel -+ - #ifdef HAVE_CONFIG_H - #include "config.h" - #endif -diff --git a/php_facedetect.h b/php_facedetect.h -index 171006e..95d598d 100644 ---- a/php_facedetect.h -+++ b/php_facedetect.h -@@ -2,13 +2,13 @@ - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ -- | This source file is subject to version 3.0 of the PHP license, | -+ | This source file is subject to BSD 3-Clause 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_0.txt. | -- | If you did not receive a copy of the PHP license and are unable to | -+ | http://opensource.org/licenses/BSD-3-Clause. | -+ | If you did not receive a copy of the BSD 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. | -+ | robert@xarg.org so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Robert Eisele | - +----------------------------------------------------------------------+ diff --git a/v1.1.0...f1c9d0f_part2.diff b/v1.1.0...f1c9d0f_part2.diff deleted file mode 100644 index bda5979..0000000 --- a/v1.1.0...f1c9d0f_part2.diff +++ /dev/null @@ -1,127 +0,0 @@ -diff --git a/README.md b/README.md -new file mode 100644 -index 0000000..c34e086 ---- /dev/null -+++ b/README.md -@@ -0,0 +1,4 @@ -+# PHP-Facedetect -+A simple OpenCV wrapper for PHP to detect faces on images -+ -+OpenCV 3 Support -diff --git a/config.m4 b/config.m4 -index 1b58b07..2e6ffd7 100644 ---- a/config.m4 -+++ b/config.m4 -@@ -2,7 +2,7 @@ PHP_ARG_WITH(facedetect, for facedetect support, [ --with-facedetect Enable - - if test "$PHP_FACEDETECT" != "no"; then - SEARCH_PATH="/usr/local /usr /opt/local" -- SEARCH_FOR="/include/opencv/cv.h" -+ SEARCH_FOR="/include/opencv2/core/core_c.h" - - if test -r $PHP_FACEDETECT/$SEARCH_FOR; then - FACEDETECT_DIR=$PHP_FACEDETECT -@@ -24,8 +24,10 @@ if test "$PHP_FACEDETECT" != "no"; then - - PHP_ADD_INCLUDE($FACEDETECT_DIR/include) - -- AC_CHECK_HEADER([$FACEDETECT_DIR/include/opencv/cv.h], [], AC_MSG_ERROR('opencv/cv.h' header not found)) -- AC_CHECK_HEADER([$FACEDETECT_DIR/include/opencv/highgui.h], [], AC_MSG_ERROR('opencv/highgui.h' header not found)) -+ AC_CHECK_HEADER([$FACEDETECT_DIR/include/opencv2/core/core_c.h], [], AC_MSG_ERROR('opencv/core/core_c.h' header not found)) -+ AC_CHECK_HEADER([$FACEDETECT_DIR/include/opencv2/imgproc/imgproc_c.h], [], AC_MSG_ERROR('opencv/imgproc/imgproc_c.h' header not found)) -+ AC_CHECK_HEADER([$FACEDETECT_DIR/include/opencv2/photo/photo_c.h], [], AC_MSG_ERROR('opencv/photo/photo_c.h' header not found)) -+ AC_CHECK_HEADER([$FACEDETECT_DIR/include/opencv2/objdetect/objdetect_c.h], [], AC_MSG_ERROR('opencv/objdetect/objdetect_c.h' header not found)) - - PHP_CHECK_LIBRARY(opencv_core, cvLoad, - [ -@@ -37,7 +39,7 @@ if test "$PHP_FACEDETECT" != "no"; then - ],[ - AC_MSG_ERROR([Wrong OpenCV version or OpenCV not found]) - ],[ -- ]), -+ ]) - ],[ - AC_MSG_ERROR([wrong OpenCV version or OpenCV not found]) - ],[ -diff --git a/config.w32 b/config.w32 -index 1a79f55..78306d1 100644 ---- a/config.w32 -+++ b/config.w32 -@@ -8,7 +8,7 @@ if (PHP_FACEDETECT == "yes") { - CHECK_LIB("opencv_core*.lib", "facedetect", PHP_FACEDETECT) && - CHECK_LIB("opencv_imgproc*.lib", "facedetect", PHP_FACEDETECT) && - CHECK_LIB("opencv_highgui*.lib", "facedetect", PHP_FACEDETECT) && -- CHECK_HEADER_ADD_INCLUDE("opencv/cv.h", "CFLAGS_FFACEDETECT")) { -+ CHECK_HEADER_ADD_INCLUDE("opencv2/core/core_c.h", "CFLAGS_FFACEDETECT")) { - - AC_DEFINE("HAVE_FACEDETECT", 1); - -diff --git a/facedetect.c b/facedetect.c -index ab49c9d..6bc73f6 100644 ---- a/facedetect.c -+++ b/facedetect.c -@@ -24,8 +21,12 @@ - #include "ext/standard/info.h" - #include "php_facedetect.h" - --#include --#include -+#include "opencv2/core/core_c.h" -+#include "opencv2/imgproc/imgproc_c.h" -+#include "opencv2/photo/photo_c.h" -+#include "opencv2/objdetect/objdetect_c.h" -+ -+#include "opencv2/core/version.hpp" - - /* {{{ facedetect_functions[] - * -@@ -74,12 +75,19 @@ PHP_MINFO_FUNCTION(facedetect) - } - /* }}} */ - -+IplImage* cvLoadImage(char *file, int number); -+ - static void php_facedetect(INTERNAL_FUNCTION_PARAMETERS, int return_type) - { - char *file, *casc; - long flen, clen; - -+#ifdef ZEND_ENGINE_3 -+ zval array; -+#else - zval *array; -+#endif -+ zval *pArray; - - CvHaarClassifierCascade* cascade; - IplImage *img, *gray; -@@ -116,17 +124,23 @@ static void php_facedetect(INTERNAL_FUNCTION_PARAMETERS, int return_type) - if(faces && faces->total > 0) { - int i; - for(i = 0; i < faces->total; i++) { -+#ifdef ZEND_ENGINE_3 -+ ZVAL_NEW_ARR(&array); -+ pArray = &array; -+#else - MAKE_STD_ZVAL(array); -- array_init(array); -+ pArray = array; -+#endif -+ array_init(pArray); - - rect = (CvRect *)cvGetSeqElem(faces, i); - -- add_assoc_long(array, "x", rect->x); -- add_assoc_long(array, "y", rect->y); -- add_assoc_long(array, "w", rect->width); -- add_assoc_long(array, "h", rect->height); -+ add_assoc_long(pArray, "x", rect->x); -+ add_assoc_long(pArray, "y", rect->y); -+ add_assoc_long(pArray, "w", rect->width); -+ add_assoc_long(pArray, "h", rect->height); - -- add_next_index_zval(return_value, array); -+ add_next_index_zval(return_value, pArray); - } - } - } else {