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
22dece81
Commit
22dece81
authored
Oct 13, 2017
by
catree
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix DNN samples for compatibility with Python 3.
Add PyInt_Check in pyopencv_dnn.hpp.
parent
1ba29cc9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
8 deletions
+12
-8
pyopencv_dnn.hpp
modules/dnn/misc/python/pyopencv_dnn.hpp
+5
-0
colorization.py
samples/dnn/colorization.py
+5
-3
mobilenet_ssd_python.py
samples/dnn/mobilenet_ssd_python.py
+2
-2
resnet_ssd_face_python.py
samples/dnn/resnet_ssd_face_python.py
+0
-3
No files found.
modules/dnn/misc/python/pyopencv_dnn.hpp
View file @
22dece81
...
...
@@ -16,6 +16,11 @@ bool pyopencv_to(PyObject *o, dnn::DictValue &dv, const char *name)
dv
=
dnn
::
DictValue
((
int64
)
PyLong_AsLongLong
(
o
));
return
true
;
}
else
if
(
PyInt_Check
(
o
))
{
dv
=
dnn
::
DictValue
((
int64
)
PyInt_AS_LONG
(
o
));
return
true
;
}
else
if
(
PyFloat_Check
(
o
))
{
dv
=
dnn
::
DictValue
(
PyFloat_AS_DOUBLE
(
o
));
...
...
samples/dnn/colorization.py
View file @
22dece81
# Script is based on https://github.com/richzhang/colorization/colorize.py
# Script is based on https://github.com/richzhang/colorization/blob/master/colorize.py
# To download the caffemodel and the prototxt, see: https://github.com/richzhang/colorization/tree/master/models
# To download pts_in_hull.npy, see: https://github.com/richzhang/colorization/blob/master/resources/pts_in_hull.npy
import
numpy
as
np
import
argparse
import
cv2
as
cv
...
...
@@ -27,8 +29,8 @@ if __name__ == '__main__':
# populate cluster centers as 1x1 convolution kernel
pts_in_hull
=
pts_in_hull
.
transpose
()
.
reshape
(
2
,
313
,
1
,
1
)
net
.
getLayer
(
long
(
net
.
getLayerId
(
'class8_ab'
)
))
.
blobs
=
[
pts_in_hull
.
astype
(
np
.
float32
)]
net
.
getLayer
(
long
(
net
.
getLayerId
(
'conv8_313_rh'
)
))
.
blobs
=
[
np
.
full
([
1
,
313
],
2.606
,
np
.
float32
)]
net
.
getLayer
(
net
.
getLayerId
(
'class8_ab'
))
.
blobs
=
[
pts_in_hull
.
astype
(
np
.
float32
)]
net
.
getLayer
(
net
.
getLayerId
(
'conv8_313_rh'
))
.
blobs
=
[
np
.
full
([
1
,
313
],
2.606
,
np
.
float32
)]
if
args
.
input
:
cap
=
cv
.
VideoCapture
(
args
.
input
)
...
...
samples/dnn/mobilenet_ssd_python.py
View file @
22dece81
...
...
@@ -95,9 +95,9 @@ if __name__ == "__main__":
else
:
cropSize
=
(
cols
,
int
(
cols
/
WHRatio
))
y1
=
(
rows
-
cropSize
[
1
])
/
2
y1
=
int
((
rows
-
cropSize
[
1
])
/
2
)
y2
=
y1
+
cropSize
[
1
]
x1
=
(
cols
-
cropSize
[
0
])
/
2
x1
=
int
((
cols
-
cropSize
[
0
])
/
2
)
x2
=
x1
+
cropSize
[
0
]
frame
=
frame
[
y1
:
y2
,
x1
:
x2
]
...
...
samples/dnn/resnet_ssd_face_python.py
View file @
22dece81
import
numpy
as
np
import
argparse
import
os
import
sys
sys
.
path
.
append
(
'/home/arrybn/build/opencv/lib'
)
import
cv2
as
cv
try
:
import
cv2
as
cv
...
...
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