Skip to content

Commit 05da542

Browse files
committed
Merge branch 'master' into dev
2 parents 15b1543 + 86e9ffc commit 05da542

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

opencv.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ const zend_function_entry opencv_functions[] = {
193193
ZEND_NS_NAMED_FE(OPENCV_NS, cvtColor, ZEND_FN(opencv_cv_t_color), NULL)
194194
ZEND_NS_NAMED_FE(OPENCV_NS, ellipse, ZEND_FN(opencv_ellipse), NULL)
195195
ZEND_NS_NAMED_FE(OPENCV_NS, circle, ZEND_FN(opencv_circle), NULL)
196+
ZEND_NS_NAMED_FE(OPENCV_NS, fillPoly, ZEND_FN(opencv_fill_poly), NULL)//TODO fillPoly
196197
ZEND_NS_NAMED_FE(OPENCV_NS, line, ZEND_FN(opencv_line), NULL)
197198
ZEND_NS_NAMED_FE(OPENCV_NS, rectangle, ZEND_FN(opencv_rectangle), NULL)
198199
ZEND_NS_NAMED_FE(OPENCV_NS, rectangleByPoint, ZEND_FN(opencv_rectangle_by_point), NULL)

source/opencv2/opencv_imgproc.cc

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,55 @@ PHP_FUNCTION(opencv_circle){
117117
RETURN_NULL();
118118
}
119119

120+
/**
121+
* CV\fillPoly
122+
* @param execute_data
123+
* @param return_value
124+
*/
125+
PHP_FUNCTION(opencv_fill_poly){
126+
127+
long thickness = 1, lineType = LINE_8, shift = 0;
128+
long *number_points;
129+
long ncoutours;
130+
zval *mat_zval, *scalar_zval, *offset_point_zval;
131+
zval *start_point_zval;
132+
opencv_point_object *offset_object;
133+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "OOllO|llO",
134+
&mat_zval, opencv_mat_ce,
135+
&start_point_zval, opencv_point_ce,
136+
&number_points,
137+
&ncoutours,
138+
&scalar_zval, opencv_scalar_ce,
139+
&thickness, &lineType,
140+
&offset_point_zval, opencv_point_ce) == FAILURE) {
141+
RETURN_NULL();
142+
}
143+
144+
zval *offset_point_real_zval = Z_REFVAL_P(offset_point_zval);
145+
if(Z_TYPE_P(offset_point_real_zval) == IS_OBJECT && Z_OBJCE_P(offset_point_real_zval)==opencv_point_ce){
146+
// is Point object
147+
offset_object = Z_PHP_POINT_OBJ_P(offset_point_real_zval);
148+
} else{
149+
// isn't Point object
150+
zval instance;
151+
Point dst;
152+
object_init_ex(&instance,opencv_point_ce);
153+
ZVAL_COPY_VALUE(offset_point_real_zval, &instance);// Cover dst_real_zval by Point object
154+
offset_object = Z_PHP_POINT_OBJ_P(offset_point_real_zval);
155+
offset_object->point = new Point(dst);
156+
}
157+
158+
opencv_mat_object *mat_obj = Z_PHP_MAT_OBJ_P(mat_zval);
159+
opencv_point_object *start_point_obj = Z_PHP_POINT_OBJ_P(start_point_zval);
160+
opencv_scalar_object *scalar_obj = Z_PHP_SCALAR_OBJ_P(scalar_zval);
161+
162+
const Point *pts = (start_point_obj->point);
163+
const int *npts = (int*)(number_points);
164+
fillPoly(*(mat_obj->mat), &pts, npts, ncoutours, *(scalar_obj->scalar), thickness, lineType, *offset_object->point);
165+
166+
RETURN_NULL();
167+
}
168+
120169
/**
121170
* CV\line
122171
* @param execute_data

0 commit comments

Comments
 (0)