← all repositories
hihozhou/php-opencv

When your PHP app needs eyes: a C++ bridge to OpenCV

A PHP extension that wraps OpenCV's computer-vision library so you can do face recognition and image processing without leaving your comfort language.

php-opencv
Not currently ranked — collecting fresh signals.
star history

What it does

php-opencv is a C++ PHP extension that exposes OpenCV 4.x APIs to PHP 7+. You get functions like imread, cvtColor, and equalizeHist, plus classes like LBPHFaceRecognizer and CascadeClassifier — all callable from PHP scripts. The author also provides a 300MB Docker image with OpenCV pre-installed if you’d rather not wrestle with C++ build chains yourself.

The interesting bit

Most computer-vision work happens in Python or C++. This project asks: what if your stack is already PHP and you just need to recognize a face or filter an image without spinning up a microservice? It’s a direct binding, not a REST wrapper, so you’re calling OpenCV in-process.

Key highlights

  • Covers core OpenCV modules: core, imgproc, highgui, ml, objdetect, and video
  • Includes LBPH face recognition with working examples (train, predict, draw results)
  • Docker image available with opencv_contrib baked in
  • Documented at doc.phpopencv.org with Chinese and English sections
  • ~563 stars, though the author notes it is no longer actively maintained

Caveats

  • Unmaintained: the README explicitly states “NO LONGER IN ACTIVE DEVELOPMENT” due to the author’s scheduling constraints
  • Partial coverage: many OpenCV modules (contrib, features2d, gpu, photo, stitching, etc.) are unchecked in the feature list
  • Requires PHP 7.0+ and OpenCV 4.0.0+ — you’ll be compiling a C++ extension, not running composer install

Verdict

Worth a look if you’re maintaining a PHP monolith that needs modest computer-vision capabilities and you can’t justify adding Python to your stack. Skip it if you need actively maintained bindings, modern PHP 8+ support, or full OpenCV module coverage — in those cases, a Python service or a more current project is the safer bet.

Frequently asked

What is hihozhou/php-opencv?
A PHP extension that wraps OpenCV's computer-vision library so you can do face recognition and image processing without leaving your comfort language.
Is php-opencv open source?
Yes — hihozhou/php-opencv is open source, released under the Apache-2.0 license.
What language is php-opencv written in?
hihozhou/php-opencv is primarily written in C++.
How popular is php-opencv?
hihozhou/php-opencv has 562 stars on GitHub.
Where can I find php-opencv?
hihozhou/php-opencv is on GitHub at https://github.com/hihozhou/php-opencv.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.