Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- from numpy import *
- from scipy.signal import *
- def nothing(x):
- pass
- def test_estimate_delta(a,b, wid):
- cap = cv2.VideoCapture(0)
- flag = False
- while True:
- ret, v = cap.read()
- frame = frame[:,::-1]
- lst = []
- h = ones((a,a))
- for i in xrange(0,255):
- tmp = fftconvolve(where(v >= i, 1,0),h, mode="same")
- lst += [tmp]
- f = array(lst)
- d = arange(len(f))[:,None,None] * ones(f.shape)
- thresh = where((f <= b + wid) == (f > t - wid), d, 255).argmin(axis=0)
- thresh = where(thresh == 0, 255, thresh)
- v = where(v > thresh, 255, 0).astype(uint8)
- cv2.imshow("Movie", v)
- k = cv2.waitKey(1)
- if k == 27:
- break
- cap.release()
- cv2.destroyAllWindows()
- capture_camera()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement