Skip to content

Commit 665f750

Browse files
authored
Merge pull request #4 from MaleicAcid/master
add cv/Mat->dims (test passed)
2 parents a44ea45 + 35aeb65 commit 665f750

File tree

5 files changed

+39
-6
lines changed

5 files changed

+39
-6
lines changed

source/opencv2/core/opencv_mat.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ void opencv_mat_free_obj(zend_object *object)
5555
void opencv_mat_update_property_by_c_mat(zval *z,Mat *mat){
5656
zend_update_property_long(opencv_mat_ce, z, "rows", sizeof("rows")-1, mat->rows);
5757
zend_update_property_long(opencv_mat_ce, z, "cols", sizeof("cols")-1, mat->cols);
58+
zend_update_property_long(opencv_mat_ce, z, "dims", sizeof("dims")-1, mat->dims);
5859
zend_update_property_long(opencv_mat_ce, z, "type", sizeof("type")-1, mat->type());
5960
}
6061

@@ -121,6 +122,12 @@ PHP_METHOD(opencv_mat, channels)
121122
RETURN_LONG(obj->mat->channels());
122123
}
123124

125+
PHP_METHOD(opencv_mat, empty)
126+
{
127+
opencv_mat_object *obj = Z_PHP_MAT_OBJ_P(getThis());
128+
RETURN_LONG(obj->mat->empty());
129+
}
130+
124131

125132
PHP_METHOD(opencv_mat, zeros)
126133
{
@@ -174,6 +181,18 @@ PHP_METHOD(opencv_mat, is_continuous)
174181
RETURN_BOOL(isContinuous);
175182
}
176183

184+
/**
185+
* Mat->isSubmatrix
186+
* @param execute_data
187+
* @param return_value
188+
*/
189+
PHP_METHOD(opencv_mat, is_submatrix)
190+
{
191+
opencv_mat_object *obj = Z_PHP_MAT_OBJ_P(getThis());
192+
bool isSubmatrix = obj->mat->isSubmatrix();
193+
RETURN_BOOL(isSubmatrix);
194+
}
195+
177196
/**
178197
* Mat->row(y)
179198
* @param execute_data
@@ -381,9 +400,11 @@ const zend_function_entry opencv_mat_methods[] = {
381400
PHP_ME(opencv_mat, type, NULL, ZEND_ACC_PUBLIC)
382401
PHP_ME(opencv_mat, depth, NULL, ZEND_ACC_PUBLIC)
383402
PHP_ME(opencv_mat, channels, NULL, ZEND_ACC_PUBLIC)
403+
PHP_ME(opencv_mat, empty, NULL, ZEND_ACC_PUBLIC)
384404
PHP_ME(opencv_mat, print, NULL, ZEND_ACC_PUBLIC)
385405
PHP_ME(opencv_mat, zeros, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
386406
PHP_MALIAS(opencv_mat, isContinuous ,is_continuous, NULL, ZEND_ACC_PUBLIC)
407+
PHP_MALIAS(opencv_mat, isSubmatrix ,is_submatrix, NULL, ZEND_ACC_PUBLIC)
387408
PHP_ME(opencv_mat, row, NULL, ZEND_ACC_PUBLIC)
388409
PHP_ME(opencv_mat, col, NULL, ZEND_ACC_PUBLIC)
389410
PHP_ME(opencv_mat, at, NULL, ZEND_ACC_PUBLIC)

tests/absdiff.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ var_dump($dst);
2222
$dst->print();
2323

2424
--EXPECT--
25-
object(CV\Mat)#3 (3) {
25+
object(CV\Mat)#3 (4) {
2626
["type":"CV\Mat":private]=>
2727
int(0)
2828
["rows"]=>
2929
int(3)
3030
["cols"]=>
3131
int(3)
32+
["dims"]=>
33+
int(2)
3234
}
3335
[ 10, 10, 10;
3436
10, 10, 10;
@@ -47,13 +49,15 @@ object(CV\Scalar)#3 (1) {
4749
}
4850
}
4951
[0, 0, 0, 0]
50-
object(CV\Mat)#3 (3) {
52+
object(CV\Mat)#3 (4) {
5153
["type":"CV\Mat":private]=>
5254
int(16)
5355
["rows"]=>
5456
int(3)
5557
["cols"]=>
5658
int(3)
59+
["dims"]=>
60+
int(2)
5761
}
5862
[ 0, 0, 0, 0, 0, 0, 0, 0, 0;
5963
0, 0, 0, 0, 0, 0, 0, 0, 0;

tests/cv.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ var_dump($im);
1313
//CV::imwrite('2222.png',$im);
1414
?>
1515
--EXPECT--
16-
object(CV\Mat)#1 (3) {
16+
object(CV\Mat)#1 (4) {
1717
["type":"CV\Mat":private]=>
1818
int(16)
1919
["rows"]=>
2020
int(50)
2121
["cols"]=>
2222
int(50)
23+
["dims"]=>
24+
int(2)
2325
}

tests/mat.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,30 @@ var_dump($zeros);
1717
$zeros->print(Formatter::FMT_PYTHON);
1818
?>
1919
--EXPECT--
20-
object(CV\Mat)#2 (3) {
20+
object(CV\Mat)#2 (4) {
2121
["type":"CV\Mat":private]=>
2222
int(16)
2323
["rows"]=>
2424
int(5)
2525
["cols"]=>
2626
int(5)
27+
["dims"]=>
28+
int(2)
2729
}
2830
[[[255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100]],
2931
[[255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100]],
3032
[[255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100]],
3133
[[255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100]],
3234
[[255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100], [255, 100, 100]]]
33-
object(CV\Mat)#3 (3) {
35+
object(CV\Mat)#3 (4) {
3436
["type":"CV\Mat":private]=>
3537
int(0)
3638
["rows"]=>
3739
int(10)
3840
["cols"]=>
3941
int(10)
42+
["dims"]=>
43+
int(2)
4044
}
4145
[[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4246
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

tests/roi.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ $roi->print(Formatter::FMT_PYTHON);
2020

2121
?>
2222
--EXPECT--
23-
object(CV\Mat)#3 (3) {
23+
object(CV\Mat)#3 (4) {
2424
["type":"CV\Mat":private]=>
2525
int(0)
2626
["rows"]=>
2727
int(5)
2828
["cols"]=>
2929
int(5)
30+
["dims"]=>
31+
int(2)
3032
}
3133
[[ 0, 0, 0, 0, 0],
3234
[ 0, 0, 0, 0, 0],

0 commit comments

Comments
 (0)