I want to trigger an image capture every time a tyre of a set of moving vehicles appears just in front of the picamera. Is there any way to get this done automatically every time a tyre appears in front of the camera ?
-
There's like a zillion possibility to do that, you need to ask a more specific question. Do you want to recognize tire ? If so you can train a model to recognize just that. Is the camera fixed on something and the background picture remain the same ? Then you should probably try to detect edges and movement. ....– YCN-Commented Jul 5, 2019 at 8:40
Add a comment
|
1 Answer
Example from here :
import picamera
import picamera.array
import numpy as np
class MyMotionDetector(picamera.array.PiMotionAnalysis):
def analyse(self, a):
a = np.sqrt(
np.square(a['x'].astype(np.float)) +
np.square(a['y'].astype(np.float))
).clip(0, 255).astype(np.uint8)
# If there're more than 10 vectors with a magnitude greater
# than 60, then say we've detected motion
if (a > 60).sum() > 10:
print('Motion detected!')
with picamera.PiCamera() as camera:
camera.resolution = (640, 480)
camera.framerate = 30
camera.start_recording(
'/dev/null', format='h264',
motion_output=MyMotionDetector(camera)
)
camera.wait_recording(30)
camera.stop_recording()
New in version 1.5.