Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.ip.flandmark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.ip.flandmark
Commits
bdf725d2
Commit
bdf725d2
authored
10 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
Fix doctest circumventing ifconfig sphinx bug
parent
f830bb70
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/conf.py
+2
-10
2 additions, 10 deletions
doc/conf.py
doc/guide.rst
+15
-38
15 additions, 38 deletions
doc/guide.rst
xbob/ip/flandmark/test.py
+1
-1
1 addition, 1 deletion
xbob/ip/flandmark/test.py
with
18 additions
and
49 deletions
doc/conf.py
+
2
−
10
View file @
bdf725d2
...
...
@@ -29,8 +29,8 @@ extensions = [
'
sphinx.ext.ifconfig
'
,
'
sphinx.ext.autodoc
'
,
'
sphinx.ext.autosummary
'
,
'
sphinx.ext.doctest
'
,
'
sphinx.ext.intersphinx
'
,
'
sphinx.ext.doctest
'
,
'
matplotlib.sphinxext.plot_directive
'
,
]
...
...
@@ -280,13 +280,5 @@ intersphinx_mapping = {
numpy_manual
:
None
,
}
try
:
import
cv2
has_opencv
=
True
print
(
"
OpenCV python module is installed - running full doctest suite
"
)
except
ImportError
:
has_opencv
=
False
print
(
"
OpenCV python module is *NOT* installed - skipping parts
"
)
def
setup
(
app
):
app
.
add_config_value
(
'
has_opencv
'
,
has_opencv
,
'
html
'
)
pass
This diff is collapsed.
Click to expand it.
doc/guide.rst
+
15
−
38
View file @
bdf725d2
...
...
@@ -9,10 +9,6 @@
from pkg_resources import resource_filename
return resource_filename('xbob.ip.flandmark', join('data', f))
LENA = get_file('lena.jpg')
MULTI = get_file('multi.jpg')
CASCADE = get_file('haarcascade_frontalface_alt.xml')
=============
Users Guide
=============
...
...
@@ -67,52 +63,33 @@ detector. OpenCV_, if compiled with Python support, provides an easy to use
frontal face detector. The code below shall detect most frontal faces in a
provided (gray-scaled) image:
.. ifconfig:: not has_opencv
.. warning::
OpenCV for the current installation in which this manual was generated was
not compiled with Python support. The code below cannot be tested and it
may work differently than what is announced. In doubt, consult the OpenCV
guide.
.. code-block:: python
>>> from cv2 import CascadeClassifier, cv
>>> from xbob.io import load
>>> from xbob.ip.color import rgb_to_gray
>>> cc = CascadeClassifier(CASCADE) # uses 'haarcascade_frontalface_alt.xml'
>>> lena_gray = rgb_to_gray(load(LENA) # uses 'lena.jpg'
>>> face_bbxs = cc.detectMultiScale(lena_gray, 1.3, 4, 0, (20, 20))
>>> print face_bbxs
[[...]]
.. ifconfig:: has_opencv
.. doctest::
:options: +NORMALIZE_WHITESPACE, +ELLIPSIS
.. doctest::
:options: +NORMALIZE_WHITESPACE, +ELLIPSIS
>>> from cv2 import CascadeClassifier, cv
>>> from xbob.io import load
>>> from xbob.ip.color import rgb_to_gray
>>> cc = CascadeClassifier(get_file('haarcascade_frontalface_alt.xml'))
>>> lena_gray = rgb_to_gray(load(get_file('lena.jpg')))
>>> face_bbxs = cc.detectMultiScale(lena_gray, 1.3, 4, 0, (20, 20))
>>> print face_bbxs
[[...]]
>>> from xbob.io import load
>>> from xbob.ip.color import rgb_to_gray
>>> lena_gray = rgb_to_gray(load(get_file('lena.jpg')))
>>> try:
... from cv2 import CascadeClassifier
... cc = CascadeClassifier(get_file('haarcascade_frontalface_alt.xml'))
... face_bbxs = cc.detectMultiScale(lena_gray, 1.3, 4, 0, (20, 20))
... except ImportError: #if you don't have OpenCV, do it otherwise
... face_bbxs = [[214, 202, 183, 183]] #e.g., manually
>>> print(face_bbxs)
[[...]]
The function ``detectMultiScale`` returns OpenCV_ rectangles as 2D
:py:class:`numpy.ndarray`'s. Each row corresponds to a detected face at the
input image. Notice the format of each bounding box differs from that of Bob_.
Their format is ``(x, y, width, height)``.
Once in possession of bounding boxes for the provided
,
gray-scaled image, you
Once in possession of bounding boxes for the provided
(
gray-scaled
)
image, you
can find the keypoints in the following way:
.. doctest::
:options: +NORMALIZE_WHITESPACE, +ELLIPSIS
>>> x, y, width, height =
[214, 202, 183, 183] #or from OpenCV
>>> x, y, width, height =
face_bbxs[0]
>>> from xbob.ip.flandmark import Flandmark
>>> localizer = Flandmark()
>>> keypoints = localizer.locate(lena_gray, y, x, height, width)
...
...
This diff is collapsed.
Click to expand it.
xbob/ip/flandmark/test.py
+
1
−
1
View file @
bdf725d2
...
...
@@ -39,7 +39,7 @@ def opencv_detect(image):
face.
"""
from
cv2
import
CascadeClassifier
,
cv
from
cv2
import
CascadeClassifier
cc
=
CascadeClassifier
(
F
(
'
haarcascade_frontalface_alt.xml
'
))
return
cc
.
detectMultiScale
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment