Commit ddd301b5 authored by Guillaume HEUSCH's avatar Guillaume HEUSCH
Browse files

[all] modified buildout and setup, add a demo script and data

parent 66cb2d6d
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Andre Anjos <andre.dos.anjos@gmail.com>
# Wed 15 Aug 09:59:33 2012
#
# Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Test Units
"""
def test_version():
from .script import version
assert version.main() == 0
import sys
import numpy
import bob.io.base
import bob.io.image
import bob.ip.facedetect
from ..skin_color_filter import SkinColorFilter
def show_image(image, title=''):
"""
This function just shows an image with a title (if provided)
:param image: the image to show
:param title: the title of the plot
"""
from matplotlib import pyplot
# color image
if len(image.shape) == 3:
im = image.transpose(1,2,0)
pyplot.figure()
pyplot.imshow(im)
pyplot.title(title)
pyplot.show()
# grayscale
else:
pyplot.figure()
pyplot.imshow(image.astype(numpy.uint8), cmap='gray')
pyplot.title(title)
pyplot.show()
def main(user_input=None):
image = bob.io.base.load('./bob/ip/skincolorfilter/data/001.png')
show_image(image, 'original image')
detection = bob.ip.facedetect.detect_single_face(image)
if detection is not None:
bb, quality = detection
face = image[:, bb.top:bb.bottom, bb.left:bb.right]
show_image(face, 'cropped face')
skin_filter = SkinColorFilter()
skin_filter.get_gaussian_parameters(face)
skin_mask = skin_filter.get_skin_pixels(image, 0.5)
display_skin = numpy.copy(image)
display_skin[:, numpy.logical_not(skin_mask)] = 0
show_image(display_skin, 'skin pixels')
else:
print "No face detected in the image"
sys.exit()
......@@ -7,14 +7,14 @@ eggs = bob.ip.skincolorfilter
extensions = bob.buildout
mr.developer
auto-checkout = *
develop = src/bob.extension
develop = .
src/bob.extension
src/bob.blitz
src/bob.core
src/bob.io.base
src/bob.io.image
src/bob.ip.base
src/bob.ip.facedetect
.
; options for bob.buildout
debug = true
......
......@@ -64,7 +64,8 @@ setup(
# This line is required for any distutils based packaging.
# It will find all package-data inside the 'bob' directory.
packages = find_packages('bob'),
#packages = find_packages('bob'),
packages = find_packages(),
include_package_data = True,
# This line defines which packages should be installed when you "install"
......@@ -92,7 +93,8 @@ setup(
# scripts should be declared using this entry:
'console_scripts' : [
'test.py = bob.example.project.script.test:main',
'test.py = bob.ip.skincolorfilter.script.test:main',
'test_skin_color_filter.py = bob.ip.skincolorfilter.script.test_skin_color_filter:main',
],
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment