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
8356a6b6
Commit
8356a6b6
authored
May 11, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11442 from cclauss:print-function
parents
d1d7408a
05c1a3d1
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
91 additions
and
79 deletions
+91
-79
common.py
modules/core/src/opencl/runtime/generator/common.py
+54
-53
parser_cl.py
modules/core/src/opencl/runtime/generator/parser_cl.py
+3
-2
parser_clamdblas.py
...les/core/src/opencl/runtime/generator/parser_clamdblas.py
+3
-2
parser_clamdfft.py
modules/core/src/opencl/runtime/generator/parser_clamdfft.py
+3
-2
quantize_face_detector.py
modules/dnn/misc/quantize_face_detector.py
+3
-2
check-tests.py
modules/java/check-tests.py
+3
-2
perf_tests_timing.py
modules/ts/misc/perf_tests_timing.py
+3
-2
table_formatter.py
modules/ts/misc/table_formatter.py
+2
-1
testlog_parser.py
modules/ts/misc/testlog_parser.py
+8
-7
fast_neural_style.py
samples/dnn/fast_neural_style.py
+2
-1
mobilenet_ssd_accuracy.py
samples/dnn/mobilenet_ssd_accuracy.py
+3
-2
match_template.py
...on/tutorial_code/imgProc/match_template/match_template.py
+4
-3
No files found.
modules/core/src/opencl/runtime/generator/common.py
View file @
8356a6b6
from
__future__
import
print_function
import
sys
,
os
,
re
#
...
...
@@ -84,7 +85,7 @@ def readFunctionFilter(fns, fileName):
try
:
f
=
open
(
fileName
,
"r"
)
except
:
print
"ERROR: Can't open filter file:
%
s"
%
fileName
print
(
"ERROR: Can't open filter file:
%
s"
%
fileName
)
return
0
count
=
0
...
...
@@ -133,8 +134,8 @@ def outputToString(f):
@outputToString
def
generateFilterNames
(
fns
):
for
fn
in
fns
:
print
'
%
s
%
s'
%
(
''
if
fn
.
has_key
(
'enabled'
)
else
'//'
,
fn
[
'name'
]
)
print
'#total
%
d'
%
len
(
fns
)
print
(
'
%
s
%
s'
%
(
''
if
'enabled'
in
fn
else
'//'
,
fn
[
'name'
])
)
print
(
'#total
%
d'
%
len
(
fns
)
)
callback_check
=
re
.
compile
(
r'([^\(]*\(.*)(\* *)(\).*\(.*\))'
)
...
...
@@ -145,100 +146,100 @@ def getTypeWithParam(t, p):
@outputToString
def
generateStructDefinitions
(
fns
,
lprefix
=
'opencl_fn'
,
enumprefix
=
'OPENCL_FN'
):
print
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
]
)
print
(
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
])
)
for
fn
in
fns
:
commentStr
=
''
if
fn
.
has_key
(
'enabled'
)
else
'//'
commentStr
=
''
if
'enabled'
in
fn
else
'//'
decl_args
=
[]
for
(
i
,
t
)
in
enumerate
(
fn
[
'params'
]):
decl_args
.
append
(
getTypeWithParam
(
t
,
'p
%
d'
%
(
i
+
1
)))
decl_args_str
=
'('
+
(
', '
.
join
(
decl_args
))
+
')'
print
'
%
s
%
s
%
d(
%
s_
%
s,
%
s,
%
s)'
%
\
print
(
'
%
s
%
s
%
d(
%
s_
%
s,
%
s,
%
s)'
%
\
(
commentStr
,
lprefix
,
len
(
fn
[
'params'
]),
enumprefix
,
fn
[
'name'
],
\
' '
.
join
(
fn
[
'ret'
]),
decl_args_str
)
print
commentStr
+
(
'
%
s
%
s (
%
s *
%
s)(
%
s) =
\n
%
s
%
s_
%
s_switch_fn;'
%
\
' '
.
join
(
fn
[
'ret'
]),
decl_args_str
)
)
print
(
commentStr
+
(
'
%
s
%
s (
%
s *
%
s)(
%
s) =
\n
%
s
%
s_
%
s_switch_fn;'
%
\
((
' '
.
join
(
fn
[
'modifiers'
]
+
' '
)
if
len
(
fn
[
'modifiers'
])
>
0
else
''
),
' '
.
join
(
fn
[
'ret'
]),
' '
.
join
(
fn
[
'calling'
]),
fn
[
'name'
],
', '
.
join
(
fn
[
'params'
]),
\
commentStr
,
enumprefix
,
fn
[
'name'
]))
print
commentStr
+
(
'static const struct DynamicFnEntry
%
s_definition = { "
%
s", (void**)&
%
s};'
%
(
fn
[
'name'
],
fn
[
'name'
],
fn
[
'name'
]
))
print
commentStr
,
enumprefix
,
fn
[
'name'
]))
)
print
(
commentStr
+
(
'static const struct DynamicFnEntry
%
s_definition = { "
%
s", (void**)&
%
s};'
%
(
fn
[
'name'
],
fn
[
'name'
],
fn
[
'name'
])
))
print
()
@outputToString
def
generateStaticDefinitions
(
fns
):
print
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
]
)
print
(
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
])
)
for
fn
in
fns
:
commentStr
=
''
if
fn
.
has_key
(
'enabled'
)
else
'//'
commentStr
=
''
if
'enabled'
in
fn
else
'//'
decl_args
=
[]
for
(
i
,
t
)
in
enumerate
(
fn
[
'params'
]):
decl_args
.
append
(
getTypeWithParam
(
t
,
'p
%
d'
%
(
i
+
1
)))
decl_args_str
=
'('
+
(
', '
.
join
(
decl_args
))
+
')'
print
commentStr
+
(
'CL_RUNTIME_EXPORT
%
s
%
s (
%
s *
%
s_pfn)(
%
s) =
%
s;'
%
\
print
(
commentStr
+
(
'CL_RUNTIME_EXPORT
%
s
%
s (
%
s *
%
s_pfn)(
%
s) =
%
s;'
%
\
((
' '
.
join
(
fn
[
'modifiers'
]
+
' '
)
if
len
(
fn
[
'modifiers'
])
>
0
else
''
),
' '
.
join
(
fn
[
'ret'
]),
' '
.
join
(
fn
[
'calling'
]),
fn
[
'name'
],
', '
.
join
(
fn
[
'params'
]),
\
fn
[
'name'
]))
fn
[
'name'
]))
)
@outputToString
def
generateListOfDefinitions
(
fns
,
name
=
'opencl_fn_list'
):
print
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
]
)
print
'static const struct DynamicFnEntry*
%
s[] = {'
%
(
name
)
print
(
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
])
)
print
(
'static const struct DynamicFnEntry*
%
s[] = {'
%
(
name
)
)
for
fn
in
fns
:
commentStr
=
''
if
fn
.
has_key
(
'enabled'
)
else
'//'
if
fn
.
has_key
(
'enabled'
)
:
print
' &
%
s_definition,'
%
(
fn
[
'name'
]
)
commentStr
=
''
if
'enabled'
in
fn
else
'//'
if
'enabled'
in
fn
:
print
(
' &
%
s_definition,'
%
(
fn
[
'name'
])
)
else
:
print
' NULL/*&
%
s_definition*/,'
%
(
fn
[
'name'
]
)
print
(
' NULL/*&
%
s_definition*/,'
%
(
fn
[
'name'
])
)
first
=
False
print
'};'
print
(
'};'
)
@outputToString
def
generateEnums
(
fns
,
prefix
=
'OPENCL_FN'
):
print
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
]
)
print
'enum
%
s_ID {'
%
prefix
print
(
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
])
)
print
(
'enum
%
s_ID {'
%
prefix
)
for
(
i
,
fn
)
in
enumerate
(
fns
):
commentStr
=
''
if
fn
.
has_key
(
'enabled'
)
else
'//'
print
commentStr
+
(
'
%
s_
%
s =
%
d,'
%
(
prefix
,
fn
[
'name'
],
i
))
print
'};'
commentStr
=
''
if
'enabled'
in
fn
else
'//'
print
(
commentStr
+
(
'
%
s_
%
s =
%
d,'
%
(
prefix
,
fn
[
'name'
],
i
)
))
print
(
'};'
)
@outputToString
def
generateRemapOrigin
(
fns
):
print
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
]
)
print
(
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
])
)
for
fn
in
fns
:
print
'#define
%
s
%
s_'
%
(
fn
[
'name'
],
fn
[
'name'
]
)
print
(
'#define
%
s
%
s_'
%
(
fn
[
'name'
],
fn
[
'name'
])
)
@outputToString
def
generateRemapDynamic
(
fns
):
print
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
]
)
print
(
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
])
)
for
fn
in
fns
:
print
'#undef
%
s'
%
(
fn
[
'name'
]
)
commentStr
=
''
if
fn
.
has_key
(
'enabled'
)
else
'//'
print
commentStr
+
(
'#define
%
s
%
s_pfn'
%
(
fn
[
'name'
],
fn
[
'name'
]
))
print
(
'#undef
%
s'
%
(
fn
[
'name'
])
)
commentStr
=
''
if
'enabled'
in
fn
else
'//'
print
(
commentStr
+
(
'#define
%
s
%
s_pfn'
%
(
fn
[
'name'
],
fn
[
'name'
])
))
@outputToString
def
generateFnDeclaration
(
fns
):
print
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
]
)
print
(
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
])
)
for
fn
in
fns
:
commentStr
=
''
if
fn
.
has_key
(
'enabled'
)
else
'//'
print
commentStr
+
(
'extern CL_RUNTIME_EXPORT
%
s
%
s (
%
s *
%
s)(
%
s);'
%
(
' '
.
join
(
fn
[
'modifiers'
]),
' '
.
join
(
fn
[
'ret'
]),
' '
.
join
(
fn
[
'calling'
]),
fn
[
'name'
],
', '
.
join
(
fn
[
'params'
]
if
not
fn
.
has_key
(
'params_full'
)
else
fn
[
'params_full'
]
)))
commentStr
=
''
if
'enabled'
in
fn
else
'//'
print
(
commentStr
+
(
'extern CL_RUNTIME_EXPORT
%
s
%
s (
%
s *
%
s)(
%
s);'
%
(
' '
.
join
(
fn
[
'modifiers'
]),
' '
.
join
(
fn
[
'ret'
]),
' '
.
join
(
fn
[
'calling'
]),
fn
[
'name'
],
', '
.
join
(
fn
[
'params'
]
if
'params_full'
not
in
fn
else
fn
[
'params_full'
])
)))
@outputToString
def
generateTemplates
(
total
,
lprefix
,
switch_name
,
calling_convention
=
''
):
print
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
]
)
print
(
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
])
)
for
sz
in
range
(
total
):
template_params
=
[
'ID'
,
'_R'
,
'decl_args'
]
params
=
[
'p
%
d'
%
(
i
+
1
)
for
i
in
range
(
0
,
sz
)]
print
'#define
%
s
%
d(
%
s)
\\
'
%
(
lprefix
,
sz
,
', '
.
join
(
template_params
))
print
' typedef _R (
%
s *ID##FN)decl_args;
\\
'
%
(
calling_convention
)
print
' static _R
%
s ID##_switch_fn decl_args
\\
'
%
(
calling_convention
)
print
' { return ((ID##FN)
%
s(ID))(
%
s); }
\\
'
%
(
switch_name
,
', '
.
join
(
params
))
print
''
print
(
'#define
%
s
%
d(
%
s)
\\
'
%
(
lprefix
,
sz
,
', '
.
join
(
template_params
)
))
print
(
' typedef _R (
%
s *ID##FN)decl_args;
\\
'
%
(
calling_convention
)
)
print
(
' static _R
%
s ID##_switch_fn decl_args
\\
'
%
(
calling_convention
)
)
print
(
' { return ((ID##FN)
%
s(ID))(
%
s); }
\\
'
%
(
switch_name
,
', '
.
join
(
params
)
))
print
(
''
)
@outputToString
def
generateInlineWrappers
(
fns
):
print
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
]
)
print
(
'// generated by
%
s'
%
os
.
path
.
basename
(
sys
.
argv
[
0
])
)
for
fn
in
fns
:
commentStr
=
''
if
fn
.
has_key
(
'enabled'
)
else
'//'
print
'#undef
%
s'
%
(
fn
[
'name'
]
)
print
commentStr
+
(
'#define
%
s
%
s_fn'
%
(
fn
[
'name'
],
fn
[
'name'
]
))
commentStr
=
''
if
'enabled'
in
fn
else
'//'
print
(
'#undef
%
s'
%
(
fn
[
'name'
])
)
print
(
commentStr
+
(
'#define
%
s
%
s_fn'
%
(
fn
[
'name'
],
fn
[
'name'
])
))
params
=
[]
call_params
=
[]
for
i
in
range
(
0
,
len
(
fn
[
'params'
])):
...
...
@@ -251,23 +252,23 @@ def generateInlineWrappers(fns):
call_params
.
append
(
'p
%
d'
%
(
i
))
if
len
(
fn
[
'ret'
])
==
1
and
fn
[
'ret'
][
0
]
==
'void'
:
print
commentStr
+
(
'inline void
%
s(
%
s) {
%
s_pfn(
%
s); }'
\
%
(
fn
[
'name'
],
', '
.
join
(
params
),
fn
[
'name'
],
', '
.
join
(
call_params
)))
print
(
commentStr
+
(
'inline void
%
s(
%
s) {
%
s_pfn(
%
s); }'
\
%
(
fn
[
'name'
],
', '
.
join
(
params
),
fn
[
'name'
],
', '
.
join
(
call_params
)))
)
else
:
print
commentStr
+
(
'inline
%
s
%
s(
%
s) { return
%
s_pfn(
%
s); }'
\
%
(
' '
.
join
(
fn
[
'ret'
]),
fn
[
'name'
],
', '
.
join
(
params
),
fn
[
'name'
],
', '
.
join
(
call_params
)))
print
(
commentStr
+
(
'inline
%
s
%
s(
%
s) { return
%
s_pfn(
%
s); }'
\
%
(
' '
.
join
(
fn
[
'ret'
]),
fn
[
'name'
],
', '
.
join
(
params
),
fn
[
'name'
],
', '
.
join
(
call_params
)))
)
def
ProcessTemplate
(
inputFile
,
ctx
,
noteLine
=
'//
\n
// AUTOGENERATED, DO NOT EDIT
\n
//'
):
f
=
open
(
inputFile
,
"r"
)
if
noteLine
:
print
noteLine
print
(
noteLine
)
for
line
in
f
:
if
line
.
startswith
(
'@'
):
assert
line
[
-
1
]
==
'
\n
'
line
=
line
[:
-
1
]
# remove '\n'
assert
line
[
-
1
]
==
'@'
name
=
line
[
1
:
-
1
]
assert
ctx
.
has_key
(
name
)
,
name
assert
name
in
ctx
,
name
line
=
ctx
[
name
]
+
(
'
\n
'
if
len
(
ctx
[
name
])
>
0
and
ctx
[
name
][
-
1
]
!=
'
\n
'
else
''
)
sys
.
stdout
.
write
(
line
)
f
.
close
()
modules/core/src/opencl/runtime/generator/parser_cl.py
View file @
8356a6b6
...
...
@@ -2,6 +2,7 @@
# usage:
# cat opencl11/cl.h | $0 cl_runtime_opencl11
# cat opencl12/cl.h | $0 cl_runtime_opencl12
from
__future__
import
print_function
import
sys
,
re
;
from
common
import
remove_comments
,
getTokens
,
getParameters
,
postProcessParameters
...
...
@@ -77,7 +78,7 @@ while True:
name
=
parts
[
i
];
i
+=
1
;
fn
[
'name'
]
=
name
print
'name='
+
name
print
(
'name='
+
name
)
params
=
getParameters
(
i
,
parts
)
...
...
@@ -88,7 +89,7 @@ while True:
f
.
close
()
print
'Found
%
d functions'
%
len
(
fns
)
print
(
'Found
%
d functions'
%
len
(
fns
)
)
postProcessParameters
(
fns
)
...
...
modules/core/src/opencl/runtime/generator/parser_clamdblas.py
View file @
8356a6b6
#!/bin/python
# usage:
# cat clAmdBlas.h | $0
from
__future__
import
print_function
import
sys
,
re
;
from
common
import
remove_comments
,
getTokens
,
getParameters
,
postProcessParameters
...
...
@@ -69,7 +70,7 @@ while True:
name
=
parts
[
i
];
i
+=
1
;
fn
[
'name'
]
=
name
print
'name='
+
name
print
(
'name='
+
name
)
params
=
getParameters
(
i
,
parts
)
...
...
@@ -80,7 +81,7 @@ while True:
f
.
close
()
print
'Found
%
d functions'
%
len
(
fns
)
print
(
'Found
%
d functions'
%
len
(
fns
)
)
postProcessParameters
(
fns
)
...
...
modules/core/src/opencl/runtime/generator/parser_clamdfft.py
View file @
8356a6b6
#!/bin/python
# usage:
# cat clAmdFft.h | $0
from
__future__
import
print_function
import
sys
,
re
;
from
common
import
remove_comments
,
getTokens
,
getParameters
,
postProcessParameters
...
...
@@ -63,7 +64,7 @@ while True:
name
=
parts
[
i
];
i
+=
1
;
fn
[
'name'
]
=
name
print
'name='
+
name
print
(
'name='
+
name
)
params
=
getParameters
(
i
,
parts
)
...
...
@@ -77,7 +78,7 @@ while True:
f
.
close
()
print
'Found
%
d functions'
%
len
(
fns
)
print
(
'Found
%
d functions'
%
len
(
fns
)
)
postProcessParameters
(
fns
)
...
...
modules/dnn/misc/quantize_face_detector.py
View file @
8356a6b6
from
__future__
import
print_function
import
argparse
import
cv2
as
cv
import
tensorflow
as
tf
...
...
@@ -199,8 +200,8 @@ with tf.Session() as sess:
outDNN
=
cvNet
.
forward
(
out_nodes
)
outTF
=
sess
.
run
([
mbox_loc
,
mbox_conf_flatten
],
feed_dict
=
{
inp
:
inputData
.
transpose
(
0
,
2
,
3
,
1
)})
print
'Max diff @ locations:
%
e'
%
np
.
max
(
np
.
abs
(
outDNN
[
0
]
-
outTF
[
0
]
))
print
'Max diff @ confidence:
%
e'
%
np
.
max
(
np
.
abs
(
outDNN
[
1
]
-
outTF
[
1
]
))
print
(
'Max diff @ locations:
%
e'
%
np
.
max
(
np
.
abs
(
outDNN
[
0
]
-
outTF
[
0
])
))
print
(
'Max diff @ confidence:
%
e'
%
np
.
max
(
np
.
abs
(
outDNN
[
1
]
-
outTF
[
1
])
))
# Save a graph
graph_def
=
sess
.
graph
.
as_graph_def
()
...
...
modules/java/check-tests.py
View file @
8356a6b6
#!/usr/bin/env python
from
__future__
import
print_function
import
sys
,
os
,
re
classes_ignore_list
=
(
...
...
@@ -148,9 +149,9 @@ class JavaParser:
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
<
2
:
print
"Usage:
\n
"
,
\
print
(
"Usage:
\n
"
,
\
os
.
path
.
basename
(
sys
.
argv
[
0
]),
\
"<Classes/Tests dir1/file1> [<Classes/Tests dir2/file2> ...]
\n
"
,
"Not tested methods are loggedto stdout."
"<Classes/Tests dir1/file1> [<Classes/Tests dir2/file2> ...]
\n
"
,
"Not tested methods are loggedto stdout."
)
exit
(
0
)
parser
=
JavaParser
()
for
x
in
sys
.
argv
[
1
:]:
...
...
modules/ts/misc/perf_tests_timing.py
View file @
8356a6b6
#!/usr/bin/env python
from
__future__
import
print_function
import
testlog_parser
,
sys
,
os
,
xml
,
glob
,
re
from
table_formatter
import
*
from
optparse
import
OptionParser
...
...
@@ -154,6 +155,6 @@ if __name__ == "__main__":
htmlPrintFooter
(
sys
.
stdout
)
else
:
if
not
options
.
failedOnly
:
print
'
\n
Overall time:
%.2
f min
\n
'
%
overall_time
print
(
'
\n
Overall time:
%.2
f min
\n
'
%
overall_time
)
tbl
.
consolePrintTable
(
sys
.
stdout
)
print
2
*
'
\n
'
print
(
2
*
'
\n
'
)
modules/ts/misc/table_formatter.py
View file @
8356a6b6
#!/usr/bin/env python
from
__future__
import
print_function
import
sys
,
re
,
os
.
path
,
cgi
,
stat
,
math
from
optparse
import
OptionParser
from
color
import
getColorizer
,
dummyColorizer
...
...
@@ -723,7 +724,7 @@ def formatValue(val, metric, units = None):
if
__name__
==
"__main__"
:
if
len
(
sys
.
argv
)
<
2
:
print
"Usage:
\n
"
,
os
.
path
.
basename
(
sys
.
argv
[
0
]),
"<log_name>.xml"
print
(
"Usage:
\n
"
,
os
.
path
.
basename
(
sys
.
argv
[
0
]),
"<log_name>.xml"
)
exit
(
0
)
parser
=
OptionParser
()
...
...
modules/ts/misc/testlog_parser.py
View file @
8356a6b6
#!/usr/bin/env python
from
__future__
import
print_function
import
collections
import
re
import
os.path
...
...
@@ -108,7 +109,7 @@ class TestInfo(object):
def
dump
(
self
,
units
=
"ms"
):
print
"
%
s ->
\t\033
[1;31m
%
s
\033
[0m =
\t
%.2
f
%
s"
%
(
str
(
self
),
self
.
status
,
self
.
get
(
"gmean"
,
units
),
units
)
print
(
"
%
s ->
\t\033
[1;31m
%
s
\033
[0m =
\t
%.2
f
%
s"
%
(
str
(
self
),
self
.
status
,
self
.
get
(
"gmean"
,
units
),
units
)
)
def
getName
(
self
):
...
...
@@ -198,22 +199,22 @@ def parseLogFile(filename):
if
__name__
==
"__main__"
:
if
len
(
sys
.
argv
)
<
2
:
print
"Usage:
\n
"
,
os
.
path
.
basename
(
sys
.
argv
[
0
]),
"<log_name>.xml"
print
(
"Usage:
\n
"
,
os
.
path
.
basename
(
sys
.
argv
[
0
]),
"<log_name>.xml"
)
exit
(
0
)
for
arg
in
sys
.
argv
[
1
:]:
print
"Processing {}..."
.
format
(
arg
)
print
(
"Processing {}..."
.
format
(
arg
)
)
run
=
parseLogFile
(
arg
)
print
"Properties:"
print
(
"Properties:"
)
for
(
prop_name
,
prop_value
)
in
run
.
properties
.
items
():
print
"
\t
{} = {}"
.
format
(
prop_name
,
prop_value
)
print
(
"
\t
{} = {}"
.
format
(
prop_name
,
prop_value
)
)
print
"Tests:"
print
(
"Tests:"
)
for
t
in
sorted
(
run
.
tests
):
t
.
dump
()
print
print
()
samples/dnn/fast_neural_style.py
View file @
8356a6b6
from
__future__
import
print_function
import
cv2
as
cv
import
numpy
as
np
import
argparse
...
...
@@ -43,7 +44,7 @@ while cv.waitKey(1) < 0:
t
,
_
=
net
.
getPerfProfile
()
freq
=
cv
.
getTickFrequency
()
/
1000
print
t
/
freq
,
'ms'
print
(
t
/
freq
,
'ms'
)
if
args
.
median_filter
:
out
=
cv
.
medianBlur
(
out
,
args
.
median_filter
)
...
...
samples/dnn/mobilenet_ssd_accuracy.py
View file @
8356a6b6
from
__future__
import
print_function
# Script to evaluate MobileNet-SSD object detection model trained in TensorFlow
# using both TensorFlow and OpenCV. Example:
#
...
...
@@ -115,14 +116,14 @@ pylab.rcParams['figure.figsize'] = (10.0, 8.0)
annType
=
[
'segm'
,
'bbox'
,
'keypoints'
]
annType
=
annType
[
1
]
#specify type here
prefix
=
'person_keypoints'
if
annType
==
'keypoints'
else
'instances'
print
'Running demo for *
%
s* results.'
%
(
annType
)
print
(
'Running demo for *
%
s* results.'
%
(
annType
)
)
#initialize COCO ground truth api
cocoGt
=
COCO
(
args
.
annotations
)
#initialize COCO detections api
for
resFile
in
[
'tf_result.json'
,
'cv_result.json'
]:
print
resFile
print
(
resFile
)
cocoDt
=
cocoGt
.
loadRes
(
resFile
)
cocoEval
=
COCOeval
(
cocoGt
,
cocoDt
,
annType
)
...
...
samples/python/tutorial_code/imgProc/match_template/match_template.py
View file @
8356a6b6
from
__future__
import
print_function
import
sys
import
cv2
as
cv
...
...
@@ -16,8 +17,8 @@ max_Trackbar = 5
def
main
(
argv
):
if
(
len
(
sys
.
argv
)
<
3
):
print
'Not enough parameters'
print
'Usage:
\n
match_template_demo.py <image_name> <template_name> [<mask_name>]'
print
(
'Not enough parameters'
)
print
(
'Usage:
\n
match_template_demo.py <image_name> <template_name> [<mask_name>]'
)
return
-
1
## [load_image]
...
...
@@ -33,7 +34,7 @@ def main(argv):
mask
=
cv
.
imread
(
sys
.
argv
[
3
],
cv
.
IMREAD_COLOR
)
if
((
img
is
None
)
or
(
templ
is
None
)
or
(
use_mask
and
(
mask
is
None
))):
print
'Can
\'
t read one of the images'
print
(
'Can
\'
t read one of the images'
)
return
-
1
## [load_image]
...
...
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