Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
d7a20812
Commit
d7a20812
authored
Aug 12, 2011
by
Alexander Mordvintsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
peopledetect.py sample added (TODO: use builtin svm data instead of people_hog.txt)
some old cv api use cleaning
parent
9fba5e8d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
2 deletions
+59
-2
distrans.py
samples/python2/distrans.py
+1
-0
facedetect.py
samples/python2/facedetect.py
+1
-1
lk_track.py
samples/python2/lk_track.py
+0
-1
people_hog.txt
samples/python2/people_hog.txt
+0
-0
peopledetect.py
samples/python2/peopledetect.py
+57
-0
No files found.
samples/python2/distrans.py
View file @
d7a20812
import
numpy
as
np
import
cv2
import
cv2.cv
as
cv
from
common
import
make_cmap
help_message
=
'''USAGE: distrans.py [<image>]
...
...
samples/python2/facedetect.py
View file @
d7a20812
...
...
@@ -37,7 +37,7 @@ if __name__ == '__main__':
while
True
:
ret
,
img
=
cam
.
read
()
gray
=
cv2
.
cvtColor
(
img
,
cv
.
CV
_BGR2GRAY
)
gray
=
cv2
.
cvtColor
(
img
,
cv
2
.
COLOR
_BGR2GRAY
)
gray
=
cv2
.
equalizeHist
(
gray
)
t
=
clock
()
...
...
samples/python2/lk_track.py
View file @
d7a20812
import
numpy
as
np
import
cv2
import
cv2.cv
as
cv
import
video
from
common
import
anorm2
,
draw_str
from
time
import
clock
...
...
samples/python2/people_hog.txt
0 → 100644
View file @
d7a20812
This diff is collapsed.
Click to expand it.
samples/python2/peopledetect.py
0 → 100644
View file @
d7a20812
import
numpy
as
np
import
cv2
help_message
=
'''
USAGE: peopledetect.py <image_names> ...
Press any key to continue, ESC to stop.
'''
def
inside
(
r
,
q
):
rx
,
ry
,
rw
,
rh
=
r
qx
,
qy
,
qw
,
qh
=
q
return
rx
>
qx
and
ry
>
qy
and
rx
+
rw
<
qx
+
qw
and
ry
+
rh
<
qy
+
qh
def
draw_detections
(
img
,
rects
,
thickness
=
1
):
for
x
,
y
,
w
,
h
in
rects
:
# the HOG detector returns slightly larger rectangles than the real objects.
# so we slightly shrink the rectangles to get a nicer output.
pad_w
,
pad_h
=
int
(
0.15
*
w
),
int
(
0.05
*
h
)
cv2
.
rectangle
(
img
,
(
x
+
pad_w
,
y
+
pad_h
),
(
x
+
w
-
pad_w
,
y
+
h
-
pad_h
),
(
0
,
255
,
0
),
thickness
)
if
__name__
==
'__main__'
:
import
sys
from
glob
import
glob
import
itertools
as
it
print
help_message
text
=
""
.
join
(
open
(
'people_hog.txt'
)
.
readlines
()[
1
:])
data
=
np
.
fromstring
(
text
,
sep
=
','
)
hog
=
cv2
.
HOGDescriptor
()
hog
.
setSVMDetector
(
data
)
for
fn
in
it
.
chain
(
*
map
(
glob
,
sys
.
argv
[
1
:])):
print
fn
,
' - '
,
try
:
img
=
cv2
.
imread
(
fn
)
except
:
print
'loading error'
continue
found
=
hog
.
detectMultiScale
(
img
,
winStride
=
(
8
,
8
),
padding
=
(
32
,
32
),
scale
=
1.05
)
found_filtered
=
[]
for
ri
,
r
in
enumerate
(
found
):
for
qi
,
q
in
enumerate
(
found
):
if
ri
!=
qi
and
inside
(
r
,
q
):
break
else
:
found_filtered
.
append
(
r
)
draw_detections
(
img
,
found
)
draw_detections
(
img
,
found_filtered
,
3
)
print
'
%
d (
%
d) found'
%
(
len
(
found_filtered
),
len
(
found
))
cv2
.
imshow
(
'img'
,
img
)
ch
=
cv2
.
waitKey
()
if
ch
==
27
:
break
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