camera = PiCamera() camera.start_preview(alpha=200) for i in range(5): sleep(5) camera.capture('/home/pi/Desktop/image{}.jpg'.format(i)) camera.stop_preview()
import MotionSensor from datetime import datetime camera = PiCamera() pir = MotionSensor(4) while True: if pir.motion_detected: camera.start_preview(alpha=200) timestamp = datetime.now().isoformat() camera.start_recording('/home/pi/{}.h264'.format(timestamp)) camera.wait_recording(10) camera.stop_recording() camera.stop_preview()