Helmet Orchid Pollinator Study

Tell us about your projects. Update us regularly.
parkview
Guru Maker
Posts: 603
Joined: Tue Jun 24, 2014 8:25 pm
Location: Busselton
Contact:

Re: Helmet Orchid Pollinator Study

Post by parkview » Sat Jul 30, 2016 9:10 pm

I have had a few decent runs out in the bush now. Last Fri evening I set up Pollinator-Pi up after work and left it over night. I scored 16K photos or around 20GB worth of 1920x1080 photos. I brought in a fresh 12V SLA battery in the morning and a new USB flash drive and captured a further 5.8K of photos in a few hours. Unfortunately I couldn't do anything else today on it and won't get back out there till next weekend. I have some 64GB USB flash drives winging there way here. These should be able to store around 50K photos a pop.

No auto movement detection yet, and I have still to label all the photos, but I do have short sample 2K photo video on Youtube: https://www.youtube.com/watch?v=DMkIrkBH1ZU Check out the action at around 1:11 It looks like a wasp poking around - maybe looking for a spider?

There is lots more to do and it's still an interesting project, with maybe 4-6 weeks of life left for this year.

All dressed up ready to go. The IR flood light was further back this time:
2016-07-30_on-site.1.jpg
2016-07-30_on-site.1.jpg (109.2 KiB) Viewed 9341 times


Close up of the action:
2016-07-30_on-site.2.jpg
2016-07-30_on-site.2.jpg (90.51 KiB) Viewed 9341 times


It survived the weekends storms admirably.

User avatar
seaton
Master Maker
Posts: 222
Joined: Tue Jun 24, 2014 11:41 am
Location: Bunbury, WA
Contact:

Re: Helmet Orchid Pollinator Study

Post by seaton » Thu Aug 18, 2016 8:40 pm

Well done!, just need to incorporate openCV and you'll be cooking with gas!

parkview
Guru Maker
Posts: 603
Joined: Tue Jun 24, 2014 8:25 pm
Location: Busselton
Contact:

Re: Helmet Orchid Pollinator Study

Post by parkview » Sun Aug 28, 2016 12:18 pm

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! :lol:

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
motion detected.jpg (106.3 KiB) Viewed 9331 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
frame_272.jpg (32.11 KiB) Viewed 9331 times


I am also logging each movement event, frame by frame to a logfile:
object logging.jpg
object logging.jpg (16.55 KiB) Viewed 9331 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
object outside the flower zone.jpg (57.39 KiB) Viewed 9331 times


Below, you can see the bright green box around a flying gnat:
object within the flowerzone.jpg
object within the flowerzone.jpg (58.14 KiB) Viewed 9331 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
frame_1383_flying_gnatt.jpg (4.25 KiB) Viewed 9331 times


Not very exciting is it! Here it is perched on the Helmet orchid flower a few frames before:
frame_1381_purched_gnatt.jpg
frame_1381_purched_gnatt.jpg (11.1 KiB) Viewed 9331 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.

parkview
Guru Maker
Posts: 603
Joined: Tue Jun 24, 2014 8:25 pm
Location: Busselton
Contact:

Re: Helmet Orchid Pollinator Study

Post by parkview » Sun Aug 28, 2016 10:37 pm

Ok, with a bit more smoke and mirrors, if the OpenCV script detects motion around the flower, it's now dumping the full video frame into a subdirectory so that at the end, they can all be compiled back into a video. It's a bit more pixelated, as I am not currently using the good jpg photo file.

The main thing, is that I now longer have to watch 35min length videos :o that equate to 15 hours of photographs!

You can find a sample 79 frame video here: https://youtu.be/ICUhvifKFEs

At the moment, I have to manually setup the two mask zones. If this becomes too cumbersome, I might create a Pygame GUI that I could use to draw each of the mask zones on a sample photo which then passes the coordinates onto the main python script.

parkview
Guru Maker
Posts: 603
Joined: Tue Jun 24, 2014 8:25 pm
Location: Busselton
Contact:

Re: Helmet Orchid Pollinator Study

Post by parkview » Fri Nov 06, 2020 9:36 pm

I gave a talk on this project to a local Bunbury group the other day and as I am in a bit of a electronics mode, I decided to whip up a nice looking PCB for it. This will include a buzzer and a 5 way navigation tactile menu switch. This will allow me to automate a bit more of the running of the camera rig.

It took me a day to quickly draw up a schematic diagram and lay out most of the PCB:
Pollinator-Pi_3D_PCB_V1.0_sml.jpg
Pollinator-Pi_3D_PCB_V1.0_sml.jpg (64.89 KiB) Viewed 7336 times
It took another day to finish off the PCB layout, create a few 3D drawings of some of the components, measure up and align the Raspberry Pi and OLED mounting holes. I tested it out by laser cutting out a paper template to make sure everything is correct.

Post Reply