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
df57d038
Commit
df57d038
authored
Jan 15, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3572 from berak:python_samples_30
parents
713aa5c5
fd60e98c
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
27 additions
and
26 deletions
+27
-26
features2d.hpp
modules/features2d/include/opencv2/features2d.hpp
+1
-1
calibrate.py
samples/python2/calibrate.py
+1
-1
deconvolution.py
samples/python2/deconvolution.py
+1
-1
digits_video.py
samples/python2/digits_video.py
+1
-1
edge.py
samples/python2/edge.py
+1
-1
find_obj.py
samples/python2/find_obj.py
+7
-5
fitline.py
samples/python2/fitline.py
+1
-1
lappyr.py
samples/python2/lappyr.py
+1
-1
mosse.py
samples/python2/mosse.py
+1
-1
mser.py
samples/python2/mser.py
+2
-2
plane_ar.py
samples/python2/plane_ar.py
+1
-1
plane_tracker.py
samples/python2/plane_tracker.py
+2
-2
squares.py
samples/python2/squares.py
+1
-1
stereo_match.py
samples/python2/stereo_match.py
+6
-7
No files found.
modules/features2d/include/opencv2/features2d.hpp
View file @
df57d038
...
@@ -337,7 +337,7 @@ public:
...
@@ -337,7 +337,7 @@ public:
double
_min_margin
=
0.003
,
int
_edge_blur_size
=
5
);
double
_min_margin
=
0.003
,
int
_edge_blur_size
=
5
);
CV_WRAP
virtual
void
detectRegions
(
InputArray
image
,
CV_WRAP
virtual
void
detectRegions
(
InputArray
image
,
std
::
vector
<
std
::
vector
<
Point
>
>&
msers
,
CV_OUT
std
::
vector
<
std
::
vector
<
Point
>
>&
msers
,
std
::
vector
<
Rect
>&
bboxes
)
=
0
;
std
::
vector
<
Rect
>&
bboxes
)
=
0
;
CV_WRAP
virtual
void
setDelta
(
int
delta
)
=
0
;
CV_WRAP
virtual
void
setDelta
(
int
delta
)
=
0
;
...
...
samples/python2/calibrate.py
View file @
df57d038
...
@@ -26,7 +26,7 @@ if __name__ == '__main__':
...
@@ -26,7 +26,7 @@ if __name__ == '__main__':
try
:
try
:
img_mask
=
img_mask
[
0
]
img_mask
=
img_mask
[
0
]
except
:
except
:
img_mask
=
'../
cpp
/left*.jpg'
img_mask
=
'../
data
/left*.jpg'
img_names
=
glob
(
img_mask
)
img_names
=
glob
(
img_mask
)
debug_dir
=
args
.
get
(
'--debug'
)
debug_dir
=
args
.
get
(
'--debug'
)
...
...
samples/python2/deconvolution.py
View file @
df57d038
...
@@ -119,7 +119,7 @@ if __name__ == '__main__':
...
@@ -119,7 +119,7 @@ if __name__ == '__main__':
update
(
None
)
update
(
None
)
while
True
:
while
True
:
ch
=
cv2
.
waitKey
()
ch
=
cv2
.
waitKey
()
&
0xFF
if
ch
==
27
:
if
ch
==
27
:
break
break
if
ch
==
ord
(
' '
):
if
ch
==
ord
(
' '
):
...
...
samples/python2/digits_video.py
View file @
df57d038
...
@@ -86,7 +86,7 @@ def main():
...
@@ -86,7 +86,7 @@ def main():
cv2
.
imshow
(
'frame'
,
frame
)
cv2
.
imshow
(
'frame'
,
frame
)
cv2
.
imshow
(
'bin'
,
bin
)
cv2
.
imshow
(
'bin'
,
bin
)
ch
=
cv2
.
waitKey
(
1
)
ch
=
cv2
.
waitKey
(
1
)
&
0xFF
if
ch
==
27
:
if
ch
==
27
:
break
break
...
...
samples/python2/edge.py
View file @
df57d038
...
@@ -45,7 +45,7 @@ if __name__ == '__main__':
...
@@ -45,7 +45,7 @@ if __name__ == '__main__':
vis
/=
2
vis
/=
2
vis
[
edge
!=
0
]
=
(
0
,
255
,
0
)
vis
[
edge
!=
0
]
=
(
0
,
255
,
0
)
cv2
.
imshow
(
'edge'
,
vis
)
cv2
.
imshow
(
'edge'
,
vis
)
ch
=
cv2
.
waitKey
(
5
)
ch
=
cv2
.
waitKey
(
5
)
&
0xFF
if
ch
==
27
:
if
ch
==
27
:
break
break
cv2
.
destroyAllWindows
()
cv2
.
destroyAllWindows
()
samples/python2/find_obj.py
View file @
df57d038
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
'''
'''
Feature-based image matching sample.
Feature-based image matching sample.
Note, that you will need the https://github.com/Itseez/opencv_contrib repo for SIFT and SURF
USAGE
USAGE
find_obj.py [--feature=<sift|surf|orb|akaze|brisk>[-flann]] [ <image1> <image2> ]
find_obj.py [--feature=<sift|surf|orb|akaze|brisk>[-flann]] [ <image1> <image2> ]
...
@@ -23,19 +25,19 @@ FLANN_INDEX_LSH = 6
...
@@ -23,19 +25,19 @@ FLANN_INDEX_LSH = 6
def
init_feature
(
name
):
def
init_feature
(
name
):
chunks
=
name
.
split
(
'-'
)
chunks
=
name
.
split
(
'-'
)
if
chunks
[
0
]
==
'sift'
:
if
chunks
[
0
]
==
'sift'
:
detector
=
cv2
.
xfeatures2d
.
SIFT
()
detector
=
cv2
.
xfeatures2d
.
SIFT
_create
()
norm
=
cv2
.
NORM_L2
norm
=
cv2
.
NORM_L2
elif
chunks
[
0
]
==
'surf'
:
elif
chunks
[
0
]
==
'surf'
:
detector
=
cv2
.
xfeatures2d
.
SURF
(
800
)
detector
=
cv2
.
xfeatures2d
.
SURF
_create
(
800
)
norm
=
cv2
.
NORM_L2
norm
=
cv2
.
NORM_L2
elif
chunks
[
0
]
==
'orb'
:
elif
chunks
[
0
]
==
'orb'
:
detector
=
cv2
.
ORB
(
400
)
detector
=
cv2
.
ORB
_create
(
400
)
norm
=
cv2
.
NORM_HAMMING
norm
=
cv2
.
NORM_HAMMING
elif
chunks
[
0
]
==
'akaze'
:
elif
chunks
[
0
]
==
'akaze'
:
detector
=
cv2
.
AKAZE
()
detector
=
cv2
.
AKAZE
_create
()
norm
=
cv2
.
NORM_HAMMING
norm
=
cv2
.
NORM_HAMMING
elif
chunks
[
0
]
==
'brisk'
:
elif
chunks
[
0
]
==
'brisk'
:
detector
=
cv2
.
BRISK
()
detector
=
cv2
.
BRISK
_create
()
norm
=
cv2
.
NORM_HAMMING
norm
=
cv2
.
NORM_HAMMING
else
:
else
:
return
None
,
None
return
None
,
None
...
...
samples/python2/fitline.py
View file @
df57d038
...
@@ -79,7 +79,7 @@ if __name__ == '__main__':
...
@@ -79,7 +79,7 @@ if __name__ == '__main__':
cv2
.
createTrackbar
(
'outlier
%
'
,
'fit line'
,
30
,
100
,
update
)
cv2
.
createTrackbar
(
'outlier
%
'
,
'fit line'
,
30
,
100
,
update
)
while
True
:
while
True
:
update
()
update
()
ch
=
cv2
.
waitKey
(
0
)
ch
=
cv2
.
waitKey
(
0
)
&
0xFF
if
ch
==
ord
(
'f'
):
if
ch
==
ord
(
'f'
):
cur_func_name
=
dist_func_names
.
next
()
cur_func_name
=
dist_func_names
.
next
()
if
ch
==
27
:
if
ch
==
27
:
...
...
samples/python2/lappyr.py
View file @
df57d038
...
@@ -62,5 +62,5 @@ if __name__ == '__main__':
...
@@ -62,5 +62,5 @@ if __name__ == '__main__':
cv2
.
imshow
(
'laplacian pyramid filter'
,
res
)
cv2
.
imshow
(
'laplacian pyramid filter'
,
res
)
if
cv2
.
waitKey
(
1
)
==
27
:
if
cv2
.
waitKey
(
1
)
&
0xFF
==
27
:
break
break
samples/python2/mosse.py
View file @
df57d038
...
@@ -168,7 +168,7 @@ class App:
...
@@ -168,7 +168,7 @@ class App:
self
.
rect_sel
.
draw
(
vis
)
self
.
rect_sel
.
draw
(
vis
)
cv2
.
imshow
(
'frame'
,
vis
)
cv2
.
imshow
(
'frame'
,
vis
)
ch
=
cv2
.
waitKey
(
10
)
ch
=
cv2
.
waitKey
(
10
)
&
0xFF
if
ch
==
27
:
if
ch
==
27
:
break
break
if
ch
==
ord
(
' '
):
if
ch
==
ord
(
' '
):
...
...
samples/python2/mser.py
View file @
df57d038
...
@@ -26,13 +26,13 @@ if __name__ == '__main__':
...
@@ -26,13 +26,13 @@ if __name__ == '__main__':
video_src
=
0
video_src
=
0
cam
=
video
.
create_capture
(
video_src
)
cam
=
video
.
create_capture
(
video_src
)
mser
=
cv2
.
MSER
()
mser
=
cv2
.
MSER
_create
()
while
True
:
while
True
:
ret
,
img
=
cam
.
read
()
ret
,
img
=
cam
.
read
()
gray
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2GRAY
)
gray
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2GRAY
)
vis
=
img
.
copy
()
vis
=
img
.
copy
()
regions
=
mser
.
detect
(
gray
,
None
)
regions
=
mser
.
detect
Regions
(
gray
,
None
)
hulls
=
[
cv2
.
convexHull
(
p
.
reshape
(
-
1
,
1
,
2
))
for
p
in
regions
]
hulls
=
[
cv2
.
convexHull
(
p
.
reshape
(
-
1
,
1
,
2
))
for
p
in
regions
]
cv2
.
polylines
(
vis
,
hulls
,
1
,
(
0
,
255
,
0
))
cv2
.
polylines
(
vis
,
hulls
,
1
,
(
0
,
255
,
0
))
...
...
samples/python2/plane_ar.py
View file @
df57d038
...
@@ -71,7 +71,7 @@ class App:
...
@@ -71,7 +71,7 @@ class App:
self
.
rect_sel
.
draw
(
vis
)
self
.
rect_sel
.
draw
(
vis
)
cv2
.
imshow
(
'plane'
,
vis
)
cv2
.
imshow
(
'plane'
,
vis
)
ch
=
cv2
.
waitKey
(
1
)
ch
=
cv2
.
waitKey
(
1
)
&
0xFF
if
ch
==
ord
(
' '
):
if
ch
==
ord
(
' '
):
self
.
paused
=
not
self
.
paused
self
.
paused
=
not
self
.
paused
if
ch
==
ord
(
'c'
):
if
ch
==
ord
(
'c'
):
...
...
samples/python2/plane_tracker.py
View file @
df57d038
...
@@ -61,7 +61,7 @@ TrackedTarget = namedtuple('TrackedTarget', 'target, p0, p1, H, quad')
...
@@ -61,7 +61,7 @@ TrackedTarget = namedtuple('TrackedTarget', 'target, p0, p1, H, quad')
class
PlaneTracker
:
class
PlaneTracker
:
def
__init__
(
self
):
def
__init__
(
self
):
self
.
detector
=
cv2
.
ORB
(
nfeatures
=
1000
)
self
.
detector
=
cv2
.
ORB
_create
(
nfeatures
=
1000
)
self
.
matcher
=
cv2
.
FlannBasedMatcher
(
flann_params
,
{})
# bug : need to pass empty dict (#1329)
self
.
matcher
=
cv2
.
FlannBasedMatcher
(
flann_params
,
{})
# bug : need to pass empty dict (#1329)
self
.
targets
=
[]
self
.
targets
=
[]
...
@@ -160,7 +160,7 @@ class App:
...
@@ -160,7 +160,7 @@ class App:
self
.
rect_sel
.
draw
(
vis
)
self
.
rect_sel
.
draw
(
vis
)
cv2
.
imshow
(
'plane'
,
vis
)
cv2
.
imshow
(
'plane'
,
vis
)
ch
=
cv2
.
waitKey
(
1
)
ch
=
cv2
.
waitKey
(
1
)
&
0xFF
if
ch
==
ord
(
' '
):
if
ch
==
ord
(
' '
):
self
.
paused
=
not
self
.
paused
self
.
paused
=
not
self
.
paused
if
ch
==
ord
(
'c'
):
if
ch
==
ord
(
'c'
):
...
...
samples/python2/squares.py
View file @
df57d038
...
@@ -37,7 +37,7 @@ def find_squares(img):
...
@@ -37,7 +37,7 @@ def find_squares(img):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
from
glob
import
glob
from
glob
import
glob
for
fn
in
glob
(
'../
cpp
/pic*.png'
):
for
fn
in
glob
(
'../
data
/pic*.png'
):
img
=
cv2
.
imread
(
fn
)
img
=
cv2
.
imread
(
fn
)
squares
=
find_squares
(
img
)
squares
=
find_squares
(
img
)
cv2
.
drawContours
(
img
,
squares
,
-
1
,
(
0
,
255
,
0
),
3
)
cv2
.
drawContours
(
img
,
squares
,
-
1
,
(
0
,
255
,
0
),
3
)
...
...
samples/python2/stereo_match.py
View file @
df57d038
...
@@ -39,16 +39,15 @@ if __name__ == '__main__':
...
@@ -39,16 +39,15 @@ if __name__ == '__main__':
window_size
=
3
window_size
=
3
min_disp
=
16
min_disp
=
16
num_disp
=
112
-
min_disp
num_disp
=
112
-
min_disp
stereo
=
cv2
.
StereoSGBM
(
minDisparity
=
min_disp
,
stereo
=
cv2
.
StereoSGBM
_create
(
minDisparity
=
min_disp
,
numDisparities
=
num_disp
,
numDisparities
=
num_disp
,
SADWindowSize
=
window_size
,
blockSize
=
16
,
uniquenessRatio
=
10
,
speckleWindowSize
=
100
,
speckleRange
=
32
,
disp12MaxDiff
=
1
,
P1
=
8
*
3
*
window_size
**
2
,
P1
=
8
*
3
*
window_size
**
2
,
P2
=
32
*
3
*
window_size
**
2
,
P2
=
32
*
3
*
window_size
**
2
,
fullDP
=
False
disp12MaxDiff
=
1
,
uniquenessRatio
=
10
,
speckleWindowSize
=
100
,
speckleRange
=
32
)
)
print
'computing disparity...'
print
'computing disparity...'
...
...
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