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
c92c99ed
Commit
c92c99ed
authored
Sep 07, 2017
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enabled forEach for const Mats
parent
2ac57a2b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
mat.inl.hpp
modules/core/include/opencv2/core/mat.inl.hpp
+1
-1
test_mat.cpp
modules/core/test/test_mat.cpp
+18
-0
No files found.
modules/core/include/opencv2/core/mat.inl.hpp
View file @
c92c99ed
...
...
@@ -1214,7 +1214,7 @@ void Mat::forEach(const Functor& operation) {
template
<
typename
_Tp
,
typename
Functor
>
inline
void
Mat
::
forEach
(
const
Functor
&
operation
)
const
{
// call as not const
(
const_cast
<
Mat
*>
(
this
))
->
forEach
<
const
_Tp
>
(
operation
);
(
const_cast
<
Mat
*>
(
this
))
->
forEach
<
_Tp
>
(
operation
);
}
template
<
typename
_Tp
>
inline
...
...
modules/core/test/test_mat.cpp
View file @
c92c99ed
...
...
@@ -671,6 +671,13 @@ struct InitializerFunctor5D{
}
};
template
<
typename
Pixel
>
struct
EmptyFunctor
{
void
operator
()(
const
Pixel
&
,
const
int
*
)
const
{}
};
void
Core_ArrayOpTest
::
run
(
int
/* start_from */
)
{
int
errcount
=
0
;
...
...
@@ -799,6 +806,17 @@ void Core_ArrayOpTest::run( int /* start_from */)
}
}
// test const cv::Mat::forEach
{
const
Mat
a
(
10
,
10
,
CV_32SC3
);
Mat
b
(
10
,
10
,
CV_32SC3
);
const
Mat
&
c
=
b
;
a
.
forEach
<
Point3i
>
(
EmptyFunctor
<
Point3i
>
());
b
.
forEach
<
Point3i
>
(
EmptyFunctor
<
const
Point3i
>
());
c
.
forEach
<
Point3i
>
(
EmptyFunctor
<
Point3i
>
());
// tests compilation, no runtime check is needed
}
RNG
rng
;
const
int
MAX_DIM
=
5
,
MAX_DIM_SZ
=
10
;
// sparse matrix operations
...
...
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