Skip to content

Commit 4a613a4

Browse files
MaleicAcidMaleicAcid
authored andcommitted
add CV\getStructuringElement
1 parent a140f26 commit 4a613a4

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

opencv.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ const zend_function_entry opencv_functions[] = {
222222
ZEND_NS_NAMED_FE(OPENCV_NS, bilateralFilter, ZEND_FN(opencv_bilateral_filter), opencv_bilateral_filter_arginfo)
223223
ZEND_NS_NAMED_FE(OPENCV_NS, dilate, ZEND_FN(opencv_dilate), opencv_dilate_arginfo)
224224
ZEND_NS_NAMED_FE(OPENCV_NS, erode, ZEND_FN(opencv_erode), opencv_erode_arginfo)
225+
ZEND_NS_NAMED_FE(OPENCV_NS, getStructuringElement, ZEND_FN(opencv_get_structuring_element), opencv_get_structuring_element_arginfo)
225226
PHP_FE_END /* Must be the last line in opencv_functions[] */
226227
};
227228
/* }}} */

source/opencv2/opencv_imgproc.cc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,42 @@ PHP_FUNCTION(opencv_erode){
644644
RETURN_NULL();
645645
}
646646

647+
/**
648+
* CV\getStructuringElement
649+
* @param execute_data
650+
* @param return_value
651+
*/
652+
PHP_FUNCTION(opencv_get_structuring_element){
653+
long shape;
654+
zval *ksize_zval, *anchor_zval = NULL;
655+
Point anchor = Point(-1,-1);
656+
opencv_mat_object *dst_object;
657+
Mat dst;
658+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "lO|O",
659+
&shape,
660+
&ksize_zval, opencv_size_ce,
661+
&anchor_zval, opencv_point_ce) == FAILURE) {
662+
RETURN_NULL();
663+
}
664+
665+
opencv_size_object *ksize_object = Z_PHP_SIZE_OBJ_P(ksize_zval);
666+
if(anchor_zval != NULL){
667+
opencv_point_object *anchor_object = Z_PHP_POINT_OBJ_P(anchor_zval);
668+
anchor = *anchor_object->point;
669+
}
670+
671+
dst = getStructuringElement((int)shape, *ksize_object->size, anchor);
672+
673+
zval instance;
674+
object_init_ex(&instance,opencv_mat_ce);
675+
opencv_mat_object *dst_obj = Z_PHP_MAT_OBJ_P(&instance);
676+
677+
dst_obj->mat=new Mat(dst);
678+
opencv_mat_update_property_by_c_mat(&instance,dst_obj->mat);
679+
680+
RETURN_ZVAL(&instance,0,0); //return php Mat object
681+
}
682+
647683
/**
648684
* color conversion code in CV\cvtColor,opencv enum ColorConversionCodes
649685
* @param module_number

source/opencv2/opencv_imgproc.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,10 @@ ZEND_BEGIN_ARG_INFO_EX(opencv_erode_arginfo, 0, 0, 7)
111111
ZEND_END_ARG_INFO()
112112
PHP_FUNCTION(opencv_erode);
113113

114+
ZEND_BEGIN_ARG_INFO_EX(opencv_get_structuring_element_arginfo, 0, 0, 3)
115+
ZEND_ARG_INFO(0, shape)
116+
ZEND_ARG_INFO(0, ksize)
117+
ZEND_ARG_INFO(0, anchor)
118+
ZEND_END_ARG_INFO()
119+
PHP_FUNCTION(opencv_get_structuring_element);
114120
#endif //OPENCV_OPENCV_IMGPROC_H

0 commit comments

Comments
 (0)