php-opencv / php-opencv-examples

Tutorial for computer vision and machine learning in PHP 7/8 by opencv (installation + examples + documentation)
478 stars 92 forks source link

Call to undefined function CV\imread() #15

Closed quangduz closed 5 years ago

quangduz commented 5 years ago

Fatal error: Uncaught Error: Call to undefined function CV\imread() in /var/www/html/php-opencv-examples/detect_face_by_dnn_ssd.php:10 Stack trace: #0 {main} thrown in /var/www/html/php-opencv-examples/detect_face_by_dnn_ssd.php on line 10

Worked in terminal command: php detect_face_by_dnn_ssd.php array ( 0 => 1, 1 => 1, 2 => 69, 3 => 7, )0.999955415725708 0.999824583530426

But got error when run on localhost.

Please help !

morozovsk commented 5 years ago

You need to enable opencv module. For example, you can enable it for console by the command: echo "extension=opencv.so" > /etc/php/7.2/cli/conf.d/opencv.ini

You need to change it for your os, version of php and your web server. For example: echo "extension=opencv.so" > /etc/php/7.2/fpm/conf.d/opencv.ini echo "extension=opencv.so" > /etc/php/7.2/apache2/conf.d/opencv.ini