Install OpenCV on macOS Big Sur / PHP 7.4

Hey guys,

I’m really looking forward to using OpenCV which I have downloaded with Homebrew (brew install opencv) to my Mac. I’m using Big Sur with the installed apache and PHP 7.4.

I have spend hours to google how to connect php with opencv in order to use it. Seems to be a little problem, but maybe someone knows the answer to this question.

Open CV is installed in: /usr/local/Cellar/opencv/4.5.2

PHP.ini is found in: /usr/local/etc/php/7.4/php.ini

On the site Installation. php opencv · php-opencv/php-opencv Wiki · GitHub I’ve found this:

echo "extension=opencv.so" > /etc/php/7.4/cli/conf.d/opencv.ini
echo "extension=opencv.so" > /etc/php/7.4/fpm/conf.d/opencv.ini
echo "extension=opencv.so" > /etc/php/7.4/apache2/conf.d/opencv.ini

From here I don’t know what to do.

Thanks in advance for your help!

don’t try ;(

php has a c (extension)-api, opencv is c++, serious friction ahead.
(there was an opencv c-api, but it’s long long deprecated, and as of now - defunct)

this seems to be a subset of opencv, wrapped into php
but it’s not at all maintained by opencv, and we really cannot help much with 3rdparty efforts.

don’t try with that. it only covers like ~50 of ~2500 functions… !
even IF you get it to run, it will have so many “holes”, that it’ll be next to unusable for a real life project.

pssst, don’t tell anyone, but opencv has excellent, officially supported python wrappers … (and they’re only a pip install opencv-contrib-python away !)

1 Like

Thanks for your quick response, berak. So now I’ll have to start leaning python… :slight_smile:

i’d say, this is the much better idea, than messing with some unsupported, incomplete (and somewhat “against the wall”) project

1 Like