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
19450639
Commit
19450639
authored
Jun 14, 2011
by
Alexander Mordvintsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python helper routines (common.py) added
parent
d22b9475
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
2 deletions
+74
-2
calibrate.py
samples/python2/calibrate.py
+1
-2
common.py
samples/python2/common.py
+72
-0
video.py
samples/python2/video.py
+1
-0
No files found.
samples/python2/calibrate.py
View file @
19450639
...
@@ -26,8 +26,7 @@ if __name__ == '__main__':
...
@@ -26,8 +26,7 @@ if __name__ == '__main__':
try
:
img_mask
=
img_mask
[
0
]
try
:
img_mask
=
img_mask
[
0
]
except
:
img_mask
=
'../cpp/left*.jpg'
except
:
img_mask
=
'../cpp/left*.jpg'
img_names
=
glob
(
img_mask
)
img_names
=
glob
(
img_mask
)
try
:
debug_dir
=
args
[
'--debug'
]
debug_dir
=
args
.
get
(
'--debug'
)
except
:
debug_dir
=
None
pattern_size
=
(
9
,
6
)
pattern_size
=
(
9
,
6
)
pattern_points
=
np
.
zeros
(
(
np
.
prod
(
pattern_size
),
3
),
np
.
float32
)
pattern_points
=
np
.
zeros
(
(
np
.
prod
(
pattern_size
),
3
),
np
.
float32
)
...
...
samples/python2/common.py
0 → 100644
View file @
19450639
import
numpy
as
np
import
cv2
def
to_list
(
a
):
return
[
tuple
(
p
)
for
p
in
a
]
def
anorm2
(
a
):
return
(
a
*
a
)
.
sum
(
-
1
)
def
anorm
(
a
):
return
np
.
sqrt
(
anorm2
(
a
)
)
def
homotrans
(
H
,
x
,
y
):
xs
=
H
[
0
,
0
]
*
x
+
H
[
0
,
1
]
*
y
+
H
[
0
,
2
]
ys
=
H
[
1
,
0
]
*
x
+
H
[
1
,
1
]
*
y
+
H
[
1
,
2
]
s
=
H
[
2
,
0
]
*
x
+
H
[
2
,
1
]
*
y
+
H
[
2
,
2
]
return
xs
/
s
,
ys
/
s
def
to_rect
(
a
):
a
=
np
.
ravel
(
a
)
if
len
(
a
)
==
2
:
a
=
(
0
,
0
,
a
[
0
],
a
[
1
])
return
np
.
array
(
a
,
np
.
float64
)
.
reshape
(
2
,
2
)
def
rect2rect_mtx
(
src
,
dst
):
src
,
dst
=
to_rect
(
src
),
to_rect
(
dst
)
cx
,
cy
=
(
dst
[
1
]
-
dst
[
0
])
/
(
src
[
1
]
-
src
[
0
])
tx
,
ty
=
dst
[
0
]
-
src
[
0
]
*
(
cx
,
cy
)
M
=
np
.
float64
([[
cx
,
0
,
tx
],
[
0
,
cy
,
ty
],
[
0
,
0
,
1
]])
return
M
def
lookat
(
eye
,
target
,
up
=
(
0
,
0
,
1
)):
fwd
=
np
.
asarray
(
target
,
np
.
float64
)
-
eye
fwd
/=
anorm
(
fwd
)
right
=
np
.
cross
(
fwd
,
up
)
right
/=
anorm
(
right
)
down
=
np
.
cross
(
fwd
,
right
)
Rt
=
np
.
zeros
((
3
,
4
))
Rt
[:,:
3
]
=
[
right
,
down
,
fwd
]
Rt
[:,
3
]
=
-
np
.
dot
(
Rt
[:,:
3
],
eye
)
return
Rt
def
mtx2rvec
(
R
):
pass
if
__name__
==
'__main__'
:
import
cv2
from
time
import
clock
'''
w, h = 640, 480
while True:
img = np.zeros((h, w, 3), np.uint8)
t = clock()
eye = [5*cos(t), 5*sin(t), 3]
Rt = lookat(eye, [0, 0, 0])
'''
eye
=
[
1
,
-
4
,
3
]
target
=
[
0
,
0
,
0
]
Rt
=
lookat
(
eye
,
[
0
,
0
,
0
])
print
Rt
p
=
[
0
,
0
,
0
]
print
cv2
.
transform
(
np
.
float64
([[
p
]]),
Rt
)
print
cv2
.
SVDecomp
(
Rt
[:,:
3
])
samples/python2/video.py
View file @
19450639
...
@@ -64,6 +64,7 @@ def create_capture(source):
...
@@ -64,6 +64,7 @@ def create_capture(source):
presets
=
dict
(
presets
=
dict
(
empty
=
'synth:'
,
lena
=
'synth:bg=../cpp/lena.jpg:noise=0.1'
lena
=
'synth:bg=../cpp/lena.jpg:noise=0.1'
)
)
...
...
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