fixes for latest changes in opencv3.0 api
fixes for latest changes in opencv3.0 api waitKey() normalization fixed mser bindings
This commit is contained in:
parent
fd2d800c06
commit
fd60e98c5b
@ -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;
|
||||||
|
@ -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')
|
||||||
|
@ -71,8 +71,8 @@ def mtx2rvec(R):
|
|||||||
return axis * np.arctan2(s, c)
|
return axis * np.arctan2(s, c)
|
||||||
|
|
||||||
def draw_str(dst, (x, y), s):
|
def draw_str(dst, (x, y), s):
|
||||||
cv2.putText(dst, s, (x+1, y+1), cv2.FONT_HERSHEY_PLAIN, 1.0, (0, 0, 0), thickness = 2, lineType=cv2.CV_AA)
|
cv2.putText(dst, s, (x+1, y+1), cv2.FONT_HERSHEY_PLAIN, 1.0, (0, 0, 0), thickness = 2, lineType=cv2.LINE_AA)
|
||||||
cv2.putText(dst, s, (x, y), cv2.FONT_HERSHEY_PLAIN, 1.0, (255, 255, 255), lineType=cv2.CV_AA)
|
cv2.putText(dst, s, (x, y), cv2.FONT_HERSHEY_PLAIN, 1.0, (255, 255, 255), lineType=cv2.LINE_AA)
|
||||||
|
|
||||||
class Sketcher:
|
class Sketcher:
|
||||||
def __init__(self, windowname, dests, colors_func):
|
def __init__(self, windowname, dests, colors_func):
|
||||||
|
@ -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(' '):
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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()
|
||||||
|
@ -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
|
|||||||
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
|
||||||
|
@ -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:
|
||||||
|
@ -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
|
||||||
|
@ -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(' '):
|
||||||
|
@ -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.detectRegions(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))
|
||||||
|
|
||||||
|
@ -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'):
|
||||||
|
@ -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:
|
|||||||
|
|
||||||
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'):
|
||||||
|
@ -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 )
|
||||||
|
@ -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...'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user