Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
d5afd070
Commit
d5afd070
authored
Jul 01, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4094 from kashefy:Mat_push_back_MatExpr_bug_4340
parents
88691506
790ef21a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
0 deletions
+52
-0
mat.inl.hpp
modules/core/include/opencv2/core/mat.inl.hpp
+6
-0
test_mat.cpp
modules/core/test/test_mat.cpp
+46
-0
No files found.
modules/core/include/opencv2/core/mat.inl.hpp
View file @
d5afd070
...
...
@@ -1096,6 +1096,12 @@ void Mat::push_back(const Mat_<_Tp>& m)
push_back
((
const
Mat
&
)
m
);
}
template
<>
inline
void
Mat
::
push_back
(
const
MatExpr
&
expr
)
{
push_back
(
static_cast
<
Mat
>
(
expr
));
}
///////////////////////////// MatSize ////////////////////////////
inline
...
...
modules/core/test/test_mat.cpp
View file @
d5afd070
...
...
@@ -1189,6 +1189,52 @@ TEST(Core_Mat, reshape_1942)
ASSERT_EQ
(
1
,
cn
);
}
TEST
(
Core_Mat
,
push_back
)
{
Mat
a
=
(
Mat_
<
float
>
(
1
,
2
)
<<
3.4884074
f
,
1.4159607
f
);
Mat
b
=
(
Mat_
<
float
>
(
1
,
2
)
<<
0.78737736
f
,
2.3456569
f
);
a
.
push_back
(
b
);
ASSERT_EQ
(
2
,
a
.
cols
);
ASSERT_EQ
(
2
,
a
.
rows
);
ASSERT_FLOAT_EQ
(
3.4884074
f
,
a
.
at
<
float
>
(
0
,
0
));
ASSERT_FLOAT_EQ
(
1.4159607
f
,
a
.
at
<
float
>
(
0
,
1
));
ASSERT_FLOAT_EQ
(
0.78737736
f
,
a
.
at
<
float
>
(
1
,
0
));
ASSERT_FLOAT_EQ
(
2.3456569
f
,
a
.
at
<
float
>
(
1
,
1
));
Mat
c
=
(
Mat_
<
float
>
(
2
,
2
)
<<
-
0.88010466
f
,
0.3009364
f
,
2.22399974
f
,
-
5.45933905
f
);
ASSERT_EQ
(
c
.
rows
,
a
.
cols
);
a
.
push_back
(
c
.
t
());
ASSERT_EQ
(
2
,
a
.
cols
);
ASSERT_EQ
(
4
,
a
.
rows
);
ASSERT_FLOAT_EQ
(
3.4884074
f
,
a
.
at
<
float
>
(
0
,
0
));
ASSERT_FLOAT_EQ
(
1.4159607
f
,
a
.
at
<
float
>
(
0
,
1
));
ASSERT_FLOAT_EQ
(
0.78737736
f
,
a
.
at
<
float
>
(
1
,
0
));
ASSERT_FLOAT_EQ
(
2.3456569
f
,
a
.
at
<
float
>
(
1
,
1
));
ASSERT_FLOAT_EQ
(
-
0.88010466
f
,
a
.
at
<
float
>
(
2
,
0
));
ASSERT_FLOAT_EQ
(
2.22399974
f
,
a
.
at
<
float
>
(
2
,
1
));
ASSERT_FLOAT_EQ
(
0.3009364
f
,
a
.
at
<
float
>
(
3
,
0
));
ASSERT_FLOAT_EQ
(
-
5.45933905
f
,
a
.
at
<
float
>
(
3
,
1
));
a
.
push_back
(
Mat
::
ones
(
2
,
2
,
CV_32FC1
));
ASSERT_EQ
(
6
,
a
.
rows
);
for
(
int
row
=
4
;
row
<
a
.
rows
;
row
++
)
{
for
(
int
col
=
0
;
col
<
a
.
cols
;
col
++
)
{
ASSERT_FLOAT_EQ
(
1.
f
,
a
.
at
<
float
>
(
row
,
col
));
}
}
}
TEST
(
Core_Mat
,
copyNx1ToVector
)
{
cv
::
Mat_
<
uchar
>
src
(
5
,
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment