mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 05:06:29 +08:00
Merge pull request #3572 from berak:python_samples_30
This commit is contained in:
commit
df57d038b8
@ -337,7 +337,7 @@ public:
|
||||
double _min_margin=0.003, int _edge_blur_size=5 );
|
||||
|
||||
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;
|
||||
|
||||
CV_WRAP virtual void setDelta(int delta) = 0;
|
||||
|
@ -26,7 +26,7 @@ if __name__ == '__main__':
|
||||
try:
|
||||
img_mask = img_mask[0]
|
||||
except:
|
||||
img_mask = '../cpp/left*.jpg'
|
||||
img_mask = '../data/left*.jpg'
|
||||
|
||||
img_names = glob(img_mask)
|
||||
debug_dir = args.get('--debug')
|
||||
|
@ -119,7 +119,7 @@ if __name__ == '__main__':
|
||||
update(None)
|
||||
|
||||
while True:
|
||||
ch = cv2.waitKey()
|
||||
ch = cv2.waitKey() & 0xFF
|
||||
if ch == 27:
|
||||
break
|
||||
if ch == ord(' '):
|
||||
|
@ -86,7 +86,7 @@ def main():
|
||||
|
||||
cv2.imshow('frame', frame)
|
||||
cv2.imshow('bin', bin)
|
||||
ch = cv2.waitKey(1)
|
||||
ch = cv2.waitKey(1) & 0xFF
|
||||
if ch == 27:
|
||||
break
|
||||
|
||||
|
@ -45,7 +45,7 @@ if __name__ == '__main__':
|
||||
vis /= 2
|
||||
vis[edge != 0] = (0, 255, 0)
|
||||
cv2.imshow('edge', vis)
|
||||
ch = cv2.waitKey(5)
|
||||
ch = cv2.waitKey(5) & 0xFF
|
||||
if ch == 27:
|
||||
break
|
||||
cv2.destroyAllWindows()
|
||||
|
@ -3,6 +3,8 @@
|
||||
'''
|
||||
Feature-based image matching sample.
|
||||
|
||||
Note, that you will need the https://github.com/Itseez/opencv_contrib repo for SIFT and SURF
|
||||
|
||||
USAGE
|
||||
find_obj.py [--feature=<sift|surf|orb|akaze|brisk>[-flann]] [ <image1> <image2> ]
|
||||
|
||||
@ -23,19 +25,19 @@ FLANN_INDEX_LSH = 6
|
||||
def init_feature(name):
|
||||
chunks = name.split('-')
|
||||
if chunks[0] == 'sift':
|
||||
detector = cv2.xfeatures2d.SIFT()
|
||||
detector = cv2.xfeatures2d.SIFT_create()
|
||||
norm = cv2.NORM_L2
|
||||
elif chunks[0] == 'surf':
|
||||
detector = cv2.xfeatures2d.SURF(800)
|
||||
detector = cv2.xfeatures2d.SURF_create(800)
|
||||
norm = cv2.NORM_L2
|
||||
elif chunks[0] == 'orb':
|
||||
detector = cv2.ORB(400)
|
||||
detector = cv2.ORB_create(400)
|
||||
norm = cv2.NORM_HAMMING
|
||||
elif chunks[0] == 'akaze':
|
||||
detector = cv2.AKAZE()
|
||||
detector = cv2.AKAZE_create()
|
||||
norm = cv2.NORM_HAMMING
|
||||
elif chunks[0] == 'brisk':
|
||||
detector = cv2.BRISK()
|
||||
detector = cv2.BRISK_create()
|
||||
norm = cv2.NORM_HAMMING
|
||||
else:
|
||||
return None, None
|
||||
|
@ -79,7 +79,7 @@ if __name__ == '__main__':
|
||||
cv2.createTrackbar('outlier %', 'fit line', 30, 100, update)
|
||||
while True:
|
||||
update()
|
||||
ch = cv2.waitKey(0)
|
||||
ch = cv2.waitKey(0) & 0xFF
|
||||
if ch == ord('f'):
|
||||
cur_func_name = dist_func_names.next()
|
||||
if ch == 27:
|
||||
|
@ -62,5 +62,5 @@ if __name__ == '__main__':
|
||||
|
||||
cv2.imshow('laplacian pyramid filter', res)
|
||||
|
||||
if cv2.waitKey(1) == 27:
|
||||
if cv2.waitKey(1) & 0xFF == 27:
|
||||
break
|
||||
|
@ -168,7 +168,7 @@ class App:
|
||||
self.rect_sel.draw(vis)
|
||||
|
||||
cv2.imshow('frame', vis)
|
||||
ch = cv2.waitKey(10)
|
||||
ch = cv2.waitKey(10) & 0xFF
|
||||
if ch == 27:
|
||||
break
|
||||
if ch == ord(' '):
|
||||
|
@ -26,13 +26,13 @@ if __name__ == '__main__':
|
||||
video_src = 0
|
||||
|
||||
cam = video.create_capture(video_src)
|
||||
mser = cv2.MSER()
|
||||
mser = cv2.MSER_create()
|
||||
while True:
|
||||
ret, img = cam.read()
|
||||
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||
vis = img.copy()
|
||||
|
||||
regions = mser.detect(gray, None)
|
||||
regions = mser.detectRegions(gray, None)
|
||||
hulls = [cv2.convexHull(p.reshape(-1, 1, 2)) for p in regions]
|
||||
cv2.polylines(vis, hulls, 1, (0, 255, 0))
|
||||
|
||||
|
@ -71,7 +71,7 @@ class App:
|
||||
|
||||
self.rect_sel.draw(vis)
|
||||
cv2.imshow('plane', vis)
|
||||
ch = cv2.waitKey(1)
|
||||
ch = cv2.waitKey(1) & 0xFF
|
||||
if ch == ord(' '):
|
||||
self.paused = not self.paused
|
||||
if ch == ord('c'):
|
||||
|
@ -61,7 +61,7 @@ TrackedTarget = namedtuple('TrackedTarget', 'target, p0, p1, H, quad')
|
||||
|
||||
class PlaneTracker:
|
||||
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.targets = []
|
||||
|
||||
@ -160,7 +160,7 @@ class App:
|
||||
|
||||
self.rect_sel.draw(vis)
|
||||
cv2.imshow('plane', vis)
|
||||
ch = cv2.waitKey(1)
|
||||
ch = cv2.waitKey(1) & 0xFF
|
||||
if ch == ord(' '):
|
||||
self.paused = not self.paused
|
||||
if ch == ord('c'):
|
||||
|
@ -37,7 +37,7 @@ def find_squares(img):
|
||||
|
||||
if __name__ == '__main__':
|
||||
from glob import glob
|
||||
for fn in glob('../cpp/pic*.png'):
|
||||
for fn in glob('../data/pic*.png'):
|
||||
img = cv2.imread(fn)
|
||||
squares = find_squares(img)
|
||||
cv2.drawContours( img, squares, -1, (0, 255, 0), 3 )
|
||||
|
@ -39,16 +39,15 @@ if __name__ == '__main__':
|
||||
window_size = 3
|
||||
min_disp = 16
|
||||
num_disp = 112-min_disp
|
||||
stereo = cv2.StereoSGBM(minDisparity = min_disp,
|
||||
stereo = cv2.StereoSGBM_create(minDisparity = min_disp,
|
||||
numDisparities = num_disp,
|
||||
SADWindowSize = window_size,
|
||||
uniquenessRatio = 10,
|
||||
speckleWindowSize = 100,
|
||||
speckleRange = 32,
|
||||
disp12MaxDiff = 1,
|
||||
blockSize = 16,
|
||||
P1 = 8*3*window_size**2,
|
||||
P2 = 32*3*window_size**2,
|
||||
fullDP = False
|
||||
disp12MaxDiff = 1,
|
||||
uniquenessRatio = 10,
|
||||
speckleWindowSize = 100,
|
||||
speckleRange = 32
|
||||
)
|
||||
|
||||
print 'computing disparity...'
|
||||
|
Loading…
Reference in New Issue
Block a user