Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
skin_detector
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
人工智能
skin_detector
Commits
4658a089
Commit
4658a089
authored
Apr 27, 2015
by
Will Brennan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removing sections of contours that overlap!
parent
9e147c58
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
SpeedySuperPixels.py
SpeedySuperPixels.py
+16
-3
No files found.
SpeedySuperPixels.py
View file @
4658a089
...
@@ -19,19 +19,31 @@ class SuperContour(object):
...
@@ -19,19 +19,31 @@ class SuperContour(object):
def
__init__
(
self
,
width
=
32
):
def
__init__
(
self
,
width
=
32
):
self
.
width
=
width
self
.
width
=
width
def
grid_contours
(
self
,
contours
,
heir
):
def
grid_contours
(
self
,
frame
,
contours
,
heir
):
result_cont
,
result_heir
,
result_rois
=
[],
[],
[]
result_cont
,
result_heir
,
result_rois
=
[],
[],
[]
# todo: mix grid with contours to form super pixels!
# todo: mix grid with contours to form super pixels!
# todo: remove any regions of overlap!
# todo: remove any regions of overlap!
logger
.
debug
(
'checking and removing overlap...'
)
msk_all
=
numpy
.
zeros
(
frame
.
shape
[:
2
],
dtype
=
frame
.
dtype
)
for
contour
in
contours
:
msk
=
numpy
.
zeros
(
frame
.
shape
,
dtype
=
frame
.
dtype
)
cv2
.
drawContours
(
msk
,
[
contour
],
-
1
,
255
,
-
1
)
msk
=
cv2
.
bitwise_and
(
msk
,
cv2
.
bitwise_not
(
msk_all
))
if
msk
.
sum
()
!=
0
:
result_cont
.
append
(
msk
)
msk_all
=
numpy
.
min
(
255
,
cv2
.
add
(
msk_all
,
msk
))
logger
.
debug
(
'grid contours complete'
)
result_heir
=
heir
result_heir
=
heir
return
result_cont
,
result_heir
,
result_rois
return
result_cont
,
result_heir
,
result_rois
def
process
(
self
,
frame
):
def
process
(
self
,
frame
):
frame_gry
=
cv2
.
cvtColor
(
frame
,
cv2
.
COLOR_BGR2GRAY
)
frame_gry
=
cv2
.
cvtColor
(
frame
,
cv2
.
COLOR_BGR2GRAY
)
contours
,
heir
=
cv2
.
findContours
(
frame_gry
,
cv2
.
RETR_TREE
,
cv2
.
CHAIN_APPROX_SIMPLE
)
contours
,
heir
=
cv2
.
findContours
(
frame_gry
,
cv2
.
RETR_TREE
,
cv2
.
CHAIN_APPROX_SIMPLE
)
contours
,
heir
,
rois
=
self
.
grid_contours
(
contours
,
heir
)
contours
,
heir
,
rois
=
self
.
grid_contours
(
frame
,
contours
,
heir
)
for
i
in
range
(
len
(
contours
)):
for
i
in
range
(
len
(
contours
)):
roi
,
contour
=
rois
[
i
],
contours
[
i
]
roi
,
contour
=
rois
[
i
],
contours
[
i
]
mask
=
numpy
.
zeros
(
frame
.
shape
,
dtype
=
frame
.
dtype
)
mask
=
numpy
.
zeros
(
frame
.
shape
[:
2
]
,
dtype
=
frame
.
dtype
)
cv2
.
drawContours
(
mask
,
[
contour
],
-
1
,
255
,
-
1
)
cv2
.
drawContours
(
mask
,
[
contour
],
-
1
,
255
,
-
1
)
yield
roi
,
contour
yield
roi
,
contour
\ No newline at end of file
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