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
21 changes: 21 additions & 0 deletions source/opencv2/core/opencv_mat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void opencv_mat_free_obj(zend_object *object)
void opencv_mat_update_property_by_c_mat(zval *z,Mat *mat){
zend_update_property_long(opencv_mat_ce, z, "rows", sizeof("rows")-1, mat->rows);
zend_update_property_long(opencv_mat_ce, z, "cols", sizeof("cols")-1, mat->cols);
zend_update_property_long(opencv_mat_ce, z, "dims", sizeof("dims")-1, mat->dims);
zend_update_property_long(opencv_mat_ce, z, "type", sizeof("type")-1, mat->type());
}

Expand Down Expand Up @@ -121,6 +122,12 @@ PHP_METHOD(opencv_mat, channels)
RETURN_LONG(obj->mat->channels());
}

PHP_METHOD(opencv_mat, empty)
{
opencv_mat_object *obj = Z_PHP_MAT_OBJ_P(getThis());
RETURN_LONG(obj->mat->empty());
}


PHP_METHOD(opencv_mat, zeros)
{
Expand Down Expand Up @@ -174,6 +181,18 @@ PHP_METHOD(opencv_mat, is_continuous)
RETURN_BOOL(isContinuous);
}

/**
* Mat->isSubmatrix
* @param execute_data
* @param return_value
*/
PHP_METHOD(opencv_mat, is_submatrix)
{
opencv_mat_object *obj = Z_PHP_MAT_OBJ_P(getThis());
bool isSubmatrix = obj->mat->isSubmatrix();
RETURN_BOOL(isSubmatrix);
}

/**
* Mat->row(y)
* @param execute_data
Expand Down Expand Up @@ -381,9 +400,11 @@ const zend_function_entry opencv_mat_methods[] = {
PHP_ME(opencv_mat, type, NULL, ZEND_ACC_PUBLIC)
PHP_ME(opencv_mat, depth, NULL, ZEND_ACC_PUBLIC)
PHP_ME(opencv_mat, channels, NULL, ZEND_ACC_PUBLIC)
PHP_ME(opencv_mat, empty, NULL, ZEND_ACC_PUBLIC)
PHP_ME(opencv_mat, print, NULL, ZEND_ACC_PUBLIC)
PHP_ME(opencv_mat, zeros, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_MALIAS(opencv_mat, isContinuous ,is_continuous, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(opencv_mat, isSubmatrix ,is_submatrix, NULL, ZEND_ACC_PUBLIC)
PHP_ME(opencv_mat, row, NULL, ZEND_ACC_PUBLIC)
PHP_ME(opencv_mat, col, NULL, ZEND_ACC_PUBLIC)
PHP_ME(opencv_mat, at, NULL, ZEND_ACC_PUBLIC)
Expand Down
8 changes: 6 additions & 2 deletions tests/absdiff.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ var_dump($dst);
$dst->print();

--EXPECT--
object(CV\Mat)#3 (3) {
object(CV\Mat)#3 (4) {
["type":"CV\Mat":private]=>
int(0)
["rows"]=>
int(3)
["cols"]=>
int(3)
["dims"]=>
int(2)
}
[ 10, 10, 10;
10, 10, 10;
Expand All @@ -47,13 +49,15 @@ object(CV\Scalar)#3 (1) {
}
}
[0, 0, 0, 0]
object(CV\Mat)#3 (3) {
object(CV\Mat)#3 (4) {
["type":"CV\Mat":private]=>
int(16)
["rows"]=>
int(3)
["cols"]=>
int(3)
["dims"]=>
int(2)
}
[ 0, 0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0, 0;
Expand Down
4 changes: 3 additions & 1 deletion tests/cv.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ var_dump($im);
//CV::imwrite('2222.png',$im);
?>
--EXPECT--
object(CV\Mat)#1 (3) {
object(CV\Mat)#1 (4) {
["type":"CV\Mat":private]=>
int(16)
["rows"]=>
int(50)
["cols"]=>
int(50)
["dims"]=>
int(2)
}
8 changes: 6 additions & 2 deletions tests/mat.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,30 @@ var_dump($zeros);
$zeros->print(Formatter::FMT_PYTHON);
?>
--EXPECT--
object(CV\Mat)#2 (3) {
object(CV\Mat)#2 (4) {
["type":"CV\Mat":private]=>
int(16)
["rows"]=>
int(5)
["cols"]=>
int(5)
["dims"]=>
int(2)
}
[[[255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100]],
[[255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100]],
[[255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100]],
[[255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100]],
[[255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100]]]
object(CV\Mat)#3 (3) {
object(CV\Mat)#3 (4) {
["type":"CV\Mat":private]=>
int(0)
["rows"]=>
int(10)
["cols"]=>
int(10)
["dims"]=>
int(2)
}
[[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
Expand Down
4 changes: 3 additions & 1 deletion tests/roi.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ $roi->print(Formatter::FMT_PYTHON);

?>
--EXPECT--
object(CV\Mat)#3 (3) {
object(CV\Mat)#3 (4) {
["type":"CV\Mat":private]=>
int(0)
["rows"]=>
int(5)
["cols"]=>
int(5)
["dims"]=>
int(2)
}
[[ 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0],
Expand Down