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
619e503d
Commit
619e503d
authored
Jun 13, 2011
by
Alexander Mordvintsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
calibrate.py added (broken)
work on video synth
parent
6f26c55f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
0 deletions
+80
-0
calibrate.py
samples/python2/calibrate.py
+64
-0
video.py
samples/python2/video.py
+16
-0
No files found.
samples/python2/calibrate.py
0 → 100644
View file @
619e503d
import
numpy
as
np
import
cv2
,
cv
import
os
USAGE
=
'''
USAGE: calib.py [--save <filename>] [--debug <output path>] [<image mask>]
'''
class
Bunch
:
def
__init__
(
self
,
**
kwds
):
self
.
__dict__
.
update
(
kwds
)
def
splitfn
(
fn
):
path
,
fn
=
os
.
path
.
split
(
fn
)
name
,
ext
=
os
.
path
.
splitext
(
fn
)
return
path
,
name
,
ext
if
__name__
==
'__main__'
:
import
sys
,
getopt
from
glob
import
glob
args
,
img_mask
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
''
,
[
'save='
,
'debug='
])
args
=
dict
(
args
)
try
:
img_mask
=
img_mask
[
0
]
except
:
img_mask
=
'../cpp/left*.jpg'
img_names
=
glob
(
img_mask
)
try
:
debug_dir
=
args
[
'--debug'
]
except
:
debug_dir
=
None
pattern_size
=
(
9
,
6
)
pattern_points
=
np
.
zeros
(
(
np
.
prod
(
pattern_size
),
3
),
np
.
float32
)
pattern_points
[:,:
2
]
=
np
.
indices
(
pattern_size
)
.
T
.
reshape
(
-
1
,
2
)
obj_points
=
[]
img_points
=
[]
h
,
w
=
0
,
0
for
fn
in
img_names
:
print
'processing
%
s...'
%
fn
,
img
=
cv2
.
imread
(
fn
,
0
)
h
,
w
=
img
.
shape
[:
2
]
found
,
corners
=
cv2
.
findChessboardCorners
(
img
,
pattern_size
)
if
found
:
term
=
(
cv2
.
TERM_CRITERIA_EPS
+
cv2
.
TERM_CRITERIA_COUNT
,
30
,
0.1
)
cv2
.
cornerSubPix
(
img
,
corners
,
(
11
,
11
),
(
-
1
,
-
1
),
term
)
if
debug_dir
:
vis
=
cv2
.
cvtColor
(
img
,
cv
.
CV_GRAY2BGR
)
cv2
.
drawChessboardCorners
(
vis
,
pattern_size
,
corners
,
found
)
path
,
name
,
ext
=
splitfn
(
fn
)
cv2
.
imwrite
(
'
%
s/
%
s_chess.bmp'
%
(
debug_dir
,
name
),
vis
)
if
not
found
:
print
'chessboard not found'
break
img_points
.
append
(
corners
.
reshape
(
-
1
,
2
))
obj_points
.
append
(
pattern_points
)
print
'ok'
camera_matrix
=
np
.
zeros
((
3
,
3
))
dist_coefs
=
np
.
zeros
(
4
)
rms
=
cv2
.
calibrateCamera
(
obj_points
,
img_points
,
(
w
,
h
),
camera_matrix
,
dist_coefs
)
print
rms
\ No newline at end of file
samples/python2/video.py
View file @
619e503d
import
numpy
as
np
import
cv2
from
time
import
clock
def
lookat
(
cam_pos
,
target_pos
,
up
=
()):
dp
=
cam_pos
-
target_pos
class
VideoSynth
(
object
):
def
__init__
(
self
,
size
=
None
,
noise
=
0.0
,
bg
=
None
,
**
params
):
...
...
@@ -17,6 +21,15 @@ class VideoSynth(object):
self
.
noise
=
float
(
noise
)
w
,
h
=
self
.
frame_size
self
.
K
=
np
.
float64
([[
1.0
/
w
,
0.0
,
0.5
*
(
w
-
1
)],
[
0.0
,
1.0
/
w
,
0.5
*
(
h
-
1
)],
[
0.0
,
0.0
,
1.0
]])
def
draw_layers
(
self
,
dst
):
pass
def
read
(
self
,
dst
=
None
):
w
,
h
=
self
.
frame_size
...
...
@@ -24,6 +37,9 @@ class VideoSynth(object):
buf
=
np
.
zeros
((
h
,
w
,
3
),
np
.
uint8
)
else
:
buf
=
self
.
bg
.
copy
()
self
.
draw_layers
(
buf
)
if
self
.
noise
>
0.0
:
noise
=
np
.
zeros
((
h
,
w
,
3
),
np
.
int8
)
cv2
.
randn
(
noise
,
np
.
zeros
(
3
),
np
.
ones
(
3
)
*
255
*
self
.
noise
)
...
...
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