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
d9185ec2
Commit
d9185ec2
authored
Aug 22, 2012
by
Alexander Mordvintesv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added _doc.py -- doc-string ckecking utility
added some sample description
parent
122f5956
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
95 additions
and
36 deletions
+95
-36
_coverage.py
samples/python2/_coverage.py
+21
-16
_doc.py
samples/python2/_doc.py
+14
-0
common.py
samples/python2/common.py
+4
-0
demo.py
samples/python2/demo.py
+4
-0
distrans.py
samples/python2/distrans.py
+11
-6
floodfill.py
samples/python2/floodfill.py
+9
-5
inpaint.py
samples/python2/inpaint.py
+12
-5
morphology.py
samples/python2/morphology.py
+14
-4
squares.py
samples/python2/squares.py
+6
-0
No files found.
samples/python2/_coverage.py
View file @
d9185ec2
'''
Utility for measuring python opencv API coverage by samples.
'''
from
glob
import
glob
from
glob
import
glob
import
cv2
import
cv2
import
re
import
re
cv2_callable
=
set
([
'cv2.'
+
name
for
name
in
dir
(
cv2
)
if
callable
(
getattr
(
cv2
,
name
)
)])
if
__name__
==
'__main__'
:
cv2_callable
=
set
([
'cv2.'
+
name
for
name
in
dir
(
cv2
)
if
callable
(
getattr
(
cv2
,
name
)
)])
found
=
set
()
found
=
set
()
for
fn
in
glob
(
'*.py'
):
for
fn
in
glob
(
'*.py'
):
print
' --- '
,
fn
print
' --- '
,
fn
code
=
open
(
fn
)
.
read
()
code
=
open
(
fn
)
.
read
()
found
|=
set
(
re
.
findall
(
'cv2?
\
.
\
w+'
,
code
))
found
|=
set
(
re
.
findall
(
'cv2?
\
.
\
w+'
,
code
))
cv2_used
=
found
&
cv2_callable
cv2_used
=
found
&
cv2_callable
cv2_unused
=
cv2_callable
-
cv2_used
cv2_unused
=
cv2_callable
-
cv2_used
with
open
(
'unused_api.txt'
,
'w'
)
as
f
:
with
open
(
'unused_api.txt'
,
'w'
)
as
f
:
f
.
write
(
'
\n
'
.
join
(
sorted
(
cv2_unused
)))
f
.
write
(
'
\n
'
.
join
(
sorted
(
cv2_unused
)))
r
=
1.0
*
len
(
cv2_used
)
/
len
(
cv2_callable
)
r
=
1.0
*
len
(
cv2_used
)
/
len
(
cv2_callable
)
print
'
\n
cv2 api coverage:
%
d /
%
d (
%.1
f
%%
)'
%
(
len
(
cv2_used
),
len
(
cv2_callable
),
r
*
100
)
print
'
\n
cv2 api coverage:
%
d /
%
d (
%.1
f
%%
)'
%
(
len
(
cv2_used
),
len
(
cv2_callable
),
r
*
100
)
print
'
\n
old (cv) symbols:'
print
'
\n
old (cv) symbols:'
for
s
in
found
:
for
s
in
found
:
if
s
.
startswith
(
'cv.'
):
if
s
.
startswith
(
'cv.'
):
print
s
print
s
samples/python2/_doc.py
0 → 100644
View file @
d9185ec2
'''
Scans current directory for *.py files and reports
ones with missing __doc__ string.
'''
from
glob
import
glob
if
__name__
==
'__main__'
:
print
'--- undocumented files:'
for
fn
in
glob
(
'*.py'
):
loc
=
{}
execfile
(
fn
,
loc
)
if
'__doc__'
not
in
loc
:
print
fn
samples/python2/common.py
View file @
d9185ec2
'''
This module contais some common routines used by other samples.
'''
import
numpy
as
np
import
numpy
as
np
import
cv2
import
cv2
import
os
import
os
...
...
samples/python2/demo.py
View file @
d9185ec2
'''
Sample-launcher application.
'''
import
Tkinter
as
tk
import
Tkinter
as
tk
from
ScrolledText
import
ScrolledText
from
ScrolledText
import
ScrolledText
from
glob
import
glob
from
glob
import
glob
...
...
samples/python2/distrans.py
View file @
d9185ec2
import
numpy
as
np
'''
import
cv2
Distance transform sample.
import
cv2.cv
as
cv
from
common
import
make_cmap
help_message
=
'''USAGE: distrans.py [<image>]
Usage:
distrans.py [<image>]
Keys:
Keys:
ESC - exit
ESC - exit
v - toggle voronoi mode
v - toggle voronoi mode
'''
'''
import
numpy
as
np
import
cv2
import
cv2.cv
as
cv
from
common
import
make_cmap
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
import
sys
import
sys
try
:
fn
=
sys
.
argv
[
1
]
try
:
fn
=
sys
.
argv
[
1
]
except
:
fn
=
'../cpp/fruits.jpg'
except
:
fn
=
'../cpp/fruits.jpg'
print
help_message
print
__doc__
img
=
cv2
.
imread
(
fn
,
0
)
img
=
cv2
.
imread
(
fn
,
0
)
cm
=
make_cmap
(
'jet'
)
cm
=
make_cmap
(
'jet'
)
...
...
samples/python2/floodfill.py
View file @
d9185ec2
import
numpy
as
np
'''
import
cv2
Floodfill sample.
help_message
=
'''USAGE: floodfill.py [<image>]
Usage:
floodfill.py [<image>]
Click on the image to set seed point
Click on the image to set seed point
Keys:
Keys:
f - toggle floating range
f - toggle floating range
...
@@ -11,11 +12,14 @@ Keys:
...
@@ -11,11 +12,14 @@ Keys:
ESC - exit
ESC - exit
'''
'''
import
numpy
as
np
import
cv2
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
import
sys
import
sys
try
:
fn
=
sys
.
argv
[
1
]
try
:
fn
=
sys
.
argv
[
1
]
except
:
fn
=
'../cpp/fruits.jpg'
except
:
fn
=
'../cpp/fruits.jpg'
print
help_message
print
__doc__
img
=
cv2
.
imread
(
fn
,
True
)
img
=
cv2
.
imread
(
fn
,
True
)
h
,
w
=
img
.
shape
[:
2
]
h
,
w
=
img
.
shape
[:
2
]
...
...
samples/python2/inpaint.py
View file @
d9185ec2
import
numpy
as
np
'''
import
cv2
Inpainting sample.
from
common
import
Sketcher
Inpainting repairs damage to images by floodfilling
the damage with surrounding image areas.
help_message
=
'''USAGE: inpaint.py [<image>]
Usage:
inpaint.py [<image>]
Keys:
Keys:
SPACE - inpaint
SPACE - inpaint
...
@@ -10,11 +13,15 @@ Keys:
...
@@ -10,11 +13,15 @@ Keys:
ESC - exit
ESC - exit
'''
'''
import
numpy
as
np
import
cv2
from
common
import
Sketcher
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
import
sys
import
sys
try
:
fn
=
sys
.
argv
[
1
]
try
:
fn
=
sys
.
argv
[
1
]
except
:
fn
=
'../cpp/fruits.jpg'
except
:
fn
=
'../cpp/fruits.jpg'
print
help_message
print
__doc__
img
=
cv2
.
imread
(
fn
)
img
=
cv2
.
imread
(
fn
)
img_mark
=
img
.
copy
()
img_mark
=
img
.
copy
()
...
...
samples/python2/morphology.py
View file @
d9185ec2
'''
Morphology operations.
Usage:
morphology.py [<image>]
Keys:
1 - change operation
2 - change structure element shape
ESC - exit
'''
import
numpy
as
np
import
numpy
as
np
import
cv2
import
cv2
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
print
__doc__
import
sys
import
sys
from
itertools
import
cycle
from
itertools
import
cycle
from
common
import
draw_str
from
common
import
draw_str
...
@@ -44,10 +58,6 @@ if __name__ == '__main__':
...
@@ -44,10 +58,6 @@ if __name__ == '__main__':
cv2
.
createTrackbar
(
'op/size'
,
'morphology'
,
12
,
20
,
update
)
cv2
.
createTrackbar
(
'op/size'
,
'morphology'
,
12
,
20
,
update
)
cv2
.
createTrackbar
(
'iters'
,
'morphology'
,
1
,
10
,
update
)
cv2
.
createTrackbar
(
'iters'
,
'morphology'
,
1
,
10
,
update
)
update
()
update
()
print
"Controls:"
print
" 1 - change operation"
print
" 2 - change structure element shape"
print
while
True
:
while
True
:
ch
=
0xFF
&
cv2
.
waitKey
()
ch
=
0xFF
&
cv2
.
waitKey
()
if
ch
==
27
:
if
ch
==
27
:
...
...
samples/python2/squares.py
View file @
d9185ec2
'''
Simple "Square Detector" program.
Loads several images sequentially and tries to find squares in each image.
'''
import
numpy
as
np
import
numpy
as
np
import
cv2
import
cv2
...
...
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