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
7a472d85
Commit
7a472d85
authored
Jan 24, 2018
by
Jozef Mlich
Committed by
Alexander Alekhin
Jan 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge pull request #10663 from jmlich:master
* hogsvm compatibility with python3
parent
b97b650a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
hogsvm.py
samples/python/tutorial_code/ml/py_svm_opencv/hogsvm.py
+7
-5
No files found.
samples/python/tutorial_code/ml/py_svm_opencv/hogsvm.py
100644 → 100755
View file @
7a472d85
#!/usr/bin/env python
import
cv2
as
cv
import
numpy
as
np
...
...
@@ -44,8 +46,8 @@ test_cells = [ i[50:] for i in cells]
###### Now training ########################
deskewed
=
[
map
(
deskew
,
row
)
for
row
in
train_cells
]
hogdata
=
[
map
(
hog
,
row
)
for
row
in
deskewed
]
deskewed
=
[
list
(
map
(
deskew
,
row
)
)
for
row
in
train_cells
]
hogdata
=
[
list
(
map
(
hog
,
row
)
)
for
row
in
deskewed
]
trainData
=
np
.
float32
(
hogdata
)
.
reshape
(
-
1
,
64
)
responses
=
np
.
repeat
(
np
.
arange
(
10
),
250
)[:,
np
.
newaxis
]
...
...
@@ -60,12 +62,12 @@ svm.save('svm_data.dat')
###### Now testing ########################
deskewed
=
[
map
(
deskew
,
row
)
for
row
in
test_cells
]
hogdata
=
[
map
(
hog
,
row
)
for
row
in
deskewed
]
deskewed
=
[
list
(
map
(
deskew
,
row
)
)
for
row
in
test_cells
]
hogdata
=
[
list
(
map
(
hog
,
row
)
)
for
row
in
deskewed
]
testData
=
np
.
float32
(
hogdata
)
.
reshape
(
-
1
,
bin_n
*
4
)
result
=
svm
.
predict
(
testData
)[
1
]
####### Check Accuracy ########################
mask
=
result
==
responses
correct
=
np
.
count_nonzero
(
mask
)
print
correct
*
100.0
/
result
.
size
print
(
correct
*
100.0
/
result
.
size
)
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