Skip to content
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
1 change: 1 addition & 0 deletions opencv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ const zend_function_entry opencv_functions[] = {
ZEND_NS_NAMED_FE(OPENCV_NS, cvtColor, ZEND_FN(opencv_cv_t_color), NULL)
ZEND_NS_NAMED_FE(OPENCV_NS, ellipse, ZEND_FN(opencv_ellipse), NULL)
ZEND_NS_NAMED_FE(OPENCV_NS, circle, ZEND_FN(opencv_circle), NULL)
ZEND_NS_NAMED_FE(OPENCV_NS, fillPoly, ZEND_FN(opencv_fill_poly), NULL)//TODO fillPoly
ZEND_NS_NAMED_FE(OPENCV_NS, line, ZEND_FN(opencv_line), NULL)
ZEND_NS_NAMED_FE(OPENCV_NS, rectangle, ZEND_FN(opencv_rectangle), NULL)
ZEND_NS_NAMED_FE(OPENCV_NS, rectangleByPoint, ZEND_FN(opencv_rectangle_by_point), NULL)
Expand Down
49 changes: 49 additions & 0 deletions source/opencv2/opencv_imgproc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,55 @@ PHP_FUNCTION(opencv_circle){
RETURN_NULL();
}

/**
* CV\fillPoly
* @param execute_data
* @param return_value
*/
PHP_FUNCTION(opencv_fill_poly){

long thickness = 1, lineType = LINE_8, shift = 0;
long *number_points;
long ncoutours;
zval *mat_zval, *scalar_zval, *offset_point_zval;
zval *start_point_zval;
opencv_point_object *offset_object;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "OOllO|llO",
&mat_zval, opencv_mat_ce,
&start_point_zval, opencv_point_ce,
&number_points,
&ncoutours,
&scalar_zval, opencv_scalar_ce,
&thickness, &lineType,
&offset_point_zval, opencv_point_ce) == FAILURE) {
RETURN_NULL();
}

zval *offset_point_real_zval = Z_REFVAL_P(offset_point_zval);
if(Z_TYPE_P(offset_point_real_zval) == IS_OBJECT && Z_OBJCE_P(offset_point_real_zval)==opencv_point_ce){
// is Point object
offset_object = Z_PHP_POINT_OBJ_P(offset_point_real_zval);
} else{
// isn't Point object
zval instance;
Point dst;
object_init_ex(&instance,opencv_point_ce);
ZVAL_COPY_VALUE(offset_point_real_zval, &instance);// Cover dst_real_zval by Point object
offset_object = Z_PHP_POINT_OBJ_P(offset_point_real_zval);
offset_object->point = new Point(dst);
}

opencv_mat_object *mat_obj = Z_PHP_MAT_OBJ_P(mat_zval);
opencv_point_object *start_point_obj = Z_PHP_POINT_OBJ_P(start_point_zval);
opencv_scalar_object *scalar_obj = Z_PHP_SCALAR_OBJ_P(scalar_zval);

const Point *pts = (start_point_obj->point);
const int *npts = (int*)(number_points);
fillPoly(*(mat_obj->mat), &pts, npts, ncoutours, *(scalar_obj->scalar), thickness, lineType, *offset_object->point);

RETURN_NULL();
}

/**
* CV\line
* @param execute_data
Expand Down