Skip to content

Commit a1f33ef

Browse files
authored
Merge pull request #33 from php-opencv/master
fixes, dnn support
2 parents ab75b63 + 7b457d1 commit a1f33ef

14 files changed

+580
-167
lines changed

.travis.yml

+5-79
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,10 @@
1-
language: php
1+
sudo: required
22

3-
compiler:
4-
- gcc
5-
- clang
6-
7-
os:
8-
- linux
9-
# - osx
10-
11-
php:
12-
- 7.0
13-
- 7.1
14-
15-
notifications:
16-
3+
services:
4+
- docker
175

186
before_install:
19-
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
20-
- sudo apt-get -qq update
21-
- sudo apt-get install gcc-4.8 -y -qq
22-
- sudo apt-get install g++-4.8 -y -qq
23-
24-
install:
25-
# OpenCV dependencies - Details available at: http://docs.opencv.org/trunk/doc/tutorials/introduction/linux_install/linux_install.html
26-
- sudo apt-get install -y build-essential
27-
# Install Cmake
28-
- wget https://cmake.org/files/v3.8/cmake-3.8.2.tar.gz
29-
- tar -zxf cmake-3.8.2.tar.gz
30-
- cd cmake-3.8.2
31-
- ./configure
32-
- make
33-
- sudo make install
34-
- cd ..
35-
36-
- sudo apt-get install -y git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev -qq
37-
- sudo apt-get install -y python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev -qq
38-
39-
# Download OpenCV-contrib v3.3.0-rc
40-
#- git clone https://github.com/opencv/opencv_contrib.git
41-
#- cd opencv_contrib
42-
#- git checkout 3.3.0-rc
43-
#- cd ..
44-
45-
# Download OpenCV v3.3.0-rc
46-
- git clone https://github.com/opencv/opencv.git
47-
- cd opencv
48-
- git checkout 3.3.0-rc
49-
50-
# Create a new 'build' folder.
51-
- mkdir build
52-
- cd build
53-
54-
# Set build instructions for Ubuntu distro.
55-
#- cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
56-
- cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
57-
# Run 'make' with four threads.
58-
- make -j6
59-
60-
# Install to OS.
61-
- sudo make install
62-
# Add configuration to OpenCV to tell it where the library files are located on the file system (/usr/local/lib)
63-
- sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
64-
65-
- sudo ldconfig
66-
- echo "OpenCV installed."
67-
68-
# We need to return to the repo "root" folder, so we can then 'cd' into the C++ project folder.
69-
- cd ../../
70-
71-
#addons:
72-
# apt:
73-
# sources:
74-
# - george-edison55-precise-backports
75-
# packages:
76-
# - cmake-data
77-
# - cmake
78-
79-
#Compile
80-
before_script:
81-
- ./travis/compile.sh
7+
- docker pull ubuntu:18.04
828

839
script:
84-
- exit 0
10+
- docker build .

Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM ubuntu:18.04
2+
3+
RUN apt update && export DEBIAN_FRONTEND=noninteractive && apt install -y wget pkg-config cmake git php-cli php-dev
4+
5+
RUN wget https://raw.githubusercontent.com/php-opencv/php-opencv-packages/master/opencv_3.4_amd64.deb && dpkg -i opencv_3.4_amd64.deb && rm opencv_3.4_amd64.deb
6+
7+
RUN git clone https://github.com/php-opencv/php-opencv.git
8+
9+
RUN cd php-opencv && phpize && ./configure --with-php-config=/usr/bin/php-config && make && make install

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
## Requirements
1212

13-
- OpenCV 3.3.0+
13+
- OpenCV 3.4+
1414
- PHP7.0+
1515

1616

config.m4

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ if test "$PHP_OPENCV" != "no"; then
5151
source/opencv2/face/opencv_facerec.cc \
5252
source/opencv2/face/opencv_facemarkLBF.cc \
5353
source/opencv2/core/opencv_cvdef.cc \
54+
source/opencv2/dnn/opencv_dnn.cc \
5455
source/opencv2/opencv_ml.cc"
5556

5657

opencv.cc

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ extern "C" {
4343
#include "source/opencv2/core/opencv_utility.h"
4444
#include "source/opencv2/opencv_ml.h"
4545
#include "source/opencv2/core/opencv_cvdef.h"
46+
#include "source/opencv2/dnn/opencv_dnn.h"
4647

4748
/* If you declare any globals in php_opencv.h uncomment this:
4849
ZEND_DECLARE_MODULE_GLOBALS(opencv)
@@ -124,6 +125,7 @@ PHP_MINIT_FUNCTION(opencv)
124125
opencv_objdetect_init(module_number);
125126
opencv_videoio_init(module_number);
126127
opencv_face_init(module_number);
128+
opencv_dnn_init(module_number);
127129
opencv_ml_init(module_number);
128130
opencv_cvdef_init(module_number);
129131

@@ -244,6 +246,10 @@ const zend_function_entry opencv_functions[] = {
244246
ZEND_NS_NAMED_FE(OPENCV_NS, findContoursWithoutHierarchy, ZEND_FN(opencv_find_contours_without_hierarchy), opencv_find_contours_without_hierarchy_arginfo)
245247
ZEND_NS_NAMED_FE(OPENCV_NS, drawContours, ZEND_FN(opencv_draw_contours), opencv_draw_contours_arginfo)
246248
ZEND_NS_NAMED_FE(OPENCV_NS, boundingRect, ZEND_FN(opencv_bounding_rect), NULL)
249+
ZEND_NS_NAMED_FE(OPENCV_DNN_NS, blobFromImage, ZEND_FN(opencv_dnn_blob_from_image), NULL)
250+
ZEND_NS_NAMED_FE(OPENCV_DNN_NS, readNetFromCaffe, ZEND_FN(opencv_dnn_read_net_from_caffe), NULL)
251+
ZEND_NS_NAMED_FE(OPENCV_DNN_NS, readNetFromTorch, ZEND_FN(opencv_dnn_read_net_from_torch), NULL)
252+
ZEND_NS_NAMED_FE(OPENCV_DNN_NS, readNetFromTensorflow, ZEND_FN(opencv_dnn_read_net_from_tensorflow), NULL)
247253
PHP_FE_END /* Must be the last line in opencv_functions[] */
248254
};
249255
/* }}} */

php_opencv.h

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ using namespace cv;
4949
#define OPENCV_NS "CV"
5050
#define OPENCV_FACE_NS ZEND_NS_NAME(OPENCV_NS,"Face")
5151
#define OPENCV_ML_NS ZEND_NS_NAME(OPENCV_NS,"ML")
52+
#define OPENCV_DNN_NS ZEND_NS_NAME(OPENCV_NS,"DNN")
5253

5354
#define OPENCV_CONNECT(text1,text2) text1##text2
5455

0 commit comments

Comments
 (0)