Skip to content

Update README.md #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ make install
php.ini

```
extension="opencv.so path"
extension="your opencv.so path"
```
## Example

Expand Down Expand Up @@ -149,4 +149,4 @@ result:

感谢[韩天峰](https://github.com/matyhtf)老大的指导,
感谢[盘古大叔](https://github.com/pangudashu)的[php7-internal](https://github.com/pangudashu/php7-internal)项目以及平常的指导,
感谢`木桶技术升级交流群`和`黑夜路人技术群`、以及`PHP内核交流`的群友对技术的帮助。
感谢`木桶技术升级交流群`和`黑夜路人技术群`、以及`PHP内核交流`的群友对技术的帮助。
43 changes: 42 additions & 1 deletion source/opencv2/face/opencv_facerec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,43 @@ PHP_METHOD(opencv_lbph_face_recognizer, predict)
RETURN_LONG(predict_label);
}

PHP_METHOD(opencv_lbph_face_recognizer, predictConfidence)
{
zval *src_zval;
int label = 0;
double confidence = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &src_zval, opencv_mat_ce) == FAILURE) {
RETURN_NULL();
}
opencv_lbph_face_recognizer_object *obj = Z_PHP_LBPH_FACE_RECOGNIZER_OBJ_P(getThis());
opencv_mat_object *src_object = Z_PHP_MAT_OBJ_P(src_zval);
obj->faceRecognizer->predict(*src_object->mat, label, confidence);
RETURN_DOUBLE(confidence);
}

PHP_METHOD(opencv_lbph_face_recognizer, read)
{
char *filename;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &filename) == FAILURE) {
RETURN_NULL();
}

opencv_lbph_face_recognizer_object *obj = Z_PHP_LBPH_FACE_RECOGNIZER_OBJ_P(getThis());
obj->faceRecognizer->read(filename);
RETURN_NULL();
}

PHP_METHOD(opencv_lbph_face_recognizer, write)
{
char *filename;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &filename) == FAILURE) {
RETURN_NULL();
}

opencv_lbph_face_recognizer_object *obj = Z_PHP_LBPH_FACE_RECOGNIZER_OBJ_P(getThis());
obj->faceRecognizer->write(filename);
RETURN_NULL();
}

/**
* opencv_lbph_face_recognizer_methods[]
Expand All @@ -122,6 +159,10 @@ const zend_function_entry opencv_lbph_face_recognizer_methods[] = {
PHP_ME(opencv_lbph_face_recognizer, create, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(opencv_lbph_face_recognizer, train, NULL, ZEND_ACC_PUBLIC)
PHP_ME(opencv_lbph_face_recognizer, predict, NULL, ZEND_ACC_PUBLIC)
// todo
PHP_ME(opencv_lbph_face_recognizer, predictConfidence, NULL, ZEND_ACC_PUBLIC)
PHP_ME(opencv_lbph_face_recognizer, read, NULL, ZEND_ACC_PUBLIC)
PHP_ME(opencv_lbph_face_recognizer, write, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
Expand Down Expand Up @@ -198,4 +239,4 @@ void opencv_base_face_recognizer_init(int module_number){

}

#endif
#endif