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
fbed33cc
Commit
fbed33cc
authored
Mar 21, 2019
by
Alexander Alekhin
Committed by
Alexander Alekhin
Mar 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
samples: fix python samples compatibility with demo.py
parent
a509ec0d
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
13 deletions
+36
-13
dis_opt_flow.py
samples/python/dis_opt_flow.py
+9
-1
stitching.py
samples/python/stitching.py
+27
-12
stitching_detailed.py
samples/python/stitching_detailed.py
+0
-0
No files found.
samples/python/dis_opt_flow.py
View file @
fbed33cc
...
@@ -18,6 +18,7 @@ from __future__ import print_function
...
@@ -18,6 +18,7 @@ from __future__ import print_function
import
numpy
as
np
import
numpy
as
np
import
cv2
as
cv
import
cv2
as
cv
import
video
import
video
...
@@ -56,7 +57,7 @@ def warp_flow(img, flow):
...
@@ -56,7 +57,7 @@ def warp_flow(img, flow):
return
res
return
res
if
__name__
==
'__main__'
:
def
main
()
:
import
sys
import
sys
print
(
__doc__
)
print
(
__doc__
)
try
:
try
:
...
@@ -111,4 +112,11 @@ if __name__ == '__main__':
...
@@ -111,4 +112,11 @@ if __name__ == '__main__':
if
ch
==
ord
(
'4'
):
if
ch
==
ord
(
'4'
):
use_temporal_propagation
=
not
use_temporal_propagation
use_temporal_propagation
=
not
use_temporal_propagation
print
(
'temporal propagation is'
,
[
'off'
,
'on'
][
use_temporal_propagation
])
print
(
'temporal propagation is'
,
[
'off'
,
'on'
][
use_temporal_propagation
])
print
(
'Done'
)
if
__name__
==
'__main__'
:
print
(
__doc__
)
main
()
cv
.
destroyAllWindows
()
cv
.
destroyAllWindows
()
samples/python/stitching.py
View file @
fbed33cc
...
@@ -8,15 +8,18 @@ Show how to use Stitcher API from python in a simple way to stitch panoramas
...
@@ -8,15 +8,18 @@ Show how to use Stitcher API from python in a simple way to stitch panoramas
or scans.
or scans.
'''
'''
# Python 2/3 compatibility
from
__future__
import
print_function
from
__future__
import
print_function
import
cv2
as
cv
import
numpy
as
np
import
numpy
as
np
import
cv2
as
cv
import
argparse
import
argparse
import
sys
import
sys
modes
=
(
cv
.
Stitcher_PANORAMA
,
cv
.
Stitcher_SCANS
)
modes
=
(
cv
.
Stitcher_PANORAMA
,
cv
.
Stitcher_SCANS
)
parser
=
argparse
.
ArgumentParser
(
description
=
'Stitching sample.'
)
parser
=
argparse
.
ArgumentParser
(
prog
=
'stitching.py'
,
description
=
'Stitching sample.'
)
parser
.
add_argument
(
'--mode'
,
parser
.
add_argument
(
'--mode'
,
type
=
int
,
choices
=
modes
,
default
=
cv
.
Stitcher_PANORAMA
,
type
=
int
,
choices
=
modes
,
default
=
cv
.
Stitcher_PANORAMA
,
help
=
'Determines configuration of stitcher. The default is `PANORAMA` (
%
d), '
help
=
'Determines configuration of stitcher. The default is `PANORAMA` (
%
d), '
...
@@ -25,23 +28,35 @@ parser.add_argument('--mode',
...
@@ -25,23 +28,35 @@ parser.add_argument('--mode',
parser
.
add_argument
(
'--output'
,
default
=
'result.jpg'
,
parser
.
add_argument
(
'--output'
,
default
=
'result.jpg'
,
help
=
'Resulting image. The default is `result.jpg`.'
)
help
=
'Resulting image. The default is `result.jpg`.'
)
parser
.
add_argument
(
'img'
,
nargs
=
'+'
,
help
=
'input images'
)
parser
.
add_argument
(
'img'
,
nargs
=
'+'
,
help
=
'input images'
)
args
=
parser
.
parse_args
()
# read input images
__doc__
+=
'
\n
'
+
parser
.
format_help
()
imgs
=
[]
for
img_name
in
args
.
img
:
def
main
():
img
=
cv
.
imread
(
img_name
)
args
=
parser
.
parse_args
()
# read input images
imgs
=
[]
for
img_name
in
args
.
img
:
img
=
cv
.
imread
(
cv
.
samples
.
findFile
(
img_name
))
if
img
is
None
:
if
img
is
None
:
print
(
"can't read image "
+
img_name
)
print
(
"can't read image "
+
img_name
)
sys
.
exit
(
-
1
)
sys
.
exit
(
-
1
)
imgs
.
append
(
img
)
imgs
.
append
(
img
)
stitcher
=
cv
.
Stitcher
.
create
(
args
.
mode
)
stitcher
=
cv
.
Stitcher
.
create
(
args
.
mode
)
status
,
pano
=
stitcher
.
stitch
(
imgs
)
status
,
pano
=
stitcher
.
stitch
(
imgs
)
if
status
!=
cv
.
Stitcher_OK
:
if
status
!=
cv
.
Stitcher_OK
:
print
(
"Can't stitch images, error code =
%
d"
%
status
)
print
(
"Can't stitch images, error code =
%
d"
%
status
)
sys
.
exit
(
-
1
)
sys
.
exit
(
-
1
)
cv
.
imwrite
(
args
.
output
,
pano
);
cv
.
imwrite
(
args
.
output
,
pano
);
print
(
"stitching completed successfully.
%
s saved!"
%
args
.
output
)
print
(
"stitching completed successfully.
%
s saved!"
%
args
.
output
)
print
(
'Done'
)
if
__name__
==
'__main__'
:
print
(
__doc__
)
main
()
cv
.
destroyAllWindows
()
samples/python/stitching_detailed.py
View file @
fbed33cc
This diff is collapsed.
Click to expand it.
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