Finishes first version of sphinx documentation

This commit is contained in:
2012-05-31 14:00:54 +02:00
parent 332702b511
commit 65c46e325a
13 changed files with 798 additions and 109 deletions

2
.gitignore vendored
View File

@@ -4,4 +4,4 @@ build
dist
MANIFEST
packaging
doc
doc/build

153
doc/Makefile Normal file
View File

@@ -0,0 +1,153 @@
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
-rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/facemovie.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/facemovie.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/facemovie"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/facemovie"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."

190
doc/make.bat Normal file
View File

@@ -0,0 +1,190 @@
@ECHO OFF
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set BUILDDIR=build
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source
set I18NSPHINXOPTS=%SPHINXOPTS% source
if NOT "%PAPER%" == "" (
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
)
if "%1" == "" goto help
if "%1" == "help" (
:help
echo.Please use `make ^<target^>` where ^<target^> is one of
echo. html to make standalone HTML files
echo. dirhtml to make HTML files named index.html in directories
echo. singlehtml to make a single large HTML file
echo. pickle to make pickle files
echo. json to make JSON files
echo. htmlhelp to make HTML files and a HTML help project
echo. qthelp to make HTML files and a qthelp project
echo. devhelp to make HTML files and a Devhelp project
echo. epub to make an epub
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
echo. text to make text files
echo. man to make manual pages
echo. texinfo to make Texinfo files
echo. gettext to make PO message catalogs
echo. changes to make an overview over all changed/added/deprecated items
echo. linkcheck to check all external links for integrity
echo. doctest to run all doctests embedded in the documentation if enabled
goto end
)
if "%1" == "clean" (
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
del /q /s %BUILDDIR%\*
goto end
)
if "%1" == "html" (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
goto end
)
if "%1" == "dirhtml" (
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
goto end
)
if "%1" == "singlehtml" (
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
goto end
)
if "%1" == "pickle" (
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the pickle files.
goto end
)
if "%1" == "json" (
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the JSON files.
goto end
)
if "%1" == "htmlhelp" (
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run HTML Help Workshop with the ^
.hhp project file in %BUILDDIR%/htmlhelp.
goto end
)
if "%1" == "qthelp" (
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\facemovie.qhcp
echo.To view the help file:
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\facemovie.ghc
goto end
)
if "%1" == "devhelp" (
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished.
goto end
)
if "%1" == "epub" (
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The epub file is in %BUILDDIR%/epub.
goto end
)
if "%1" == "latex" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
if errorlevel 1 exit /b 1
echo.
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "text" (
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The text files are in %BUILDDIR%/text.
goto end
)
if "%1" == "man" (
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The manual pages are in %BUILDDIR%/man.
goto end
)
if "%1" == "texinfo" (
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
goto end
)
if "%1" == "gettext" (
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
goto end
)
if "%1" == "changes" (
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
if errorlevel 1 exit /b 1
echo.
echo.The overview file is in %BUILDDIR%/changes.
goto end
)
if "%1" == "linkcheck" (
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
if errorlevel 1 exit /b 1
echo.
echo.Link check complete; look for any errors in the above output ^
or in %BUILDDIR%/linkcheck/output.txt.
goto end
)
if "%1" == "doctest" (
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
if errorlevel 1 exit /b 1
echo.
echo.Testing of doctests in the sources finished, look at the ^
results in %BUILDDIR%/doctest/output.txt.
goto end
)
:end

247
doc/source/conf.py Normal file
View File

@@ -0,0 +1,247 @@
# -*- coding: utf-8 -*-
#
# facemovie documentation build configuration file, created by
# sphinx-quickstart on Thu May 31 11:08:43 2012.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('../..'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'facemovie'
copyright = u'2012, Julien Lengrand-Lambert'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.8'
# The full version, including alpha/beta/rc tags.
release = '0.8'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'facemoviedoc'
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'facemovie.tex', u'facemovie Documentation',
u'Julien Lengrand-Lambert', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'facemovie', u'facemovie Documentation',
[u'Julien Lengrand-Lambert'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'facemovie', u'facemovie Documentation',
u'Julien Lengrand-Lambert', 'facemovie', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'http://docs.python.org/': None}

74
doc/source/index.rst Normal file
View File

@@ -0,0 +1,74 @@
.. facemovie documentation master file, created by
sphinx-quickstart on Thu May 31 11:08:43 2012.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Facemovie's documentation!
=====================================
.. toctree::
:maxdepth: 2
.. automodule:: facemovie
FaceMovie
=========
.. automodule:: facemovie.Facemovie
:members:
Facemoviefier
=============
.. automodule:: facemovie.Facemoviefier
:members:
Eye
===
.. automodule:: facemovie.Eye
:members:
Face
====
.. automodule:: facemovie.Face
:members:
Guy
===
.. automodule:: facemovie.Guy
:members:
training_types
==============
.. automodule:: facemovie.training_types
:members:
FaceParams
==========
.. automodule:: facemovie.FaceParams
:members:
Libs
====
.. automodule:: facemovie.lib
:members:
Libs -- exif
============
.. automodule:: facemovie.lib.exif
:members:
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

View File

@@ -18,12 +18,17 @@ class Eye(object):
"""
def __init__(self):
"""A facemovie redefinition of the human eye
Args:
x_pos (int) : x position of the eye in the image (in pixels)
y_pos (int) : y position of the eye in the image (in pixels)
x_size (int) : x size of the blob (in pixels)
y_size (int) : y size of the blob (in pixels)
conf (float) : confidence indice, indicating the probability of the target to actually be an eye
:param x_pos: x position of the eye in the image (in pixels)
:type x_pos: int
:param y_pos: y position of the eye in the image (in pixels)
:type y_pos: int
:param x_size: x size of the blob (in pixels)
:type x_size: int
:param y_size: y size of the blob (in pixels)
:type y_size: int
:param conf: confidence indice, indicating the probability of the target to actually be an eye
:type conf: float
"""
x_pos = None # x position of the eye in the image
y_pos = None # y position of the eye in the image

View File

@@ -19,11 +19,16 @@ class Face(object):
def __init__(self):
"""A facemovie redifinition of the human face.
x_pos (int) : x position of the face in the image (in pixels)
y_pos (int) : y position of the face in the image (in pixels)
x_size (int) : x size of the blob (in pixels)
y_size (int) : y size of the blob (in pixels)
conf (float) : confidence indice, indicating the probability of the target to actually be an face
:param x_pos: x position of the face in the image (in pixels)
:type x_pos: int
:param y_pos: y position of the face in the image (in pixels)
:type y_pos: int
:param x_size: x size of the blob (in pixels)
:type x_size: int
:param y_size: y size of the blob (in pixels)
:type y_size: int
:param conf: confidence indice, indicating the probability of the target to actually be an face
:type conf: float
"""
x_center = None # x position of the face in the image
y_center = None # y position of the face in the image

View File

@@ -21,14 +21,19 @@ class FaceParams(object):
some of them shall never be used. Perhaps would it be good to lower the dict size, or hide some of them
postpend .xml
Args:
xml_folder (string) : the location where xml files are located
training_type (string) : the type of profile we are going to use
KArgs:
i_scale (float) : Image scaling chosen for classification
h_scale (float) : Haar scaling chosen for classification
h_flags (int) : the chosen number of haar flags
mn (int) : the Minimum number of neighbors to be defined
:param xml_folder: the location where xml files are located
:type xml_folder: string
:param training_type: the type of profile we are going to use
:type training_type: string
:param i_scale: Image scaling chosen for classification (2)
:type i_scale: float
:param h_scale: Haar scaling chosen for classification (1.2)
:type h_scale: float
:param h_flags: the chosen number of haar flags (0)
:type h_flags: int
:param mn: the Minimum number of neighbors to be defined (2)
:type mn: int
"""
cascade_name = training_types.simple_set[training_type] + ".xml"

View File

@@ -30,13 +30,12 @@ class FaceMovie(object):
Initializes all parameters of the application. Input and output folders
are defined, together with the classifier profile.
Args:
in_folder (string) : the location where input files will be
searched
out_folder (string) : the location where the outputs will be
saved
face_param (string) : the location of the profile file used
to train the classifier
:param in_folder: the location where input files will be searched
:type in_folder: string
:param out_folder: the location where the outputs will be saved
:type out_folder: string
:param face_param: the location of the profile file used to train the classifier
:type face_param: string
"""
self.source= in_folder # Source folder for pictures
self.out = out_folder # Folder to save outputs
@@ -71,9 +70,10 @@ class FaceMovie(object):
"""
Sets the cropping dimension in case they have been provided by the end user
Args:
crop_x (int) : dimension of the desired cropping in x (in number of face size)
crop_y (int) : dimension of the desired cropping in y (in number of face size)
:param crop_x: dimension of the desired cropping in x (in number of face size)
:type crop_x: int
:param crop_y: dimension of the desired cropping in y (in number of face size)
:type crop_x: int
"""
self.cropdims = [crop_x, crop_y]
@@ -82,7 +82,6 @@ class FaceMovie(object):
Aims at populating the guys list, using the source folder as an input.
Guys list shall be sorted chronologically.
In case no valid date is found, it is set to ''.
"""
try:
os.path.exists(self.source)
@@ -140,8 +139,8 @@ class FaceMovie(object):
A reference is given in input. The idea is to get all images to have the
same size in Guy.
KArgs:
reference (int) : the reference size of the face that we want to have
:param reference: the reference size of the face that we want to have (0)
:type reference: int
"""
# FIXME: May be enhanced by choosing a more educated reference
if reference == 0:
@@ -157,7 +156,7 @@ class FaceMovie(object):
Returns the mean size of all faces in input
Used to correctly crop images
**Designed for internal use only**
.. note:: Designed for internal use only
"""
tot_x = 0
tot_y = 0
@@ -253,10 +252,9 @@ class FaceMovie(object):
"""
If needed, crops the image to avoid having black borders.
Args:
image (IplImage) : the image to be cropped
:param image: the image to be cropped
:type image: IplImage
"""
# TODO : implement
width = self.width#[0, 0]
height = self.height#[0, 0]
out_im = cv.CreateImage((width[0] + width[1], height[0] + height[1]),cv.IPL_DEPTH_8U, image.nChannels)
@@ -280,8 +278,8 @@ class FaceMovie(object):
Show all faces that have been found for the guys.
The time for which each image will be displayed can be chosen.
KArgs :
mytime (int) : time for which the image should be displayed (in ms)
:param mytime: time for which the image should be displayed (in ms) (1000)
:type mytime: int
"""
for a_guy in self.guys:
if a_guy.has_face():
@@ -297,11 +295,11 @@ class FaceMovie(object):
"""
Save all faces into out_folder, in the given image format
Args:
out_folder (string) : the location where to save the output image.
:param out_folder: the location where to save the output image.
:type out_folder: string
KArgs :
mytime (int) : time for which the image should be displayed (in ms)
:param im_format: Format in which the image should be saved ("png")
:type im_format: string
"""
for a_guy in self.guys:
if a_guy.has_face():
@@ -318,11 +316,11 @@ class FaceMovie(object):
Creates a movie with all faces found in the inputs.
Guy is skipped if no face is found.
Args:
out_folder (string) : the location where to save the output image.
:param out_folder: the location where to save the output image.
:type out_folder: string
KArgs :
fps (int) : the number of frames per second to be displayed in final video
:param fps: the number of frames per second to be displayed in final video (3)
:type fps: int
"""
filename = os.path.join(out_folder, "output.avi")
fourcc = cv.CV_FOURCC('C', 'V', 'I', 'D')
@@ -354,7 +352,9 @@ class FaceMovie(object):
def number_guys(self):
"""
Simply returns the number of guys in the current to-be movie
__Designed for interface use only__
.. note::
Designed for interface use only
"""
return len(self.guys)
@@ -363,13 +363,18 @@ class FaceMovie(object):
Displays the output image, for time ms.
Setting time to 0 causes the image to remains open.
Window name slightly changed to match output
Args:
im (IplImage) : the image to be saved, formatted as an OpenCV Image
name (string) : the name of the image to be saved
KArgs :
time (int) : time for which the image should be displayed (in ms)
im_x (int) : output size of the displayed image (in pixels)
im_y (int) : output size of the displayed image (in pixels)
:param im: the image to be saved, formatted as an OpenCV Image
:type im: IplImage
:param name: the name of the image to be saved
:type name: string
:param time: time for which the image should be displayed (in ms) (1000)
:type time: int
:param im_x: output size of the displayed image (in pixels) (640)
:type im_x: int
:param im_y: output size of the displayed image (in pixels) (480)
:type im_y: int
"""
win_name = name + " - out"
cv.NamedWindow(win_name, cv.CV_WINDOW_NORMAL)
@@ -382,11 +387,14 @@ class FaceMovie(object):
"""
Saves output image to the given format (given in extension)
Args:
im (IplImage) : the image to be saved, formatted as an OpenCV Image
name (string) : the name of the image to be saved
out_folder (string) : the location where to save the image
ext (string) : Format in which the image should be saved
:param im: the image to be saved, formatted as an OpenCV Image
:type im: IplImage
:param name: the name of the image to be saved
:type name: string
:param out_folder: the location where to save the image
:type out_folder: string
:param ext: Format in which the image should be saved ("png")
:type ext: string
"""
file_name = name + "." + ext
out_name = os.path.join(out_folder, file_name)

View File

@@ -31,6 +31,8 @@ class Facemoviefier():
def init_facemovie(self):
"""
Inits the Facemovie parameters, so that it can be run efficiently
..note ::
FIXME : par folder should be known (contained somewhere in the installation)
"""
par_fo = os.path.join(self.args['root'], "haarcascades")

View File

@@ -19,10 +19,15 @@ class Guy(object):
"""
def __init__(self, image, image_id, date):
"""All data linked to an input image
Args:
image (IplImage) : the input image, formatted as an OpenCV Image
image_id (string) : the name of the image, formatted as a string
date (datetime) : the date where the input image was taken.
:param image: the input image, formatted as an OpenCV Image
:type image: IplImage
:param image_id: the name of the image, formatted as a string
:type image_id: string
:param date: the date where the input image was taken.
:type date: datetime
"""
self.in_x = None
self.in_y = None
@@ -50,13 +55,11 @@ class Guy(object):
"""This function takes a date as a string, and returns a date object.
Used afterwards to sort images chronologically
Args:
date (str): The date where the image was taken
:param date: The date where the image was taken
:type date: string
Returns:
datetime. Returns a date object according to time library.
In case of error, set the date to be the current time.
:returns: datetime -- Returns a date object according to time library.
:raises: In case of error, set the date to be the current time.
"""
try:
my_date = time.strptime(date, "%Y:%m:%d %H:%M:%S")
@@ -72,8 +75,8 @@ class Guy(object):
Set several Guy information, such as the face size, or the virtual center of the image
Args:
face_params (str): The type of file to be used to train the classifier.
:param face_params: The type of file to be used to train the classifier.
:type face_params: string
Once Faces have been found, they are listed and ordered
"""
@@ -123,12 +126,10 @@ class Guy(object):
"""
Sorts faces by number of neighbours found, most probable one first
Args:
face_params (str): The type of file to be used to train the classifier.
:param face_params: The type of file to be used to train the classifier.
:type face_params: string
Returns:
A list of faces, ordered by probability
If no faces is found, returns a void list.
:returns: A list of faces, ordered by probability. If no faces is found, returns a void list.
"""
if self.has_face() : # needed ?
self.faces.sort(key= lambda prob : prob[1], reverse=True)
@@ -140,7 +141,7 @@ class Guy(object):
Using sorted faces, defines the new center of interest of the output image
Updates the center of the image, using the most probable face as reference.
Íf no face was found, the center is not updated.
If no face was found, the center is not updated.
"""
if self.has_face():
((x, y, w, h), n) = self.faces[0]
@@ -153,8 +154,8 @@ class Guy(object):
This method aloows faces to always keep the same size during all the video.
Changes the center of the image and adds a new resized image.
Args:
reference (int): The refence size of the face (in pixels). Defined as the first face size for now
:param reference: The refence size of the face (in pixels). Defined as the first face size for now
:type reference: int
"""
self.normalize = 1
@@ -178,14 +179,17 @@ class Guy(object):
If eq_ratio is set to something different than one, input image is scaled
so that face/size = eq_ratio
Args:
x_size (int): The size of the ouput image in x (in pixels)
y_size (int): The size of the ouput image in y (in pixels)
x_point (int): The center of the output image, where the Guy image has to fit in (in pixels)
y_point (int): The center of the output image, where the Guy image has to fit in (in pixels)
:param x_size: The size of the ouput image in x (in pixels)
:type x_size: int
:param y_size: The size of the ouput image in y (in pixels)
:type y_size: int
:param x_point: The center of the output image, where the Guy image has to fit in (in pixels)
:type x_point: int
:param y_point: The center of the output image, where the Guy image has to fit in (in pixels)
:type y_point: int
:returns: IplImage -- The ouput image, centered to fit with all other images
Returns:
The ouput image, centered to fit with all other images
"""
out_im = cv.CreateImage((x_size, y_size),cv.IPL_DEPTH_8U, self.in_channels)
cv.Zero(out_im)
@@ -206,10 +210,12 @@ class Guy(object):
def create_debug_output(self):
"""
**DEPRECATED**
Creates output image
If debug is set to true, output image is the input image with a red
box around the most probable face.
.. note::
DEPRECATED
"""
out_im = cv.CreateImage((self.in_x, self.in_y),cv.IPL_DEPTH_8U, self.in_channels)
cv.Zero(out_im) # put everything to 0
@@ -242,10 +248,12 @@ class Guy(object):
Displays the input image, for time ms.
Setting time to 0 causes the image to remains open.
Args:
time (int): The time for which image stays diaplyed (in ms). 0 causes the frams to remain open
im_x (int): The output of the display frame in x (in pixels)
im_y (int): The output of the display frame in y (in pixels)
:param time: The time for which image stays diaplyed (in ms). 0 causes the frams to remain open
:type time: int
:param im_x: The output of the display frame in x (in pixels)
:type im_x: int
:param im_y: The output of the display frame in y (in pixels)
:type im_y: int
"""
cv.NamedWindow(self.name, cv.CV_WINDOW_NORMAL)
cv.ResizeWindow(self.name, im_x, im_y)
@@ -257,8 +265,7 @@ class Guy(object):
"""
Returns the number of faces found for this guy
Returns:
int The number of faces found for the input image
:returns: int -- The number of faces found for the input image
"""
return len(self.faces)
@@ -266,8 +273,7 @@ class Guy(object):
"""
Returns True of False whether images have been found for the current image or not.
Returns:
True if at least one face has been found
:returns: boolean -- True if at least one face has been found
"""
return (len(self.faces) > 0)

View File

@@ -5,3 +5,4 @@
.. moduleauthor:: Julien Lengrand-Lambert <jlengrand@gmail.com>
"""
import Eye

View File

@@ -1,7 +0,0 @@
Documentation of the FaceMovie project
**************************************
.. automodule:: facemovie
.. automodule:: facemovie.useful_1
:members: