opencv php,GitHub - hihozhou/php-opencv: PHP extensions for OpenCV

PHP-OPENCV - PHP extension for Opencv

68747470733a2f2f7472617669732d63692e6f72672f6869686f7a686f752f7068702d6f70656e63762e7376673f6272616e63683d6d617374657268747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e302d3838393242462e737667

⚠️⚠️ NO LONGER IN ACTIVE DEVELOPMENT | 项目不再维护 ⚠️⚠️

Due to personal scheduling reasons, the project has been suspended for maintenance and it is hoped that the project code will provide useful value.

Document

Requirements

OpenCV 4.0.0+

PHP7.0+

Installation

Use OpenCV docker(commendatory)

If you don't know how to install OpenCV, you can use my OpenCV docker image(only 300M, including opencv_contrib).

docker pull hihozhou/php-opencv

Compile and install php-opencv extension

git clone https://github.com/hihozhou/php-opencv.git

cd php-opencv

phpize

./configure --with-php-config=your php-config path

make

make install

Configure

php.ini

extension="your opencv.so path"

Example

LBPH face recognition

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

result:

face_recognizer.jpg

Image Processing

//Obama.php

use function CV\{ imread, imshow, waitkey, namedWindow};

$im = imread('Obama.png');//load image

namedWindow('This is Obama id card',WINDOW_FULLSCREEN);//create window

imshow('This is Obama id card',$im);//show image on window

waitkey(0);

result:

Obama.png

Load image by gray

$gray = imread('Obama.png',IMREAD_GRAYSCALE);

//or

use function CV\{ cvtColor};

$gray = cvtColor($im, COLOR_BGR2GRAY);

Obama_gray.png

You can draw something.

e.g:

use CV\{Mat,Scalar, Point, Size};

use function CV\{ellipse, imwrite, waitKey};

use const CV\{CV_8UC3};

$windowWidth = 600;

$thickness = 2;

$lineType = 8;

$matScalar = new Scalar(0,0,0);

$mat = new Mat($windowWidth, $windowWidth, CV_8UC3, $matScalar);

$point=new Point($windowWidth/2, $windowWidth/2);

$size=new Size($windowWidth/4, $windowWidth/16);

$scalar=new Scalar(255, 129, 0);

for($i = 0; $i <= 360; $i += 45){

ellipse($mat,$point,$size,$i,0,360,$scalar,$thickness,$lineType);

}

imwrite('./tests/ellipse.png',$mat);

result:

ellipse.png

Features

3.highgui

4.contrib

5.features2d

6.flann

7.gpu

8.calib3d

9.legacy

10.ml

11.nonfree

12.objdetect

13.ocl

14.photo

15.stitching

16.superres

17.ts

18.video

19.Videostab

Contributors

This project exists thanks to all the people who contribute. [Contribute].

感谢

感谢韩天峰老大的指导,

感谢韩天峰老大的指导,

感谢盘古大叔的php7-internal项目以及平常的指导,

感谢木桶技术升级交流群和黑夜路人技术群、以及PHP内核交流的群友对技术的帮助。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值