← 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
Velocity · 7d
+0.2
★ / day
Trend
steady
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.

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