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
386f1475
Commit
386f1475
authored
Jul 13, 2011
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a few minor fixes in Python samples
parent
f098d989
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
9 deletions
+17
-9
find_obj.py
samples/python2/find_obj.py
+10
-3
gaussian_mix.py
samples/python2/gaussian_mix.py
+2
-2
inpaint.py
samples/python2/inpaint.py
+2
-2
opt_flow.py
samples/python2/opt_flow.py
+2
-1
watershed.py
samples/python2/watershed.py
+1
-1
No files found.
samples/python2/find_obj.py
View file @
386f1475
...
...
@@ -37,10 +37,17 @@ def draw_match(img1, img2, p1, p2, status = None, H = None):
red
=
(
0
,
0
,
255
)
for
(
x1
,
y1
),
(
x2
,
y2
),
inlier
in
zip
(
np
.
int32
(
p1
),
np
.
int32
(
p2
),
status
):
col
=
[
red
,
green
][
inlier
]
if
not
inlier
:
if
inlier
:
cv2
.
line
(
vis
,
(
x1
,
y1
),
(
x2
+
w1
,
y2
),
col
)
cv2
.
circle
(
vis
,
(
x1
,
y1
),
2
,
col
,
-
1
)
cv2
.
circle
(
vis
,
(
x2
+
w1
,
y2
),
2
,
col
,
-
1
)
cv2
.
circle
(
vis
,
(
x1
,
y1
),
2
,
col
,
-
1
)
cv2
.
circle
(
vis
,
(
x2
+
w1
,
y2
),
2
,
col
,
-
1
)
else
:
r
=
2
thickness
=
3
cv2
.
line
(
vis
,
(
x1
-
r
,
y1
-
r
),
(
x1
+
r
,
y1
+
r
),
col
,
thickness
)
cv2
.
line
(
vis
,
(
x1
-
r
,
y1
+
r
),
(
x1
+
r
,
y1
-
r
),
col
,
thickness
)
cv2
.
line
(
vis
,
(
x2
+
w1
-
r
,
y2
-
r
),
(
x2
+
w1
+
r
,
y2
+
r
),
col
,
thickness
)
cv2
.
line
(
vis
,
(
x2
+
w1
-
r
,
y2
+
r
),
(
x2
+
w1
+
r
,
y2
-
r
),
col
,
thickness
)
return
vis
if
__name__
==
'__main__'
:
...
...
samples/python2/gaussian_mix.py
View file @
386f1475
import
numpy
as
np
import
math
from
numpy
import
random
import
cv2
def
make_gaussians
(
cluster_n
,
img_size
):
points
=
[]
ref_distrs
=
[]
...
...
@@ -20,7 +20,7 @@ def make_gaussians(cluster_n, img_size):
def
draw_gaussain
(
img
,
mean
,
cov
,
color
):
x
,
y
=
np
.
int32
(
mean
)
w
,
u
,
vt
=
cv2
.
SVDecomp
(
cov
)
ang
=
np
.
rad2deg
(
np
.
arctan2
(
u
[
1
,
0
],
u
[
0
,
0
])
)
ang
=
np
.
arctan2
(
u
[
1
,
0
],
u
[
0
,
0
])
*
(
180
/
math
.
pi
)
s1
,
s2
=
np
.
sqrt
(
w
)
*
3.0
cv2
.
ellipse
(
img
,
(
x
,
y
),
(
s1
,
s2
),
ang
,
0
,
360
,
color
,
1
,
cv2
.
CV_AA
)
...
...
samples/python2/inpaint.py
View file @
386f1475
...
...
@@ -5,8 +5,8 @@ from common import Sketcher
help_message
=
'''USAGE: inpaint.py [<image>]
Keys:
SPACE -
update
inpaint
r - res
tore image
SPACE - inpaint
r - res
et the inpainting mask
ESC - exit
'''
...
...
samples/python2/opt_flow.py
View file @
386f1475
import
numpy
as
np
import
math
import
cv2
,
cv
import
video
...
...
@@ -29,7 +30,7 @@ def draw_hsv(flow):
ang
=
np
.
arctan2
(
fy
,
fx
)
+
np
.
pi
v
=
np
.
sqrt
(
fx
*
fx
+
fy
*
fy
)
hsv
=
np
.
zeros
((
h
,
w
,
3
),
np
.
uint8
)
hsv
[
...
,
0
]
=
np
.
rad2deg
(
ang
)
/
2
hsv
[
...
,
0
]
=
ang
*
(
180
/
math
.
pi
/
2
)
hsv
[
...
,
1
]
=
255
hsv
[
...
,
2
]
=
np
.
minimum
(
v
*
4
,
255
)
bgr
=
cv2
.
cvtColor
(
hsv
,
cv
.
CV_HSV2BGR
)
...
...
samples/python2/watershed.py
View file @
386f1475
...
...
@@ -51,7 +51,7 @@ class App:
print
'auto_update if'
,
[
'off'
,
'on'
][
self
.
auto_update
]
if
ch
in
[
ord
(
'r'
),
ord
(
'R'
)]:
self
.
markers
[:]
=
0
self
.
markers_vis
[:]
=
self
.
img
self
.
markers_vis
[:]
=
self
.
img
.
copy
()
self
.
sketch
.
show
()
...
...
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