cleanup TSRMLS_C macro
- only used on PHP 5 (not supported by this ext.) - not needed on PHP 7 - removed from PHP 8
This commit is contained in:
18
pdlib.cc
18
pdlib.cc
@@ -103,10 +103,10 @@ const zend_function_entry cnn_face_detection_class_methods[] = {
|
|||||||
PHP_FE_END
|
PHP_FE_END
|
||||||
};
|
};
|
||||||
|
|
||||||
zend_object* php_cnn_face_detection_new(zend_class_entry *class_type TSRMLS_DC)
|
zend_object* php_cnn_face_detection_new(zend_class_entry *class_type)
|
||||||
{
|
{
|
||||||
cnn_face_detection *cfd = (cnn_face_detection*)ecalloc(1, sizeof(cnn_face_detection));
|
cnn_face_detection *cfd = (cnn_face_detection*)ecalloc(1, sizeof(cnn_face_detection));
|
||||||
zend_object_std_init(&cfd->std, class_type TSRMLS_CC);
|
zend_object_std_init(&cfd->std, class_type);
|
||||||
object_properties_init(&cfd->std, class_type);
|
object_properties_init(&cfd->std, class_type);
|
||||||
cfd->std.handlers = &cnn_face_detection_obj_handlers; //zend_get_std_object_handlers();
|
cfd->std.handlers = &cnn_face_detection_obj_handlers; //zend_get_std_object_handlers();
|
||||||
|
|
||||||
@@ -126,10 +126,10 @@ const zend_function_entry face_landmark_detection_class_methods[] = {
|
|||||||
PHP_FE_END
|
PHP_FE_END
|
||||||
};
|
};
|
||||||
|
|
||||||
zend_object* php_face_landmark_detection_new(zend_class_entry *class_type TSRMLS_DC)
|
zend_object* php_face_landmark_detection_new(zend_class_entry *class_type)
|
||||||
{
|
{
|
||||||
face_landmark_detection *fld = (face_landmark_detection*)ecalloc(1, sizeof(face_landmark_detection));
|
face_landmark_detection *fld = (face_landmark_detection*)ecalloc(1, sizeof(face_landmark_detection));
|
||||||
zend_object_std_init(&fld->std, class_type TSRMLS_CC);
|
zend_object_std_init(&fld->std, class_type);
|
||||||
object_properties_init(&fld->std, class_type);
|
object_properties_init(&fld->std, class_type);
|
||||||
fld->std.handlers = &face_landmark_detection_obj_handlers;
|
fld->std.handlers = &face_landmark_detection_obj_handlers;
|
||||||
|
|
||||||
@@ -149,10 +149,10 @@ const zend_function_entry face_recognition_class_methods[] = {
|
|||||||
PHP_FE_END
|
PHP_FE_END
|
||||||
};
|
};
|
||||||
|
|
||||||
zend_object* php_face_recognition_new(zend_class_entry *class_type TSRMLS_DC)
|
zend_object* php_face_recognition_new(zend_class_entry *class_type)
|
||||||
{
|
{
|
||||||
face_recognition *fr = (face_recognition*)ecalloc(1, sizeof(face_recognition));
|
face_recognition *fr = (face_recognition*)ecalloc(1, sizeof(face_recognition));
|
||||||
zend_object_std_init(&fr->std, class_type TSRMLS_CC);
|
zend_object_std_init(&fr->std, class_type);
|
||||||
object_properties_init(&fr->std, class_type);
|
object_properties_init(&fr->std, class_type);
|
||||||
fr->std.handlers = &face_recognition_obj_handlers;
|
fr->std.handlers = &face_recognition_obj_handlers;
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ PHP_MINIT_FUNCTION(pdlib)
|
|||||||
// CnnFaceDetection class definition
|
// CnnFaceDetection class definition
|
||||||
//
|
//
|
||||||
INIT_CLASS_ENTRY(ce, "CnnFaceDetection", cnn_face_detection_class_methods);
|
INIT_CLASS_ENTRY(ce, "CnnFaceDetection", cnn_face_detection_class_methods);
|
||||||
cnn_face_detection_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
cnn_face_detection_ce = zend_register_internal_class(&ce);
|
||||||
cnn_face_detection_ce->create_object = php_cnn_face_detection_new;
|
cnn_face_detection_ce->create_object = php_cnn_face_detection_new;
|
||||||
memcpy(&cnn_face_detection_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
memcpy(&cnn_face_detection_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||||
cnn_face_detection_obj_handlers.offset = XtOffsetOf(cnn_face_detection, std);
|
cnn_face_detection_obj_handlers.offset = XtOffsetOf(cnn_face_detection, std);
|
||||||
@@ -183,7 +183,7 @@ PHP_MINIT_FUNCTION(pdlib)
|
|||||||
// FaceLandmarkDetection class definition
|
// FaceLandmarkDetection class definition
|
||||||
//
|
//
|
||||||
INIT_CLASS_ENTRY(ce, "FaceLandmarkDetection", face_landmark_detection_class_methods);
|
INIT_CLASS_ENTRY(ce, "FaceLandmarkDetection", face_landmark_detection_class_methods);
|
||||||
face_landmark_detection_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
face_landmark_detection_ce = zend_register_internal_class(&ce);
|
||||||
face_landmark_detection_ce->create_object = php_face_landmark_detection_new;
|
face_landmark_detection_ce->create_object = php_face_landmark_detection_new;
|
||||||
memcpy(&face_landmark_detection_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
memcpy(&face_landmark_detection_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||||
face_landmark_detection_obj_handlers.offset = XtOffsetOf(face_landmark_detection, std);
|
face_landmark_detection_obj_handlers.offset = XtOffsetOf(face_landmark_detection, std);
|
||||||
@@ -192,7 +192,7 @@ PHP_MINIT_FUNCTION(pdlib)
|
|||||||
// FaceRecognition class definition
|
// FaceRecognition class definition
|
||||||
//
|
//
|
||||||
INIT_CLASS_ENTRY(ce, "FaceRecognition", face_recognition_class_methods);
|
INIT_CLASS_ENTRY(ce, "FaceRecognition", face_recognition_class_methods);
|
||||||
face_recognition_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
face_recognition_ce = zend_register_internal_class(&ce);
|
||||||
face_recognition_ce->create_object = php_face_recognition_new;
|
face_recognition_ce->create_object = php_face_recognition_new;
|
||||||
memcpy(&face_recognition_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
memcpy(&face_recognition_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||||
face_recognition_obj_handlers.offset = XtOffsetOf(face_recognition, std);
|
face_recognition_obj_handlers.offset = XtOffsetOf(face_recognition, std);
|
||||||
|
|||||||
@@ -66,13 +66,13 @@ ZEND_TSRMLS_CACHE_EXTERN()
|
|||||||
/* Tries to find given key in array */ \
|
/* Tries to find given key in array */ \
|
||||||
data##key = zend_hash_str_find(hashtable, #key, sizeof(#key)-1); \
|
data##key = zend_hash_str_find(hashtable, #key, sizeof(#key)-1); \
|
||||||
if (data##key == nullptr) { \
|
if (data##key == nullptr) { \
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, #error_key_missing); \
|
zend_throw_exception_ex(zend_ce_exception, 0, #error_key_missing); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
/* We also need to check proper type of value in associative array */ \
|
/* We also need to check proper type of value in associative array */ \
|
||||||
if (Z_TYPE_P(data##key) != IS_LONG) { \
|
if (Z_TYPE_P(data##key) != IS_LONG) { \
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, #error_key_not_long); \
|
zend_throw_exception_ex(zend_ce_exception, 0, #error_key_not_long); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
zend_long key = Z_LVAL_P(data##key); \
|
zend_long key = Z_LVAL_P(data##key); \
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
|
|||||||
if(zend_parse_parameters(ZEND_NUM_ARGS(), "a", &edges_arg) == FAILURE){
|
if(zend_parse_parameters(ZEND_NUM_ARGS(), "a", &edges_arg) == FAILURE){
|
||||||
zend_throw_exception_ex(
|
zend_throw_exception_ex(
|
||||||
zend_ce_exception,
|
zend_ce_exception,
|
||||||
0 TSRMLS_CC,
|
0,
|
||||||
"Unable to parse edges in dlib_chinese_whispers");
|
"Unable to parse edges in dlib_chinese_whispers");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
|
|||||||
if (Z_TYPE_P(edge) != IS_ARRAY) {
|
if (Z_TYPE_P(edge) != IS_ARRAY) {
|
||||||
zend_throw_exception_ex(
|
zend_throw_exception_ex(
|
||||||
zend_ce_exception,
|
zend_ce_exception,
|
||||||
0 TSRMLS_CC,
|
0,
|
||||||
"Each edge provided in array needs to be numeric array of 2 elements");
|
"Each edge provided in array needs to be numeric array of 2 elements");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
|
|||||||
if (zend_hash_num_elements(edge_hash) != 2) {
|
if (zend_hash_num_elements(edge_hash) != 2) {
|
||||||
zend_throw_exception_ex(
|
zend_throw_exception_ex(
|
||||||
zend_ce_exception,
|
zend_ce_exception,
|
||||||
0 TSRMLS_CC,
|
0,
|
||||||
"Edges need to contain exactly two elements");
|
"Edges need to contain exactly two elements");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
|
|||||||
!zend_hash_index_exists(edge_hash, 1)) {
|
!zend_hash_index_exists(edge_hash, 1)) {
|
||||||
zend_throw_exception_ex(
|
zend_throw_exception_ex(
|
||||||
zend_ce_exception,
|
zend_ce_exception,
|
||||||
0 TSRMLS_CC,
|
0,
|
||||||
"Edge should be numeric array with integer keys");
|
"Edge should be numeric array with integer keys");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
|
|||||||
if ((Z_TYPE_P(elem_i) != IS_LONG) || (Z_TYPE_P(elem_j) != IS_LONG)) {
|
if ((Z_TYPE_P(elem_i) != IS_LONG) || (Z_TYPE_P(elem_j) != IS_LONG)) {
|
||||||
zend_throw_exception_ex(
|
zend_throw_exception_ex(
|
||||||
zend_ce_exception,
|
zend_ce_exception,
|
||||||
0 TSRMLS_CC,
|
0,
|
||||||
"Both elements in each edge must be of long type");
|
"Both elements in each edge must be of long type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
|
|||||||
}
|
}
|
||||||
} catch (exception& e)
|
} catch (exception& e)
|
||||||
{
|
{
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
|
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ PHP_METHOD(CnnFaceDetection, __construct)
|
|||||||
cnn_face_detection *cfd = Z_CNN_FACE_DETECTION_P(getThis());
|
cnn_face_detection *cfd = Z_CNN_FACE_DETECTION_P(getThis());
|
||||||
|
|
||||||
if (NULL == cfd) {
|
if (NULL == cfd) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to find obj in CnnFaceDetection::__construct()");
|
php_error_docref(NULL, E_ERROR, "Unable to find obj in CnnFaceDetection::__construct()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s",
|
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s",
|
||||||
&sz_cnn_face_detection_model_path, &cnn_face_detection_model_path_len) == FAILURE){
|
&sz_cnn_face_detection_model_path, &cnn_face_detection_model_path_len) == FAILURE){
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse face_detection_model_path");
|
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to parse face_detection_model_path");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ PHP_METHOD(CnnFaceDetection, __construct)
|
|||||||
deserialize(cnn_face_detection_model_path) >> *pnet;
|
deserialize(cnn_face_detection_model_path) >> *pnet;
|
||||||
cfd->net = pnet;
|
cfd->net = pnet;
|
||||||
} catch (exception& e) {
|
} catch (exception& e) {
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
|
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ PHP_METHOD(CnnFaceDetection, detect)
|
|||||||
long upsample_num = 0;
|
long upsample_num = 0;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &img_path, &img_path_len, &upsample_num) == FAILURE){
|
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &img_path, &img_path_len, &upsample_num) == FAILURE){
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse detect arguments");
|
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to parse detect arguments");
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ PHP_METHOD(CnnFaceDetection, detect)
|
|||||||
}
|
}
|
||||||
catch (exception& e)
|
catch (exception& e)
|
||||||
{
|
{
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
|
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ PHP_FUNCTION(dlib_face_detection)
|
|||||||
long upsample_num = 0;
|
long upsample_num = 0;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &img_path, &img_path_len, &upsample_num) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &img_path, &img_path_len, &upsample_num) == FAILURE) {
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse dlib_face_detection arguments");
|
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to parse dlib_face_detection arguments");
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -78,14 +78,14 @@ PHP_METHOD(FaceLandmarkDetection, __construct)
|
|||||||
face_landmark_detection *fld = Z_FACE_LANDMARK_DETECTION_P(getThis());
|
face_landmark_detection *fld = Z_FACE_LANDMARK_DETECTION_P(getThis());
|
||||||
|
|
||||||
if (nullptr == fld) {
|
if (nullptr == fld) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to find obj in FaceLandmarkDetection::__construct()");
|
php_error_docref(NULL, E_ERROR, "Unable to find obj in FaceLandmarkDetection::__construct()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse predictor model's path
|
// Parse predictor model's path
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s",
|
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s",
|
||||||
&sz_shape_predictor_file_path, &shape_predictor_file_path_len) == FAILURE){
|
&sz_shape_predictor_file_path, &shape_predictor_file_path_len) == FAILURE){
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse shape_predictor_file_path");
|
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to parse shape_predictor_file_path");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ PHP_METHOD(FaceLandmarkDetection, __construct)
|
|||||||
fld->sp = new shape_predictor;
|
fld->sp = new shape_predictor;
|
||||||
deserialize(shape_predictor_file_path) >> *(fld->sp);
|
deserialize(shape_predictor_file_path) >> *(fld->sp);
|
||||||
} catch (exception& e) {
|
} catch (exception& e) {
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
|
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ PHP_METHOD(FaceLandmarkDetection, detect)
|
|||||||
// Parse path to image and bounding box. Bounding box is associative array of 4 elements - "top", "bottom", "left" and "right".
|
// Parse path to image and bounding box. Bounding box is associative array of 4 elements - "top", "bottom", "left" and "right".
|
||||||
//
|
//
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sa", &img_path, &img_path_len, &bounding_box) == FAILURE){
|
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sa", &img_path, &img_path_len, &bounding_box) == FAILURE){
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse detect arguments");
|
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to parse detect arguments");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ PHP_METHOD(FaceLandmarkDetection, detect)
|
|||||||
HashTable *bounding_box_hash = Z_ARRVAL_P(bounding_box);
|
HashTable *bounding_box_hash = Z_ARRVAL_P(bounding_box);
|
||||||
uint32_t bounding_box_num_elements = zend_hash_num_elements(bounding_box_hash);
|
uint32_t bounding_box_num_elements = zend_hash_num_elements(bounding_box_hash);
|
||||||
if (bounding_box_num_elements < 4) {
|
if (bounding_box_num_elements < 4) {
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Bounding box (second argument) needs to have at least 4 elements");
|
zend_throw_exception_ex(zend_ce_exception, 0, "Bounding box (second argument) needs to have at least 4 elements");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ PHP_METHOD(FaceLandmarkDetection, detect)
|
|||||||
add_assoc_zval(return_value, "rect", &rect_arr);
|
add_assoc_zval(return_value, "rect", &rect_arr);
|
||||||
add_assoc_zval(return_value, "parts", &parts_arr);
|
add_assoc_zval(return_value, "parts", &parts_arr);
|
||||||
} catch (exception& e) {
|
} catch (exception& e) {
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
|
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ PHP_METHOD(FaceRecognition, __construct)
|
|||||||
face_recognition *fr = Z_FACE_RECOGNITION_P(getThis());
|
face_recognition *fr = Z_FACE_RECOGNITION_P(getThis());
|
||||||
|
|
||||||
if (NULL == fr) {
|
if (NULL == fr) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to find obj in FaceRecognition::__construct()");
|
php_error_docref(NULL, E_ERROR, "Unable to find obj in FaceRecognition::__construct()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s",
|
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s",
|
||||||
&sz_face_recognition_model_path, &face_recognition_model_path_len) == FAILURE){
|
&sz_face_recognition_model_path, &face_recognition_model_path_len) == FAILURE){
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse face_recognition_model_path");
|
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to parse face_recognition_model_path");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ PHP_METHOD(FaceRecognition, __construct)
|
|||||||
fr->net = new anet_type;
|
fr->net = new anet_type;
|
||||||
deserialize(face_recognition_model_path) >> *(fr->net);
|
deserialize(face_recognition_model_path) >> *(fr->net);
|
||||||
} catch (exception& e) {
|
} catch (exception& e) {
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
|
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,24 +74,24 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
|
|||||||
long num_jitters = 1;
|
long num_jitters = 1;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sa|l", &img_path, &img_path_len, &shape, &num_jitters) == FAILURE){
|
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sa|l", &img_path, &img_path_len, &shape, &num_jitters) == FAILURE){
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse computeDescriptor arguments");
|
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to parse computeDescriptor arguments");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashTable *shape_hash = Z_ARRVAL_P(shape);
|
HashTable *shape_hash = Z_ARRVAL_P(shape);
|
||||||
uint32_t shape_hash_num_elements = zend_hash_num_elements(shape_hash);
|
uint32_t shape_hash_num_elements = zend_hash_num_elements(shape_hash);
|
||||||
if (shape_hash_num_elements != 2) {
|
if (shape_hash_num_elements != 2) {
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Shape (second argument) needs to have exactly 2 elements - keys \"rect\" and \"parts\"");
|
zend_throw_exception_ex(zend_ce_exception, 0, "Shape (second argument) needs to have exactly 2 elements - keys \"rect\" and \"parts\"");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
zval *rect_zval = zend_hash_str_find(shape_hash, "rect", sizeof("rect")-1);
|
zval *rect_zval = zend_hash_str_find(shape_hash, "rect", sizeof("rect")-1);
|
||||||
if (rect_zval == nullptr) {
|
if (rect_zval == nullptr) {
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Shape (second argument) array needs to have \"rect\" key"); \
|
zend_throw_exception_ex(zend_ce_exception, 0, "Shape (second argument) array needs to have \"rect\" key"); \
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Z_TYPE_P(rect_zval) != IS_ARRAY) {
|
if (Z_TYPE_P(rect_zval) != IS_ARRAY) {
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Value of shape's key \"rect\" must be array");
|
zend_throw_exception_ex(zend_ce_exception, 0, "Value of shape's key \"rect\" must be array");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HashTable *rect_hash = Z_ARRVAL_P(rect_zval);
|
HashTable *rect_hash = Z_ARRVAL_P(rect_zval);
|
||||||
@@ -104,11 +104,11 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
|
|||||||
|
|
||||||
zval *parts_zval = zend_hash_str_find(shape_hash, "parts", sizeof("parts")-1);
|
zval *parts_zval = zend_hash_str_find(shape_hash, "parts", sizeof("parts")-1);
|
||||||
if (parts_zval == nullptr) {
|
if (parts_zval == nullptr) {
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Shape (second argument) array needs to have \"parts\" key"); \
|
zend_throw_exception_ex(zend_ce_exception, 0, "Shape (second argument) array needs to have \"parts\" key"); \
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Z_TYPE_P(parts_zval) != IS_ARRAY) {
|
if (Z_TYPE_P(parts_zval) != IS_ARRAY) {
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Value of shape's key \"parts\" must be array");
|
zend_throw_exception_ex(zend_ce_exception, 0, "Value of shape's key \"parts\" must be array");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HashTable *parts_hash = Z_ARRVAL_P(parts_zval);
|
HashTable *parts_hash = Z_ARRVAL_P(parts_zval);
|
||||||
@@ -117,7 +117,7 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
|
|||||||
point parts_points[parts_count];
|
point parts_points[parts_count];
|
||||||
|
|
||||||
if ((parts_count != 5) && (parts_count != 68)) {
|
if ((parts_count != 5) && (parts_count != 68)) {
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC,
|
zend_throw_exception_ex(zend_ce_exception, 0,
|
||||||
"The full_object_detection must use the iBUG 300W 68 point face landmark style or dlib's 5 point style");
|
"The full_object_detection must use the iBUG 300W 68 point face landmark style or dlib's 5 point style");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -137,17 +137,17 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
|
|||||||
PARSE_POINT(x)
|
PARSE_POINT(x)
|
||||||
PARSE_POINT(y)
|
PARSE_POINT(y)
|
||||||
if (num_index > parts_count) {
|
if (num_index > parts_count) {
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Internal error, bad parsing of parts array");
|
zend_throw_exception_ex(zend_ce_exception, 0, "Internal error, bad parsing of parts array");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
parts_points[num_index] = point(x, y);
|
parts_points[num_index] = point(x, y);
|
||||||
} else {
|
} else {
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Values from parts array must be arrays with \"x\" and \"y\" keys");
|
zend_throw_exception_ex(zend_ce_exception, 0, "Values from parts array must be arrays with \"x\" and \"y\" keys");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HASH_KEY_IS_STRING:
|
case HASH_KEY_IS_STRING:
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Parts array must be indexed and it contains string keys");
|
zend_throw_exception_ex(zend_ce_exception, 0, "Parts array must be indexed and it contains string keys");
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
|
|||||||
add_next_index_double(return_value, d);
|
add_next_index_double(return_value, d);
|
||||||
}
|
}
|
||||||
} catch (exception& e) {
|
} catch (exception& e) {
|
||||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
|
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user