Well, after some lovely weather this week, I have had Pollinator-Pi collecting a few days worth of data. Unfortunately, I didn't pick up that the IR flood light had stopped working. This was only after I had spent 43 hours processing 78,840 images, 40,000 of which were black!
Anyways, on with installing and playing around with OpenCV on a home based RPi 3. I used this very handy webpage for the install instructions:
http://www.pyimagesearch.com/2016/04/18/install-guide-raspberry-pi-3-raspbian-jessie-opencv-3/. To save a bit of time, I cut'n'pasted the install lines into a few amalgamated shell scripts.
I then used this page:
http://www.pyimagesearch.com/2015/05/25/basic-motion-detection-and-tracking-with-python-and-opencv/ to start building my motion detection script.
Initially I was just happy to detect motion events and count the number in each frame. Here is a fungus gnat in frame 272:
- motion detected.jpg (106.3 KiB) Viewed 9394 times
Placing the frame number in each video frame allows me to go back to the original JPG and check out the annotated photo, in this case:
- frame_272.jpg (32.11 KiB) Viewed 9394 times
I am also logging each movement event, frame by frame to a logfile:
- object logging.jpg (16.55 KiB) Viewed 9394 times
The small video taken on the 2016-08-31, consists of 5800+ photos. Of these, my script detects 1574 movement events. Quite a few of these, are caused by wind blowing the peppi leaf on the LH side. I know this kind of thing happens in a lot in the compiled videos, so I needed a way to ignore these. Also, I wanted a way to highlight any movement around the flower of interest, so I have manually created ignore zones: cyan box and a flower zone, purple box. I then highlight moving objects differently depending where they are.
Below, you can see a faint green box around an ant (above and to the left of the mouse X cursor):
- object outside the flower zone.jpg (57.39 KiB) Viewed 9394 times
Below, you can see the bright green box around a flying gnat:
- object within the flowerzone.jpg (58.14 KiB) Viewed 9394 times
It's rather a poor example, but it was only in the video for a few seconds, and I found it difficult to get a screen shot of it. Here is frame 1383 at full resolution:
- frame_1383_flying_gnatt.jpg (4.25 KiB) Viewed 9394 times
Not very exciting is it! Here it is perched on the Helmet orchid flower a few frames before:
- frame_1381_purched_gnatt.jpg (11.1 KiB) Viewed 9394 times
There ended up being 79 frames with movement inside the purple flower zone. Of these, there were only two different gnat events, with none going inside the flower. The rest where ants trekking around the flower. To speed up the script, I shrink the HD video down to 800 pixels. In this, most ants show up at around 50-70 pixel area, whereas the gnats show up around 150 pixels. It will be interesting to see if that holds true across the different videos. I try to keep the flower at a constant 7cm from the camera, so I think they should.
Once again, this is being done with the RPi IR camera, so the colours are all washed out. To speed up the photo capture rate, I am limiting the photo size to 1920x1080, ie: 2MP. It would be interesting to see it all at the full 5MP resolution. Of course, I would need a rather expensive 128GB USB flash drive to store all the images out in the field, and over time, a larger home QNAP storage device!
I don't think there is much flying around at night, so maybe by next season I will make up a new waterproof camera that utilises a normal RPi camera board.