1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-25 13:23:02 +04:00

update samples: waitKey() usage

Original commit is a5f19f7dd6
This commit is contained in:
StevenPuttemans
2016-08-12 15:11:30 +02:00
committed by Alexander Alekhin
parent 4e7b521438
commit 6d34d6b47e
76 changed files with 142 additions and 154 deletions
+1 -1
View File
@@ -110,7 +110,7 @@ class App(object):
cv2.imshow('camshift', vis)
ch = 0xFF & cv2.waitKey(5)
ch = cv2.waitKey(5)
if ch == 27:
break
if ch == ord('b'):
+1 -1
View File
@@ -77,7 +77,7 @@ if __name__ == '__main__':
cv2.imshow('src', src)
update()
while True:
ch = 0xFF & cv2.waitKey()
ch = cv2.waitKey()
if ch == ord(' '):
update()
if ch == 27:
+1 -1
View File
@@ -56,7 +56,7 @@ if __name__ == '__main__':
vis = hsv_map*h[:,:,np.newaxis] / 255.0
cv2.imshow('hist', vis)
ch = 0xFF & cv2.waitKey(1)
ch = cv2.waitKey(1)
if ch == 27:
break
cv2.destroyAllWindows()
+1 -1
View File
@@ -66,5 +66,5 @@ if __name__ == '__main__':
update(3)
cv2.createTrackbar( "levels+3", "contours", 3, 7, update )
cv2.imshow('image', img)
0xFF & cv2.waitKey()
cv2.waitKey()
cv2.destroyAllWindows()
+1 -1
View File
@@ -122,7 +122,7 @@ if __name__ == '__main__':
update(None)
while True:
ch = cv2.waitKey() & 0xFF
ch = cv2.waitKey()
if ch == 27:
break
if ch == ord(' '):
+1 -1
View File
@@ -92,7 +92,7 @@ def main():
cv2.imshow('frame', frame)
cv2.imshow('bin', bin)
ch = cv2.waitKey(1) & 0xFF
ch = cv2.waitKey(1)
if ch == 27:
break
+1 -1
View File
@@ -59,7 +59,7 @@ if __name__ == '__main__':
while True:
ch = 0xFF & cv2.waitKey(50)
ch = cv2.waitKey(50)
if ch == 27:
break
if ch == ord('v'):
+1 -1
View File
@@ -49,7 +49,7 @@ if __name__ == '__main__':
vis = np.uint8(vis/2.)
vis[edge != 0] = (0, 255, 0)
cv2.imshow('edge', vis)
ch = cv2.waitKey(5) & 0xFF
ch = cv2.waitKey(5)
if ch == 27:
break
cv2.destroyAllWindows()
+1 -1
View File
@@ -68,6 +68,6 @@ if __name__ == '__main__':
draw_str(vis, (20, 20), 'time: %.1f ms' % (dt*1000))
cv2.imshow('facedetect', vis)
if 0xFF & cv2.waitKey(5) == 27:
if cv2.waitKey(5) == 27:
break
cv2.destroyAllWindows()
+1 -1
View File
@@ -88,7 +88,7 @@ if __name__ == '__main__':
cv2.createTrackbar('outlier %', 'fit line', 30, 100, update)
while True:
update()
ch = cv2.waitKey(0) & 0xFF
ch = cv2.waitKey(0)
if ch == ord('f'):
if PY3:
cur_func_name = next(dist_func_names)
+1 -1
View File
@@ -66,7 +66,7 @@ if __name__ == '__main__':
cv2.createTrackbar('hi', 'floodfill', 20, 255, update)
while True:
ch = 0xFF & cv2.waitKey()
ch = cv2.waitKey()
if ch == 27:
break
if ch == ord('f'):
+1 -1
View File
@@ -63,7 +63,7 @@ if __name__ == '__main__':
draw_gaussain(img, m, cov, (0, 0, 255))
cv2.imshow('gaussian mixture', img)
ch = 0xFF & cv2.waitKey(0)
ch = cv2.waitKey(0)
if ch == 27:
break
cv2.destroyAllWindows()
+1 -1
View File
@@ -129,7 +129,7 @@ if __name__ == '__main__':
cv2.imshow('output',output)
cv2.imshow('input',img)
k = 0xFF & cv2.waitKey(1)
k = cv2.waitKey(1)
# key bindings
if k == 27: # esc to exit
+1 -1
View File
@@ -84,7 +84,7 @@ if __name__ == '__main__':
cv2.imshow('image',im)
while True:
k = cv2.waitKey(0)&0xFF
k = cv2.waitKey(0)
if k == ord('a'):
curve = hist_curve(im)
cv2.imshow('histogram',curve)
+1 -1
View File
@@ -41,7 +41,7 @@ if __name__ == '__main__':
sketch = Sketcher('img', [img_mark, mark], lambda : ((255, 255, 255), 255))
while True:
ch = 0xFF & cv2.waitKey()
ch = cv2.waitKey()
if ch == 27:
break
if ch == ord(' '):
+1 -1
View File
@@ -90,7 +90,7 @@ if __name__ == "__main__":
if code != -1:
break
if (code % 0x100) in [27, ord('q'), ord('Q')]:
if code in [27, ord('q'), ord('Q')]:
break
cv2.destroyWindow("Kalman")
+1 -1
View File
@@ -44,7 +44,7 @@ if __name__ == '__main__':
cv2.circle(img, (x, y), 1, c, -1)
cv2.imshow('gaussian mixture', img)
ch = 0xFF & cv2.waitKey(0)
ch = cv2.waitKey(0)
if ch == 27:
break
cv2.destroyAllWindows()
+1 -1
View File
@@ -70,5 +70,5 @@ if __name__ == '__main__':
cv2.imshow('laplacian pyramid filter', res)
if cv2.waitKey(1) & 0xFF == 27:
if cv2.waitKey(1) == 27:
break
+1 -1
View File
@@ -90,7 +90,7 @@ class App:
cv2.imshow('lk_homography', vis)
ch = 0xFF & cv2.waitKey(1)
ch = cv2.waitKey(1)
if ch == 27:
break
if ch == ord(' '):
+1 -1
View File
@@ -85,7 +85,7 @@ class App:
self.prev_gray = frame_gray
cv2.imshow('lk_track', vis)
ch = 0xFF & cv2.waitKey(1)
ch = cv2.waitKey(1)
if ch == 27:
break
+1 -1
View File
@@ -79,7 +79,7 @@ if __name__ == '__main__':
cv2.createTrackbar('iters', 'morphology', 1, 10, update)
update()
while True:
ch = 0xFF & cv2.waitKey()
ch = cv2.waitKey()
if ch == 27:
break
if ch == ord('1'):
+1 -1
View File
@@ -176,7 +176,7 @@ class App:
self.rect_sel.draw(vis)
cv2.imshow('frame', vis)
ch = cv2.waitKey(10) & 0xFF
ch = cv2.waitKey(10)
if ch == 27:
break
if ch == ord(' '):
+1 -1
View File
@@ -78,6 +78,6 @@ if __name__ == '__main__':
drag_start = None
gray=cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imshow("gray",gray)
if (cv2.waitKey() & 255) == 27:
if cv2.waitKey() == 27:
break
cv2.destroyAllWindows()
+1 -1
View File
@@ -40,6 +40,6 @@ if __name__ == '__main__':
cv2.polylines(vis, hulls, 1, (0, 255, 0))
cv2.imshow('img', vis)
if 0xFF & cv2.waitKey(5) == 27:
if cv2.waitKey(5) == 27:
break
cv2.destroyAllWindows()
+1 -1
View File
@@ -83,7 +83,7 @@ if __name__ == '__main__':
cur_glitch = warp_flow(cur_glitch, flow)
cv2.imshow('glitch', cur_glitch)
ch = 0xFF & cv2.waitKey(5)
ch = cv2.waitKey(5)
if ch == 27:
break
if ch == ord('1'):
+1 -1
View File
@@ -65,7 +65,7 @@ if __name__ == '__main__':
draw_detections(img, found_filtered, 3)
print('%d (%d) found' % (len(found_filtered), len(found)))
cv2.imshow('img', img)
ch = 0xFF & cv2.waitKey()
ch = cv2.waitKey()
if ch == 27:
break
cv2.destroyAllWindows()
+1 -1
View File
@@ -75,7 +75,7 @@ class App:
self.rect_sel.draw(vis)
cv2.imshow('plane', vis)
ch = cv2.waitKey(1) & 0xFF
ch = cv2.waitKey(1)
if ch == ord(' '):
self.paused = not self.paused
if ch == ord('c'):
+1 -1
View File
@@ -170,7 +170,7 @@ class App:
self.rect_sel.draw(vis)
cv2.imshow('plane', vis)
ch = cv2.waitKey(1) & 0xFF
ch = cv2.waitKey(1)
if ch == ord(' '):
self.paused = not self.paused
if ch == ord('c'):
+1 -1
View File
@@ -49,7 +49,7 @@ if __name__ == '__main__':
squares = find_squares(img)
cv2.drawContours( img, squares, -1, (0, 255, 0), 3 )
cv2.imshow('squares', img)
ch = 0xFF & cv2.waitKey()
ch = cv2.waitKey()
if ch == 27:
break
cv2.destroyAllWindows()
+2 -2
View File
@@ -108,9 +108,9 @@ if __name__ == '__main__':
img = render.getNextFrame()
cv2.imshow('img', img)
ch = 0xFF & cv2.waitKey(3)
ch = cv2.waitKey(3)
if ch == 27:
break
#import os
#print (os.environ['PYTHONPATH'])
cv2.destroyAllWindows()
cv2.destroyAllWindows()
+1 -1
View File
@@ -69,6 +69,6 @@ if __name__ == '__main__':
vis = a.copy()
draw_str(vis, (20, 20), 'frame %d' % frame_i)
cv2.imshow('a', vis)
if 0xFF & cv2.waitKey(5) == 27:
if cv2.waitKey(5) == 27:
break
cv2.destroyAllWindows()
+1 -1
View File
@@ -217,7 +217,7 @@ if __name__ == '__main__':
ret, img = cap.read()
imgs.append(img)
cv2.imshow('capture %d' % i, img)
ch = 0xFF & cv2.waitKey(1)
ch = cv2.waitKey(1)
if ch == 27:
break
if ch == ord(' '):
+1 -1
View File
@@ -81,7 +81,7 @@ if __name__ == '__main__':
else:
task = DummyTask(process_frame(frame, t))
pending.append(task)
ch = 0xFF & cv2.waitKey(1)
ch = cv2.waitKey(1)
if ch == ord(' '):
threaded_mode = not threaded_mode
if ch == 27:
+2 -2
View File
@@ -58,10 +58,10 @@ while True:
cv2.putText(img, "FPS: {}".format(fps), (15, 80), font, 1.0, color)
cv2.imshow("Video", img)
k = 0xFF & cv2.waitKey(1)
k = cv2.waitKey(1)
if k == 27:
break
elif k == ord("g"):
elif k == ord('g'):
convert_rgb = not convert_rgb
cap.set(cv2.CAP_PROP_CONVERT_RGB, convert_rgb)
+1 -1
View File
@@ -56,7 +56,7 @@ class App:
def run(self):
while cv2.getWindowProperty('img', 0) != -1 or cv2.getWindowProperty('watershed', 0) != -1:
ch = 0xFF & cv2.waitKey(50)
ch = cv2.waitKey(50)
if ch == 27:
break
if ch >= ord('1') and ch <= ord('7'):