Detect (and count) passing insects

Hello all,

I would like to build a square frame with:
Scenario 1: 35cm side length
Scenario 2: 70cm side length

Through this frame (you can imagine it like a window) houseflies and other small insects fly through. Now I want to count these flies/insects.

Which sensor is able to detect these small flying objects?
Or is there another solution how I could realize this?

This is not an easy thing to do. Mainly down to the size of the insects.

The simplest idea would be to use a number of lasers top and detectors on the bottom. But could you pack them in tight enough to make it work?

Another Idea that might work is to wrap two coils round the window and make a sort of metal detector, or magnetometer, circuit to measure the disturbance between the driven coil and the detector coil. But that would take some development work that you might not be up to doing.

1 Like

Get a ESP32 with camera or (easier) get a RPi with camera and openCV.

I have also thought about lasers. Setting up a network with a single laser to cover the entire area seems unrealistic. Setting up dozens of lasers side by side would be conceivable, but I doubt that it would be possible to cover the entire area accurately.

How much time and money would be required for the idea of wrapping two coils?

ESP32 with camera sounds good and seems to be cheaper than the RPi solution. But how does it look qualitatively, which of the two solutions works more precisely?

Define "precise". Define "small insects". e.g. 5mm insect --> 350/5 = 70 --> any camera bigger twice that like 320x240 will work. How often yo you want to count? And do you want to follow individuals? If they fly, how fast do they move? Can you live with 25 frames/sec or do you need 500/sec?

1 Like

It depends entirely on your skill level, the cost in parts is negligible.

The problem with a camera is where do you put it.

1 Like

So with 70cm window and 5mm flying objects, I need a camera with at least 640×480?
With "precise" I mean the accuracy of the flying object detection, no passing objects should be missed.

Counting should be done for 18 hours a day. So continuous operation. The individual flying objects do not need to be tracked. A simple if then formula is sufficient: if an object flies through the window frame, then increase counter by 1.

Because I don't know the flying speed I would choose the 500 frames/second variant as a precaution.

I would place the camera in one of the 4 corners and hope that the camera covers the whole area.

@Grumpy_Mike
My skill level tends to 0 because I am a layman. But if there is a tutorial somewhere I should be able to do it.

If there is no tutorial but the 70cm would be completely covered and all objects could be captured (flying speed unknown) I would also pay for it:)

Probably impossible, and how would you know if you counted all of them?

For example, two insects flying close together will be difficult to tell apart, and some are simply too small for a cheap camera to detect. It is remarkably difficult to count people in a crowd, too, despite quite a bit of research on the topic.

To develop something like this would take a lot of experimentation in the field, but you could expect an approximate count, for insects of easily detectable size.

That would be a very faint hope. Not only would you have a perspective problem, but also focus.

Since each fly has only one back, you could use a fly back diode to detect them. Joke, couldn't resist. Drawback would be, detection would only work in one direction. :slight_smile:

1 Like

@jremington @anon57585045

In my case, 2 objects would never fly through at the same time, but only one at a time.
After a fly is detected it takes about 15-30 minutes until a second fly flies through.

So if I understand correctly, the camera solution would not have a 100% hit rate?

What other solutions can you think of?

So if I understand correctly, the camera solution would not have a 100% hit rate?

Almost certainly true, but the success rate depends on the camera, the detection algorithm, the lighting, the type of insect, speed with which it is flying, and many other things.

You have not provided nearly enough information about your project to make any reliable guesses, except that this will be a hard problem to solve.

2 objects would never fly through at the same time,

Please explain how you know this.

None. It's a really intractable problem. Good luck with it. Look at dust detectors for clues.

Sorry none that I have ever seen.

Well I used to work with metal detectors back in the late 60s for the detection of pieces of stainless steel mesh from production lines from such diverse areas as Pharmaceuticals (for the then new contraceptive pill) to cakes produced for M&S. The size of stainless steel we could detect was limited to what we called the "product effect", this was mainly governed by the moisture content of the product.

I am guessing that the moisture content would correspond to the moisture in the insect. But like all such measurements it is limited to a certain value. As you can't say what size your smallest insect will be, you can't expect to know.

The problem I would see with a Raspberry Pi and camera is that one of resolution and speed, you would not be able to run the software fast enough to get continuous coverage.

True story. After we measured the cream cake for product effect, we ate it. Only to be rung up by the manufacturers asking if we had spotted the metal they put in it. We did feel rather queasy until they explained it was taped on the inside of the card board box.

2 Likes

You are obviously going to have to experiment with different sensors. May I suggest you begin with a microwave motion sensor that uses the highest possible frequency. I see some for 5.8gHz, but I know automobile radar sensors use 70gHz. Do you have a testing area that you can set up for different devices?

Use a microphone to detect the wing buzz. Different bugs emit sounds at characteristic frequencies.

1 Like

It might be helpful if you could expand on the larger objective that gave rise to these requirements. That is, what is the context for counting insects.

My initial thought would be something akin to a slit camera as commonly used as a finish line camera in track & field races. These are cameras that have a one dimensional sensor and record whatever passes by, so producing an image that has time as the horizontal axis and the one dimensional field of view as the vertical axis.

This could be implemented using a regular (e.g. USB) digital camera repeatedly taking images, extracting a single line from the two dimensional image, looking for changes in individual pixels across time, and combining groups of pixel detection events in time and space.

An issue with this approach is that the camera field of view is an angular section, not a "square frame". If the "wall" around the "square frame" can be sufficiently large, this could be limited to the "window".

Another issue is that the frame rate on the camera and whatever signal processing that follows must be sufficiently fast that the insect is captured. That is, the frame rate wants to be inversely proportional to the size and speed of the insect.

As with most complex sensor/signal processing projects, I'd initially prototype this with a PC to determine the viability of the approach and to work through the algorithms and to get a handle on the processing horsepower required before trying it on a more constrained processor.

Thank you for being so helpful. I kept my request as simple as possible, assuming there was a simple solution. That doesn't seem to be the case, so here's a bit more detail:

The 70cm frame is on a box. At irregular intervals, individual blueberries with a size of about 0.5 mm and a weight of 0.01 grams fall into the box. I can't measure the speed at which they fall.

Now I want to use an Arduino to find out exactly when the blueberry falls into the box.

First I tried using a scale, but because the blueberry is so light, I had to set a very precise scale. But then there were occasional false alarms because a breeze would weigh the scale down just as much as the blueberry.

Because the blueberry sometimes loses some of its juice when it hits the bottom of the box, the bottom of the box gets dirty. Therefore, the blueberry should not be in direct contact with the sensor.

Your new description makes all past and future comments very suspect, so I am out. Good luck.

1 Like

Would it be possible to have a funnel type structure that channels the fallen berries to a single point? Then the problem is reduced to simply counting berries passing by that point which is a far simpler thing to do.

Edit to add: If you simply want a count of berries, then it would be easier to do after collection. Also I'm not clear why a count is important, blueberries are typically measured by weight or volume.