Skip to content

Commit e6ffb0d

Browse files
authored
Update opencv_facerec.cc
1 parent 0c49689 commit e6ffb0d

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

source/opencv2/face/opencv_facerec.cc

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,43 @@ PHP_METHOD(opencv_lbph_face_recognizer, predict)
114114
RETURN_LONG(predict_label);
115115
}
116116

117+
PHP_METHOD(opencv_lbph_face_recognizer, predictConfidence)
118+
{
119+
zval *src_zval;
120+
int label = 0;
121+
double confidence = 0;
122+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &src_zval, opencv_mat_ce) == FAILURE) {
123+
RETURN_NULL();
124+
}
125+
opencv_lbph_face_recognizer_object *obj = Z_PHP_LBPH_FACE_RECOGNIZER_OBJ_P(getThis());
126+
opencv_mat_object *src_object = Z_PHP_MAT_OBJ_P(src_zval);
127+
obj->faceRecognizer->predict(*src_object->mat, label, confidence);
128+
RETURN_DOUBLE(confidence);
129+
}
130+
131+
PHP_METHOD(opencv_lbph_face_recognizer, read)
132+
{
133+
char *filename;
134+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &filename) == FAILURE) {
135+
RETURN_NULL();
136+
}
137+
138+
opencv_lbph_face_recognizer_object *obj = Z_PHP_LBPH_FACE_RECOGNIZER_OBJ_P(getThis());
139+
obj->faceRecognizer->read(filename);
140+
RETURN_NULL();
141+
}
142+
143+
PHP_METHOD(opencv_lbph_face_recognizer, write)
144+
{
145+
char *filename;
146+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &filename) == FAILURE) {
147+
RETURN_NULL();
148+
}
149+
150+
opencv_lbph_face_recognizer_object *obj = Z_PHP_LBPH_FACE_RECOGNIZER_OBJ_P(getThis());
151+
obj->faceRecognizer->write(filename);
152+
RETURN_NULL();
153+
}
117154

118155
/**
119156
* opencv_lbph_face_recognizer_methods[]
@@ -122,6 +159,9 @@ const zend_function_entry opencv_lbph_face_recognizer_methods[] = {
122159
PHP_ME(opencv_lbph_face_recognizer, create, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
123160
PHP_ME(opencv_lbph_face_recognizer, train, NULL, ZEND_ACC_PUBLIC)
124161
PHP_ME(opencv_lbph_face_recognizer, predict, NULL, ZEND_ACC_PUBLIC)
162+
PHP_ME(opencv_lbph_face_recognizer, predictConfidence, NULL, ZEND_ACC_PUBLIC)
163+
PHP_ME(opencv_lbph_face_recognizer, read, NULL, ZEND_ACC_PUBLIC)
164+
PHP_ME(opencv_lbph_face_recognizer, write, NULL, ZEND_ACC_PUBLIC)
125165
PHP_FE_END
126166
};
127167
/* }}} */
@@ -198,4 +238,4 @@ void opencv_base_face_recognizer_init(int module_number){
198238

199239
}
200240

201-
#endif
241+
#endif

0 commit comments

Comments
 (0)