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
ce90ade0
Commit
ce90ade0
authored
Apr 27, 2015
by
Will Brennan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finalised layout of SpeedySuperPixels.py
parent
2f25672f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
8 deletions
+20
-8
SpeedySuperPixels.py
SpeedySuperPixels.py
+20
-8
No files found.
SpeedySuperPixels.py
View file @
ce90ade0
...
@@ -21,22 +21,34 @@ class SuperContour(object):
...
@@ -21,22 +21,34 @@ class SuperContour(object):
def
grid_contours
(
self
,
frame
,
contours
,
heir
):
def
grid_contours
(
self
,
frame
,
contours
,
heir
):
result_cont
,
result_heir
,
result_rois
=
[],
[],
[]
result_cont
,
result_heir
,
result_rois
=
[],
[],
[]
logger
.
debug
(
'segmenting contours with grid'
)
# todo: mix grid with contours to form super pixels!
# 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
:
for
contour
in
contours
:
msk
=
numpy
.
zeros
(
frame
.
shape
,
dtype
=
frame
.
dtype
)
msk
=
numpy
.
zeros
(
frame
.
shape
,
dtype
=
frame
.
dtype
)
cv2
.
drawContours
(
msk
,
[
contour
],
-
1
,
255
,
-
1
)
cv2
.
drawContours
(
msk
,
[
contour
],
-
1
,
255
,
-
1
)
bbox
=
cv2
.
boundingRect
(
contour
)
w0
,
h0
=
bbox
[
0
]
//
self
.
width
,
bbox
[
1
]
//
self
.
width
n_w
=
max
(
1
,
((
bbox
[
0
]
+
bbox
[
2
])
//
self
.
width
)
-
w0
)
n_h
=
max
(
1
,
((
bbox
[
1
]
+
bbox
[
3
])
//
self
.
width
)
-
h0
)
for
i
in
range
(
n_w
):
for
j
in
range
(
n_h
):
grid_msk
=
numpy
.
zeros
(
frame
.
shape
,
dtype
=
frame
.
dtype
)
grid_box
=
numpy
.
array
([[],
[],
[],
[]],
dtype
=
numpy
.
uint8
)
cv2
.
drawContours
(
grid_msk
,
[
grid_box
],
-
1
,
255
,
-
1
)
grid_msk
=
cv2
.
bitwise_and
(
grid_msk
,
msk
)
result_cont
.
append
(
grid_msk
)
# todo: work out stats of new contour!
# todo: mix grid with contours to form super pixels!
contours
=
result_cont
logger
.
debug
(
'checking and removing overlap...'
)
msk_all
=
numpy
.
zeros
(
frame
.
shape
[:
2
],
dtype
=
frame
.
dtype
)
for
msk
in
contours
:
msk
=
cv2
.
bitwise_and
(
msk
,
cv2
.
bitwise_not
(
msk_all
))
msk
=
cv2
.
bitwise_and
(
msk
,
cv2
.
bitwise_not
(
msk_all
))
if
msk
.
sum
()
!=
0
:
if
msk
.
sum
()
!=
0
:
result_cont
.
append
(
msk
)
result_cont
.
append
(
msk
)
msk_all
=
numpy
.
min
(
255
,
cv2
.
add
(
msk_all
,
msk
))
msk_all
=
numpy
.
min
(
255
,
cv2
.
add
(
msk_all
,
msk
))
logger
.
debug
(
'grid contours complete'
)
logger
.
debug
(
'grid contours complete'
)
result_heir
=
heir
contours
=
result_cont
return
result_cont
,
result_heir
,
result_
rois
return
contours
,
heir
,
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
)
...
...
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