Skip to content

Installation

Vladimir Goncharov edited this page Mar 24, 2019 · 4 revisions

Installation on ubuntu 18.04 from packages (approximately 1 minute):

apt update && apt install -y wget && \
wget https://raw.githubusercontent.com/php-opencv/php-opencv-packages/master/opencv_4.0.1_amd64.deb && dpkg -i opencv_4.0.1_amd64.deb && rm opencv_4.0.1_amd64.deb && \
wget https://raw.githubusercontent.com/php-opencv/php-opencv-packages/master/php-opencv_7.2-4.0.1_amd64.deb && dpkg -i php-opencv_7.2-4.0.1_amd64.deb && rm php-opencv_7.2-4.0.1_amd64.deb && \
echo "extension=opencv.so" > /etc/php/7.2/cli/conf.d/opencv.ini

Installation on ubuntu 17.10 from packages (approximately 1 minute):

apt update && apt install -y wget && \
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 && \
wget https://raw.githubusercontent.com/php-opencv/php-opencv-packages/master/php-opencv_7.1-3.4_amd64.deb && dpkg -i php-opencv_7.1-3.4_amd64.deb && rm php-opencv_7.1-3.4_amd64.deb && \
echo "extension=opencv.so" > /etc/php/7.1/cli/conf.d/opencv.ini

Installation on ubuntu 18.04 from sources (approximately 30 minutes):

apt update && apt install -y pkg-config cmake git php-cli php-dev && \
git clone https://github.com/opencv/opencv_contrib.git && \
git clone https://github.com/opencv/opencv.git && \
cd opencv_contrib && git checkout tags/4.0.1 && cd ../opencv && git checkout tags/4.0.1 && \
cd .. && mkdir build && cd build && \
cmake -D OPENCV_GENERATE_PKGCONFIG=YES -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ../opencv && \
make -j4 && make install && \
ldconfig && \
cd ../..  && \
git clone https://github.com/php-opencv/php-opencv.git && \
cd php-opencv && phpize && ./configure --with-php-config=/usr/bin/php-config && make && make install && \
echo "extension=opencv.so" > /etc/php/7.2/cli/conf.d/opencv.ini

Hybrid installation on ubuntu 18.04: opencv from packages and php-opencv from sources (approximately 5 minutes):

wget https://raw.githubusercontent.com/php-opencv/php-opencv-packages/master/opencv_4.0.1_amd64.deb && dpkg -i opencv_4.0.1_amd64.deb && rm opencv_4.0.1_amd64.deb && \
apt update && apt install -y pkg-config cmake git php-cli php-dev && \
git clone https://github.com/php-opencv/php-opencv.git && \
cd php-opencv && phpize && ./configure --with-php-config=/usr/bin/php-config && make && make install && \
echo "extension=opencv.so" > /etc/php/7.2/cli/conf.d/opencv.ini

Installation on centos 7.5 from sources (approximately 30 minutes):

yum install -y epel-release http://rpms.remirepo.net/enterprise/remi-release-7.rpm && \
yum-config-manager --enable remi-php70 && \
yum install -y php-cli wget git php-devel make cmake gcc gcc-c++ phpconfig rpm-build rpmdevtools && \
git clone https://github.com/opencv/opencv_contrib.git && git clone https://github.com/opencv/opencv.git && \
cd opencv_contrib && git checkout 3.4 && cd ../opencv && git checkout 3.4 && \
cd .. && mkdir build && cd build && \
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ../opencv && \
make -j4 && make install && cd ../..  && \
echo "/usr/local/lib64" > /etc/ld.so.conf.d/opencv.conf && ldconfig && \
yum -y install centos-release-scl && yum makecache && yum -y install devtoolset-7-gcc devtoolset-7-gcc-c++ && \
scl enable devtoolset-7 bash && \
export PKG_CONFIG=/usr/bin/pkg-config && export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig && \
git clone https://github.com/php-opencv/php-opencv.git && \
cd php-opencv && phpize && ./configure --with-php-config=/usr/bin/php-config && make && make install && \
echo "extension=opencv.so" > /etc/php.d/opencv.ini

installation of php-opencv-examples

git clone https://github.com/php-opencv/php-opencv-examples.git && cd php-opencv-examples

start examples

php detect_face_by_dnn_ssd.php
Clone this wiki locally
You can’t perform that action at this time.