Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import cv2
  2. from numpy import *
  3. from scipy.signal import *
  4.  
  5. def nothing(x):
  6. pass
  7.  
  8.  
  9. def test_estimate_delta(a,b, wid):
  10.  
  11. cap = cv2.VideoCapture(0)
  12. flag = False
  13. while True:
  14. ret, v = cap.read()
  15. frame = frame[:,::-1]
  16.  
  17. lst = []
  18. h = ones((a,a))
  19. for i in xrange(0,255):
  20. tmp = fftconvolve(where(v >= i, 1,0),h, mode="same")
  21. lst += [tmp]
  22. f = array(lst)
  23. d = arange(len(f))[:,None,None] * ones(f.shape)
  24.  
  25. thresh = where((f <= b + wid) == (f > t - wid), d, 255).argmin(axis=0)
  26. thresh = where(thresh == 0, 255, thresh)
  27.  
  28. v = where(v > thresh, 255, 0).astype(uint8)
  29.  
  30.  
  31. cv2.imshow("Movie", v)
  32.  
  33. k = cv2.waitKey(1)
  34. if k == 27:
  35. break
  36.  
  37. cap.release()
  38. cv2.destroyAllWindows()
  39. capture_camera()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement