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
6977a895
Commit
6977a895
authored
Jul 02, 2012
by
Alexander Mordvintsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
descriptions for watershed.py and video.py
parent
d015bf6f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
15 deletions
+54
-15
fitline.py
samples/python2/fitline.py
+2
-0
video.py
samples/python2/video.py
+31
-7
watershed.py
samples/python2/watershed.py
+21
-8
No files found.
samples/python2/fitline.py
View file @
6977a895
...
...
@@ -63,6 +63,8 @@ def update(_=None):
cv2
.
imshow
(
'fit line'
,
img
)
if
__name__
==
'__main__'
:
print
__doc__
cv2
.
namedWindow
(
'fit line'
)
cv2
.
createTrackbar
(
'noise'
,
'fit line'
,
3
,
50
,
update
)
cv2
.
createTrackbar
(
'point n'
,
'fit line'
,
100
,
500
,
update
)
...
...
samples/python2/video.py
View file @
6977a895
'''
Video capture sample.
Sample shows how VideoCapture class can be used to acquire video
frames from a camera of a movie file. Also the sample provides
an example of procedural video generation by an object, mimicking
the VideoCapture interface (see Chess class).
'create_capture' is a convinience function for capture creation,
falling back to procedural video in case of error.
Usage:
video.py [--shotdir <shot path>] [source0] [source1] ...'
sourceN is an
- integer number for camera capture
- name of video file
- synth:<params> for procedural video
Synth examples:
synth:bg=../cpp/lena.jpg:noise=0.1
synth:class=chess:bg=../cpp/lena.jpg:noise=0.1:size=640x480
Keys:
ESC - exit
SPACE - save current frame to <shot path> directory
'''
import
numpy
as
np
import
cv2
from
time
import
clock
...
...
@@ -100,8 +129,7 @@ presets = dict(
def
create_capture
(
source
=
0
,
fallback
=
presets
[
'chess'
]):
'''
source: <int> or '<int>|<filename>|synth [:<param_name>=<value> [:...]]'
'''source: <int> or '<int>|<filename>|synth [:<param_name>=<value> [:...]]'
'''
source
=
str
(
source
)
.
strip
()
chunks
=
source
.
split
(
':'
)
...
...
@@ -136,9 +164,7 @@ if __name__ == '__main__':
import
sys
import
getopt
print
'USAGE: video.py [--shotdir <dir>] [source0] [source1] ...'
print
"source: '<int>' or '<filename>' or 'synth:<params>'"
print
print
__doc__
args
,
sources
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
''
,
'shotdir='
)
args
=
dict
(
args
)
...
...
@@ -146,8 +172,6 @@ if __name__ == '__main__':
if
len
(
sources
)
==
0
:
sources
=
[
0
]
print
'Press SPACE to save current frame'
caps
=
map
(
create_capture
,
sources
)
shot_idx
=
0
while
True
:
...
...
samples/python2/watershed.py
View file @
6977a895
import
numpy
as
np
import
cv2
from
common
import
Sketcher
'''
Watershed segmentation
=========
This program demonstrates the watershed segmentation algorithm
in OpenCV: watershed().
help_message
=
'''
USAGE: watershed.py [<image>]
Usage
-----
watershed.py [image filename]
Use keys 1 - 7 to switch marker color
Keys
----
1-7 - switch marker color
SPACE - update segmentation
r - reset
a -
switch
autoupdate
a -
toggle
autoupdate
ESC - exit
'''
import
numpy
as
np
import
cv2
from
common
import
Sketcher
class
App
:
def
__init__
(
self
,
fn
):
self
.
img
=
cv2
.
imread
(
fn
)
...
...
@@ -60,5 +73,5 @@ if __name__ == '__main__':
import
sys
try
:
fn
=
sys
.
argv
[
1
]
except
:
fn
=
'../cpp/fruits.jpg'
print
help_message
print
__doc__
App
(
fn
)
.
run
()
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