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
8b1f0e65
Commit
8b1f0e65
authored
Apr 05, 2015
by
WillBrennan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ycrcb masking
parent
b7f64d42
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
main.py
main.py
+8
-11
No files found.
main.py
View file @
8b1f0e65
...
@@ -59,16 +59,16 @@ class SkinDetector(object):
...
@@ -59,16 +59,16 @@ class SkinDetector(object):
scripts
.
display
(
'mask_rgb'
,
msk_rgb
)
scripts
.
display
(
'mask_rgb'
,
msk_rgb
)
self
.
add_mask
(
msk_rgb
)
self
.
add_mask
(
msk_rgb
)
def
get_mask_y
uv
(
self
,
img
):
def
get_mask_y
crcb
(
self
,
img
):
self
.
assert_image
(
img
)
self
.
assert_image
(
img
)
lower_thresh
=
numpy
.
array
([
65
,
85
,
85
],
dtype
=
numpy
.
uint8
)
lower_thresh
=
numpy
.
array
([
90
,
100
,
130
],
dtype
=
numpy
.
uint8
)
upper_thresh
=
numpy
.
array
([
170
,
140
,
16
0
],
dtype
=
numpy
.
uint8
)
upper_thresh
=
numpy
.
array
([
230
,
120
,
18
0
],
dtype
=
numpy
.
uint8
)
img_y
uv
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_RGB2YUV
)
img_y
crcb
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_RGB2YCR_CB
)
msk_y
uv
=
cv2
.
inRange
(
img_yuv
,
lower_thresh
,
upper_thresh
)
msk_y
crcb
=
cv2
.
inRange
(
img_ycrcb
,
lower_thresh
,
upper_thresh
)
if
self
.
args
.
debug
:
if
self
.
args
.
debug
:
scripts
.
display
(
'input'
,
img
)
scripts
.
display
(
'input'
,
img
)
scripts
.
display
(
'mask_y
uv'
,
msk_yuv
)
scripts
.
display
(
'mask_y
crcb'
,
msk_ycrcb
)
self
.
add_mask
(
msk_y
uv
)
self
.
add_mask
(
msk_y
crcb
)
@staticmethod
@staticmethod
def
closing
(
msk
):
def
closing
(
msk
):
...
@@ -91,14 +91,12 @@ class SkinDetector(object):
...
@@ -91,14 +91,12 @@ class SkinDetector(object):
self
.
mask
=
numpy
.
zeros
(
img
.
shape
[:
2
],
dtype
=
numpy
.
uint8
)
self
.
mask
=
numpy
.
zeros
(
img
.
shape
[:
2
],
dtype
=
numpy
.
uint8
)
self
.
get_mask_hsv
(
img
)
self
.
get_mask_hsv
(
img
)
self
.
get_mask_rgb
(
img
)
self
.
get_mask_rgb
(
img
)
self
.
get_mask_y
uv
(
img
)
self
.
get_mask_y
crcb
(
img
)
logger
.
debug
(
'Thresholding sum of masks'
)
logger
.
debug
(
'Thresholding sum of masks'
)
self
.
threshold
(
self
.
args
.
thresh
)
self
.
threshold
(
self
.
args
.
thresh
)
if
self
.
args
.
debug
:
if
self
.
args
.
debug
:
cv2
.
destroyAllWindows
()
cv2
.
imshow
(
'skin_mask'
,
self
.
mask
)
cv2
.
imshow
(
'skin_mask'
,
self
.
mask
)
cv2
.
imshow
(
'input_img'
,
img
)
cv2
.
imshow
(
'input_img'
,
img
)
cv2
.
waitKey
(
0
)
dt
=
round
(
time
.
time
()
-
dt
,
2
)
dt
=
round
(
time
.
time
()
-
dt
,
2
)
hz
=
round
(
1
/
dt
,
2
)
hz
=
round
(
1
/
dt
,
2
)
logger
.
debug
(
'Conducted processing in {0}s ({1}Hz)'
.
format
(
dt
,
hz
))
logger
.
debug
(
'Conducted processing in {0}s ({1}Hz)'
.
format
(
dt
,
hz
))
...
@@ -149,7 +147,6 @@ if __name__ == '__main__':
...
@@ -149,7 +147,6 @@ if __name__ == '__main__':
img_col
=
cv2
.
imread
(
image_path
,
1
)
img_col
=
cv2
.
imread
(
image_path
,
1
)
img_msk
=
process
(
img_col
,
args
=
args
)
img_msk
=
process
(
img_col
,
args
=
args
)
if
not
args
.
display
:
if
not
args
.
display
:
cv2
.
destroyAllWindows
()
cv2
.
imshow
(
'img_col'
,
img_col
)
cv2
.
imshow
(
'img_col'
,
img_col
)
cv2
.
imshow
(
'img_msk'
,
img_msk
)
cv2
.
imshow
(
'img_msk'
,
img_msk
)
cv2
.
imshow
(
'img_skn'
,
cv2
.
bitwise_and
(
img_col
,
img_col
,
mask
=
img_msk
))
cv2
.
imshow
(
'img_skn'
,
cv2
.
bitwise_and
(
img_col
,
img_col
,
mask
=
img_msk
))
...
...
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