Advertisement
Guest User

xy_koordinatai

a guest
Aug 12th, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. import numpy as np
  4. import picamera
  5. import picamera.array
  6.  
  7. class DetectMotion(picamera.array.PiMotionAnalysis):
  8.     def analyze(self, a):
  9.         a = np.sqrt(
  10.             np.square(a['x'].astype(np.float)) +
  11.             np.square(a['y'].astype(np.float))
  12.             ).clip(0, 255).astype(np.uint8)
  13.         # If there're more than 10 vectors with a magnitude greater
  14.         # than 60, then say we've detected motion
  15.         if (a > 60).sum() > 10:
  16.             print('Motion detected!')
  17.             print('a = ',a)
  18.             print('x = ','?')
  19.             print('y = ','?')
  20.  
  21.  
  22. with picamera.PiCamera() as camera:
  23.     with DetectMotion(camera) as output:
  24.         camera.resolution = (640, 480)
  25.         camera.start_recording(
  26.               '/dev/null', format='h264', motion_output=output)
  27.         camera.wait_recording(30)
  28.         camera.stop_recording()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement