I wanted to see what everyone thought as to how to improve my motion detection video recording. Here are key points I'm interested in. It seems like some of my points are related to multi-threading (or I think they are).
Please let me know general ways to improve on these points. Thanks in advance!
1. Only record video while there is motion detected, such that only a minimal of wasted recording time is present.
2. The fastest way to send email (securely to gmail in this case)
3. immediate processing/email delivery of completed media files (pics or videos)
I've just implemented picamera and rpi.GPIO in python to improve my motion detection. I was using motion-mmal previously and it was always having issues, either mis-triggering or displaying artifacts, not to mention the 2 frames/sec I had set and almost complete LACK of "codec" support in Android.
This new method uses a single python script (my first btw) to detect motion and record video/pics and there is no real control on how long the video is recorded for. You pre-choose a timeframe to record. Which is pretty lame, causing lots of wasted space for unnecessary video. Then, using a shell script cron job, I email the created video to myself for review.
So python seems pretty nice, but I want to make sure I am able to dynamically set the length of video to record, based on if the PIR sensor sees motion. (or any other built-in manner that works very well)
So in concept: (I'm terrible at this - go easy)
Code: Select all
Function Record: start_recording() recording-active = true While (datetime <recording_datetime) recording_datetime = lastPIReventTime + 5 secs wend stop_recording() end function Loop() (constantly running like a separate thread) if NOT recording-active and PIREvent Record() end if Is there a new PIRevent? lastPIReventTime = Now() end