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
f23b6ba6
Commit
f23b6ba6
authored
May 23, 2017
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed multidimensional count non-zero IPP implementation
parent
0e60b265
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
7 deletions
+33
-7
stat.cpp
modules/core/src/stat.cpp
+7
-7
test_countnonzero.cpp
modules/core/test/test_countnonzero.cpp
+26
-0
No files found.
modules/core/src/stat.cpp
View file @
f23b6ba6
...
@@ -1333,23 +1333,23 @@ static bool ipp_countNonZero( Mat &src, int &res )
...
@@ -1333,23 +1333,23 @@ static bool ipp_countNonZero( Mat &src, int &res )
{
{
IppStatus
status
;
IppStatus
status
;
const
Mat
*
arrays
[]
=
{
&
src
,
NULL
};
const
Mat
*
arrays
[]
=
{
&
src
,
NULL
};
uchar
*
ptrs
[
1
]
=
{
NULL
}
;
Mat
planes
[
1
]
;
NAryMatIterator
it
(
arrays
,
p
trs
);
NAryMatIterator
it
(
arrays
,
p
lanes
,
1
);
IppiSize
size
=
{(
int
)
it
.
size
*
src
.
channels
(),
1
};
IppiSize
size
=
{(
int
)
it
.
size
*
src
.
channels
(),
1
};
res
=
0
;
for
(
size_t
i
=
0
;
i
<
it
.
nplanes
;
i
++
,
++
it
)
for
(
size_t
i
=
0
;
i
<
it
.
nplanes
;
i
++
,
++
it
)
{
{
if
(
depth
==
CV_8U
)
if
(
depth
==
CV_8U
)
status
=
CV_INSTRUMENT_FUN_IPP
(
ippiCountInRange_8u_C1R
,
(
const
Ipp8u
*
)
src
.
ptr
(),
(
int
)
src
.
step
,
size
,
&
count
,
0
,
0
);
status
=
CV_INSTRUMENT_FUN_IPP
(
ippiCountInRange_8u_C1R
,
it
.
planes
->
ptr
<
Ipp8u
>
(),
(
int
)
it
.
planes
->
step
,
size
,
&
count
,
0
,
0
);
else
if
(
depth
==
CV_32F
)
else
if
(
depth
==
CV_32F
)
status
=
CV_INSTRUMENT_FUN_IPP
(
ippiCountInRange_32f_C1R
,
(
const
Ipp32f
*
)
src
.
ptr
(),
(
int
)
src
.
step
,
size
,
&
count
,
0
,
0
);
status
=
CV_INSTRUMENT_FUN_IPP
(
ippiCountInRange_32f_C1R
,
it
.
planes
->
ptr
<
Ipp32f
>
(),
(
int
)
it
.
planes
->
step
,
size
,
&
count
,
0
,
0
);
else
else
return
false
;
return
false
;
if
(
status
<
0
)
if
(
status
<
0
||
(
int
)
it
.
planes
->
total
()
*
src
.
channels
()
<
count
)
return
false
;
return
false
;
res
+=
(
size
.
width
*
size
.
height
-
count
)
;
res
+=
(
int
)
it
.
planes
->
total
()
*
src
.
channels
()
-
count
;
}
}
}
}
...
...
modules/core/test/test_countnonzero.cpp
View file @
f23b6ba6
...
@@ -250,3 +250,29 @@ void CV_CountNonZeroTest::run(int)
...
@@ -250,3 +250,29 @@ void CV_CountNonZeroTest::run(int)
}
}
TEST
(
Core_CountNonZero
,
accuracy
)
{
CV_CountNonZeroTest
test
;
test
.
safe_run
();
}
TEST
(
Core_CountNonZero
,
accuracy
)
{
CV_CountNonZeroTest
test
;
test
.
safe_run
();
}
typedef
testing
::
TestWithParam
<
std
::
tr1
::
tuple
<
int
,
int
>
>
CountNonZeroND
;
TEST_P
(
CountNonZeroND
,
ndim
)
{
const
int
dims
=
std
::
tr1
::
get
<
0
>
(
GetParam
());
const
int
type
=
std
::
tr1
::
get
<
1
>
(
GetParam
());
const
int
ONE_SIZE
=
5
;
vector
<
int
>
sizes
(
dims
);
fill
(
sizes
.
begin
(),
sizes
.
end
(),
ONE_SIZE
);
Mat
data
(
sizes
,
CV_MAKETYPE
(
type
,
1
));
data
=
0
;
EXPECT_EQ
(
0
,
cv
::
countNonZero
(
data
));
data
=
Scalar
::
all
(
1
);
EXPECT_EQ
(
pow
(
ONE_SIZE
,
dims
),
cv
::
countNonZero
(
data
));
}
INSTANTIATE_TEST_CASE_P
(
Core
,
CountNonZeroND
,
testing
::
Combine
(
testing
::
Range
(
2
,
9
),
testing
::
Values
(
CV_8U
,
CV_8S
,
CV_32F
)
)
);
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