Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
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
钟尚武
dlib
Commits
5b5393f6
Commit
5b5393f6
authored
Jan 04, 2015
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clarified example
parent
c335bf67
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
find_candidate_object_locations.py
python_examples/find_candidate_object_locations.py
+18
-7
No files found.
python_examples/find_candidate_object_locations.py
View file @
5b5393f6
#!/usr/bin/python
# This example shows how to use find_candidate_object_locations()
#
# This example shows how to use find_candidate_object_locations(). The
# function takes an input image and generates a set of candidate rectangles
# which are expected to bound any objects in the image.
# It is based on the paper:
# Segmentation as Selective Search for Object Recognition by Koen E. A. van de Sande, et al.
#
# Typically, you would use this as part of an object detection pipeline.
# find_candidate_object_locations() nominates boxes that might contain an
# object and you then run some expensive classifier on each one and throw away
# the false alarms. Since find_candidate_object_locations() will only generate
# a few thousand rectangles it is much faster than scanning all possible
# rectangles inside an image.
import
dlib
from
skimage
import
io
...
...
@@ -11,9 +24,7 @@ img = io.imread(image_file)
rects
=
[]
dlib
.
find_candidate_object_locations
(
img
,
rects
,
min_size
=
500
)
windows
=
[]
for
d
in
rects
:
windows
.
append
([
d
.
top
(),
d
.
left
(),
d
.
bottom
(),
d
.
right
()])
print
len
(
windows
)
print
(
image_file
,
windows
)
print
(
"number of rectangles found {}"
.
format
(
len
(
rects
)))
for
k
,
d
in
enumerate
(
rects
):
print
(
"Detection {}: Left: {} Top: {} Right: {} Bottom: {}"
.
format
(
k
,
d
.
left
(),
d
.
top
(),
d
.
right
(),
d
.
bottom
()))
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