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
1fff7085
Commit
1fff7085
authored
Apr 27, 2015
by
Will Brennan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new superpixel method!
parent
c32c74cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
SpeedySuperPixels.py
SpeedySuperPixels.py
+38
-0
No files found.
SpeedySuperPixels.py
0 → 100644
View file @
1fff7085
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__
=
'Will Brennan'
# Built-in Modules
import
logging
# Standard Modules
import
cv2
import
numpy
# Custom Modules
import
mean_color
logger
=
logging
.
getLogger
(
'main'
)
class
SuperContour
(
object
):
def
__init__
(
self
,
width
=
32
):
self
.
width
=
width
def
grid_contours
(
self
,
contours
,
heir
):
result_cont
,
result_heir
,
result_rois
=
[],
[],
[]
# todo: mix grid with contours to form super pixels!
# todo: remove any regions of overlap!
result_heir
=
heir
return
result_cont
,
result_heir
,
result_rois
def
process
(
self
,
frame
):
frame_gry
=
cv2
.
cvtColor
(
frame
,
cv2
.
COLOR_BGR2GRAY
)
contours
,
heir
=
cv2
.
findContours
(
frame_gry
,
cv2
.
RETR_TREE
,
cv2
.
CHAIN_APPROX_SIMPLE
)
contours
,
heir
,
rois
=
self
.
grid_contours
(
contours
,
heir
)
for
i
in
range
(
len
(
contours
)):
roi
,
contour
=
rois
[
i
],
contours
[
i
]
mask
=
numpy
.
zeros
(
frame
.
shape
,
dtype
=
frame
.
dtype
)
cv2
.
drawContours
(
mask
,
[
contour
],
-
1
,
255
,
-
1
)
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