XAPBob
Posts: 91
Joined: Tue Jan 03, 2012 2:40 pm

mawk input buffering

Wed Oct 02, 2013 3:22 pm

Just a note for future me...

Background I'm running a RasPiCam as a security camera, with basic motion detection on a low res image taken at about 1fps and a high res image taken when motion is detected.

This obviously would be no use if some thieving wotsit grabbed it off the wall, so I upload the images to dropbox automatically (other services are available).

In order to preserve the SD card (and my sanity) I am using a tmpfs to hold the picture, and inotifywait to monitor said directory - this is great, I get notified on MOVED_TO (which is the last thing raspistill does when it writes a file to disk.

However my processing of that data to provide a filename to my upload script was done with a single line of awk - but mawk (debian default) buffers input when it's a pipe....

So it would do nothing until about 10 files had been written and then upload them all. To deal with this apply the -Wi (or -W interactive) option to awk - this turns off the buffering of i/o (or rather makes it buffer by line rather than buffer size).

Now I get an uploaded image of any motion within about 3-5 seconds - with the camera LED disabled in the config file that's plenty quick enough.

nevenante
Posts: 1
Joined: Tue Aug 13, 2013 8:41 pm

Re: mawk input buffering

Thu Oct 03, 2013 2:23 pm

I am interested in the same topic... image processing for security applications using the Raspberry Pi camera. I am rather new at image processing. I like your idea of detecting movement at low resolution and taking snapshots at highest resolution when the movement is detected. What are you coding with? the first option that caught my eye when I set up my Raspberry Pi last night was Python. But being that it is an interpreted language, therefore slow, are there other native Raspberry Pi options available to me?

Return to “Other programming languages”