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
936523ae
Commit
936523ae
authored
Oct 30, 2018
by
LaurentBerger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add python test for copyto with mask
parent
220b2785
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
test_copytomask.py
modules/python/test/test_copytomask.py
+37
-0
No files found.
modules/python/test/test_copytomask.py
0 → 100644
View file @
936523ae
#!/usr/bin/env python
'''
Test for copyto with mask
'''
# Python 2/3 compatibility
from
__future__
import
print_function
import
cv2
as
cv
import
numpy
as
np
import
sys
from
tests_common
import
NewOpenCVTests
class
copytomask_test
(
NewOpenCVTests
):
def
test_copytomask
(
self
):
img
=
self
.
get_sample
(
'python/images/baboon.png'
,
cv
.
IMREAD_COLOR
)
eps
=
0.
#Create mask using inRange
valeurBGRinf
=
np
.
array
([
0
,
0
,
100
])
valeurBGRSup
=
np
.
array
([
70
,
70
,
255
])
maskRed
=
cv
.
inRange
(
img
,
valeurBGRinf
,
valeurBGRSup
)
#New binding
dstcv
=
cv
.
copyTo
(
img
,
maskRed
)
#using numpy
mask2
=
maskRed
.
astype
(
bool
)
_
,
mask_b
=
np
.
broadcast_arrays
(
img
,
mask2
[
...
,
None
])
dstnp
=
np
.
ma
.
masked_array
(
img
,
np
.
logical_not
(
mask_b
))
dstnp
=
np
.
ma
.
filled
(
dstnp
,[
0
])
self
.
assertEqual
(
cv
.
norm
(
dstnp
,
dstcv
),
eps
)
if
__name__
==
'__main__'
:
NewOpenCVTests
.
bootstrap
()
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