How do I install OpenCV for PHP?

2019-08-20 11:08发布

I'm trying to install OpenCV for PHP but it doesn't work.
https://github.com/mgdm/OpenCV-for-PHP
I did the following

installed OpenCV

$ sudo aptitude install libcv2.1

tried to install opencv for php

$ sudo phpize && ./configure && make && make install

tried to uses it and I got an error

$ php examples/test_convert.php

php: symbol lookup error: /usr/lib/php5/20090626/opencv.so: undefined symbol: cvSetErrMode

I thought the OpenCV for PHP needs the OpenCV libs address,

$ ldd /usr/lib/php5/20090626/opencv.so
linux-vdso.so.1 => (0x00007fff45de2000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd2d74c3000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd2d7a8a000)

so I tried this

$ phpize
$ ./configure
edit Makefile
< OPENCV_SHARED_LIBADD =
> OPENCV_SHARED_LIBADD = /usr/lib/libcv.so.2.1
$ make
$ sudo make install

and it still doesnt work.
I'm using Ubuntu11.04.
Do you have any idea?

标签: php linux opencv
3条回答
时光不老,我们不散
2楼-- · 2019-08-20 11:39

e.g:

use CV\Face\LBPHFaceRecognizer;
//use ...;

$src = imread('facePic.jpg');
$gray = cvtColor($src, COLOR_BGR2GRAY);
equalizeHist($gray, $gray);
$faceRecognizer =                 LBPHFaceRecognizer::create();
/* ... */ //get $images and $labels for train
$faceRecognizer->train($images, $labels);//How to get $image and $labels, see the document
/* ... */ //Face detection using CascadeClassifier
$faceLabel = $faceRecognizer->predict($gray);
/* ... */ //draw face and name
查看更多
何必那么认真
3楼-- · 2019-08-20 11:42

http://www.xarg.org/project/php-facedetect/ is a very good tutorial to install OpenCV on linux machine, if you know a little about PHP & Apache Web Server this tutorial will help you a lot

Regrads

Umair Iqbal

查看更多
Evening l夕情丶
4楼-- · 2019-08-20 11:51

If someone needs I've improved a bit the library: https://github.com/ProGM/OpenCV-for-PHP

I fixed compilation for php5.4 and added a solution for your issue. Follow the installation guide: https://github.com/ProGM/OpenCV-for-PHP/wiki/Installation-guide

Regards.

查看更多
登录 后发表回答