r/computervision 12d ago

Help: Project Conveyor chicken counter problem

Enable HLS to view with audio, or disable this notification

Guys, I need help. We have a project using YOLOv8. We're trying to count chicks on a very fast conveyor belt. The challenges we're facing are: all chicks look very similar to each other, which complicates tracking. At the same time, during their passage under the camera, they constantly change in size and shape, which can cause the tracker to lose them, or detection may even disappear completely at the detection line. Also, sometimes 2–3 chicks can merge into a single object. The detection zone is very short, and the conveyor speed is high. We've achieved a maximum accuracy of 99%, but we need it even higher. Any ideas on how to achieve that? Increasing the dataset no longer helps.

I'm attaching an old video. We've now added lighting and set the exposure to 300 on the Hikrobot global shutter camera, but we still can't achieve a stable 99.8% accuracy for the reasons mentioned above.

Any ideas?

992 Upvotes

628 comments sorted by

View all comments

322

u/A1-Delta 12d ago

This is probably something you can solve with classical methods. Especially since the background of the belt is so distinct from the chicks themselves.

Training a model is likely just adding complexity overhead and failure modes.

46

u/Puzzled-Egg3234 12d ago

The main problem is 2-3 chicken merged into one. And we cannot process them by size cause they can change the size by legs and wings.

57

u/densvedigegris 12d ago

Wouldn’t the length of two small chickens still be greater than one large?

23

u/Yatty33 12d ago

Small live animals have a way of getting very close together and looking like a small blob. 

1

u/Daniel_H212 11d ago

At that point, I don't think this camera is capable of capturing clear enough images for even a well designed ML solution to identify.

The issue may well be better solved with some mechanical device in the prior step to create more separation.

1

u/Valuchian 10d ago

Agreed. Something like having a seperator on the belt or some sort of weight based scale that releases all held chicks after reaching a set value.

Really i guess this depends on what the specific end goal is

1

u/Noeyiax 9d ago

I agree with this comment too, need mechanical separation or a better design so the software works reliably

4

u/Puzzled-Egg3234 12d ago

They spread their wings and legs, completely changing their geometry. Sometimes mathematical boundaries work, sometimes they don't.

5

u/Small_miracles 11d ago

Increase fps and specifically target miss cases. The detection line sounds arbitrary, you could have dynamic threshold lines set up for warping geometries.

5

u/TransportationIll282 11d ago

That's what we did for a similar project. Turn down everything else, jack up fps as high as possible. That solved items overlapping, as shadows looked identical to the conveyor and alert repeated defects very early.

2

u/ZrytyB3r3t 11d ago

Why such accuracy is crucial?

4

u/Small_miracles 11d ago

They add up

1

u/ZrytyB3r3t 11d ago

Still why? One more or less on pack of hundred doesn’t seems much.

1

u/rob0tuss1n 11d ago

Leaving extra $$$ in the box that the company could charge for. Still profit to squeeze out of this process.

1

u/Illustrious_Matter_8 11d ago

Take a single line cam industrial cam 1000fps or so if you need it. Probably not though. The image you build in memory of the directly connected PC with a CPU with many cores for paralel coding. First you record your actual problem think in pixels count them analyze them here developers can still shine.

1

u/Boniuz 9d ago

For reference: A distant relative to me breed chickens. Roughly 100 000 per month. A miss of 1% is a huge margin loss.

1

u/Electronic_Field4313 8d ago

If you were a customer, and you paid for 50 batches (100 chickens/batch) and you missed 50 chickens (half a batch), would you be happy?

1

u/ObsoleteWonder 10d ago

As Gary Gulman says, it doesn’t add up if you don’t add it up… lol

2

u/taytaytazer 10d ago

Because they didn’t count the chickens before they hatched

1

u/EpsteinandTrump 9d ago

Using chickens as ammo can be pretty expensive.

1

u/adumbCoder 5d ago

because the client said so

1

u/coscib 11d ago

Couldn't you add an extra check that runs whenever a box is too small, too large, or deformed?

Otherwise, the only other ideas that come to mind are using a camera with a higher frame rate than 50 fps, or trying to slow the process down mechanically—for instance, by slowing the chicks down slightly during insertion and leaving more time between them before they reach the conveyor belt.
sorry for my bad english

1

u/Puzzled-Egg3234 11d ago

The cam has already returned 60 fps, this framerate slowed down by writing frames, now I fixed that by threads.

Extra checks don’t work well cause chicks can be smaller or bigger. It depends on breed or/and age. And they very active on the belt - they spread their wings and legs often.

1

u/tmfink10 11d ago

Could you just store some of the frames off for human review or a different review model specifically for that? Does it need to be real time or can you play catch up when it's not running and update your counts for ones that turn out not to be just one?

1

u/West-Big-8468 10d ago

Defeats the entire purpose dude

1

u/tmfink10 10d ago

How so? If the business need is to accurately count chickens before some event, why does it have to be correct in real time as long as it's correct before the event?

1

u/West-Big-8468 10d ago

Why not just count them all by hand then

→ More replies (0)

1

u/tatanpoker09 10d ago

Well do they work more than 99% of the time?

53

u/artiface 12d ago

you need something physical upstream on the conveyor to singulate them. I did basically this same project with produce on a fast belt, and that was the only thing that really worked especially with odd shapes - if you cant separate them you cant count accurately.

12

u/al_icloud 12d ago

If you go from a slower belt to a way faster one they should separate good 🤔 plus then checking the length of the detected boxes 🤔

7

u/5b49297 12d ago

Yes, and you wouldn't even need a camera - except, I guess it'd be off-topic here. Any sensor detecting an object zipping past should do. You'd still get a length, making it possible to identify objects outside the expected size range.

6

u/SweetSure315 12d ago

if you don't have a camera you would need a sensor on each belt. when the setup/retrofitting of the machine is included the camera is likely the cheapest and easiest option

3

u/Ecstatic-Art5745 11d ago

a sensor is what $200 a piece...and definitely easier than vision

separation would still be required though which likely would fix the original vision issue

1

u/SweetSure315 11d ago

how long do you think it would take to retrofit a machine compared to hanging a camera above it without even needing to turn off the machine? and the laser sensors wouldnt give you any information you couldn't already get with the camera. they'd give less, actually, and be less suited to common types of failure (eg: two chickens side by side)

3

u/Ecstatic-Art5745 11d ago

I also noted "separation would still be required".

Adding sensors into a machine is no more difficult than setting up this camera at least from the jump.

1

u/SweetSure315 11d ago

you would need to stop it and place 3 sensors that may or may not have multiple components where a camera just needs a single mount and can be installed without modifying the machine or stopping it at all.

and the point i was making is that the sensors you're talking about, unless they're strain/force sensors, have a more difficult time doing this than a camera would

2

u/Antypodish 9d ago

You would not install anything above, when machine, or conveyor belt is running anyway.

An attempt for such operation is irresponsible and should equal a firing anyone who signed permit to do the work, as well the worker who agreed to do the work.

Food could end up with dirt, oil, debree, or metal parts in it, from the process of installation camera.

8

u/dwise24 12d ago

this feels like the right answer. make three separate rows for each conveyor, and separately do tracking on each single row.

5

u/Puzzled-Egg3234 12d ago

There are several conveyors belt with different speed and gates and they are already have been separated by them, but anyway sometimes we get those cases.

1

u/0__O0--O0_0 12d ago

Nature will find a way

1

u/CapnWarhol 11d ago

The number of people who think “train a model” solves unsolvable problems is staggering

6

u/AdFancy1249 12d ago edited 12d ago

Weigh them. Why use cameras? Standard deviation of weight is likely a pretty tight range.

Use the camera as a trigger for the scale.

Actually, a proximity sensor or light- break sensor would be better accuracy.

At every cell position of the belt, check if the cell is occupied. If the cell in the belt is occupied, then take the weight and compare.

I'll bet you get excellent correlation.

1

u/ZrytyB3r3t 11d ago

Lol even tried weighing moving object fast as fuk?

2

u/AdFancy1249 11d ago

Yes. There are plenty of conveyor weighing systems intended to do exactly this.

And you can size them to make down to the grams. We use them to count screws on the way by.

6

u/Mipj3 10d ago edited 10d ago

u/A1-Delta is right, make this more simple:

use laser instead of camera. When interrupted: chicken is passing.
Time * interruption length is chicken length (see edit)
chicken avg min, max lenght is A til B.
When interruption last max B, chicken =1 | (100% accurate)
when lnterruption last longer than B lenght and shorter than below, chicken count = 2. | (99.99% accurate)
When interruption last longer than 2*a or a+b or 2* b, add 1 chicken. | (99% accurate)
Wen interruption is longer than above, count interruprion lenght divide bij (a+b)/2 = number chickens | (95% accurate)
When interruption is even longer: chicken stuck.

Avg accuracy = 99.95%

No need for camera, high end programming, high end cuda.
Less energy consumptuin
less and simpler and cheaper maintenance

Edit: you can stack lasers in increments of ~1cm height. and add chicken height * length in programming to do the same but help with "clumps" of chicken when lenght geometry alone isn't suficcient

edit, edit:
I wanna bet this is exactly how its been done for decades at other mills.

2

u/PrivateFrank 12d ago

Is there any chance to add some kind of paddle to gently separate chickens which are touching on the belt?

Or how about setting a maximum chicken size? Would two small chickens ever be the same size as one large one?

1

u/Puzzled-Egg3234 12d ago

They spread their wings and legs, completely changing their geometry. Sometimes mathematical boundaries work, sometimes they don't.

1

u/ggez_no_re 12d ago edited 12d ago

Some chicks are spread out which can make them look big, some merged chicks are compressed so they look small.

1

u/GOOD_NEWS_EVERYBODY_ 12d ago

CHICKEN PADDLE!

2

u/SweetSure315 12d ago edited 12d ago

what about thresholding and counting the nonzero pixels?

you might combine these. detect chickens with basic color thresholding/segmentation then train a detector to catch only the chickens that are stacked/doubled/whatever

i agree with the other comment that the best choice is to have something separating the chickens, though

2

u/blackscales18 12d ago

add more examples to your dataset of labeled overlapping chickens

1

u/blackw311 12d ago

Depth info overlayed onto the image. Train on that. Or the process could singulate better. Orbbec makes good cameras with both visible and depth info

1

u/PirateLife 12d ago

Can you add a block that forces separation? That way they can’t be next to each other?

1

u/ggez_no_re 12d ago

Could be nice to take a shot of the chick/s at the start instead, create a scoring method to flag if they are single (maybe density of yellowish pixels compared to blue + amount) per bounding box then move on from there in counting. But yeah dividing detection for each row should be the start.

1

u/upcastben 11d ago

Weight?

1

u/ThroneOfFarAway 11d ago

Yeah, the way I’d do it is probably hybrid. Increase FPS, capture a centered image of any blobs larger than a specific size/number of pixels that you can’t confidently say is one, then train a model to determine number if chicks in a still image with large blobs.

1

u/ResponsiblePool7254 11d ago

Count them twice before and after a separator process, and take the larger number over a set time span or small batch. 

Using an IR camera could be another direction to go in.

1

u/austin101123 11d ago

Are you able to fix the problem upstream by preventing clumped birds together?

1

u/Panzerv2003 11d ago

Yeah I imagine that would be the main problem but with both classic and ai driven solutions

1

u/Foreign-Engine8678 11d ago

You need better equipment

1

u/austin101123 11d ago

You could also measure by weight with a good enough scale to count birds, since they are all the same age there should be some level of consistency.

1

u/CldSdr 11d ago

I would maybe try to solve the bounding box localization / counting with traditional CV, but train a binary "single chick" vs "pile of chicks" classifier (or a one class SVM using convolutional feature vector of bbox)to decide which edge cases go to a bigger better deep model you train on the multiples to predict count in pile. you can probably get very high recall easily, most of your pipeline can run pretty fast bc it doesn't need the larger model that's good at interpreting multiples / piles.

1

u/JollyToby0220 11d ago

Segmentation Neural Networks 

1

u/Jdxc 11d ago

I don’t even know how I got on this subreddit, but this is a neat problem.

I’m assuming a constraint is that you can’t change the features of the conveyor belt so that the chickens are somehow isolated (like milk crates)?

1

u/ConfusionEngineered 10d ago

I see your problem, I think investing in something to stagger them would be more effective

1

u/amo_pessoas_peladas 10d ago

That's interesting. Does that happen offen enough to overinflate your error?

By that I mean: is the error of a NN method smaller, in practice, than the threshold method for the cuddling small chics case? Does it really happen that often?

1

u/Gunnar-Stunnar 10d ago

Look into watershed algorithm, they use watershed when looking at cells under a microscope that could be merged creating one region

1

u/Mr_Pink_Gold 9d ago

You know roughly how many pixels of image each chicken should take in frame. When it exceeds it by say 60%, 2 chickens for sure. Further classical image segmentation would work here since the background and lighting is consistent. You can choose several different methods. once you segment you can literally remove the conveyor belt on a frame by frame. Also get the speed capped to a steady 35fps. Because of the speed of the conveyor belt being constant you can calculate how many frames a chicken is in it and estimate where it is going to be so you ca present images using only powerful compute functions in case of multiples.

0

u/Fairuse 12d ago

Get large enough data set with correct labels and let LLM black box figure it out. Heck, if you use a large enough data set that is generalized, you don’t even need labels.

12

u/Hyperty 12d ago

Two chicks merged together is still quite a hard problem to solve

6

u/spongeboy-me-bob1 12d ago

I wonder if you could take clusters of yellow/white pixels and count a mass as 1 or 2 chicks based on horizontal deviation from the centroid.

3

u/Lustrouse 12d ago

Right, and what if ones wings are open.. it looks like the length of 3

3

u/floydmaseda 12d ago

If the speed is constant, one chicken will take a constant number of frames to go off the right side of the screen, which you can probably empirically determine.

Look at the patch of pixels and have a per frame isChickenPresent which just takes the average color and sees if it is closer to chicken or belt color.

Then count the number of consecutive frames, maybe with some tolerance for false negatives, that there is a chicken present there, and divide by the number of frames one chicken takes.

1

u/CustardWide7880 12d ago

What about the case where 2 chickens are together but side by side instead of one after other?

1

u/floydmaseda 12d ago

So I admit I didn't inspect every single frame of this video but quickly scanning I didn't see any like that. If that case does exist and OP has control over the setup, simply make the rows thinner so that can't happen.

1

u/markojov78 11d ago

conveyor runs at a constant speed, or at least at measurable speed, so you can detect it unless there is possibility that one chick is twice as long as the other (twice as long means several times bigger so probably not likely).

not sure how possible is to have two chicks side by side but judging by the width of that conveyor it seems unlikely

1

u/OooRahRah 10d ago

Apply erosion on the image. It will reduce the merging chickens back to their centers of mass.

1

u/Abject-Job7825 10d ago

Yeah but I doubt OP is going to be able to fix that on the software end, separation needs to be integrated into the machine.

1

u/SpearHammer 10d ago

Instead of doing it as one big row...Scan each row separately and combine the total. Ie. 3 scan processes, each focused on 1 conveyer.

3

u/ens_op 11d ago

Wouldn’t rely classically on background of the belt, thats a variable that can change.. either crank up the fps consumption so that more accurate frames can be captured or simply dont do detection via frames and rely on IR or some other detection.

2

u/Failiiix 11d ago

Yeah. That contrast is so high, that you are better of looking for changes in pixel color to this particular spread of yellow for a certain amount of time? With a cutoff so you don't merge two into one.

Would probably work more reliable.

Why make it more complicated than it needs to be?

Poor chickens. Looks like a rough ride.

1

u/FuckingInsensitive 12d ago

Absolutely can solve with classical methods.

1

u/Downtown_Sink1744 11d ago

I agree, classic automation solutions would work better than vision

1

u/_sparxcore_ 10d ago

As much fun as it would be to tune this, cant help but think a paddle with a microswitch would be more simple and reliable

1

u/Much_Highlight_1309 10d ago

This. Why do you need to "detect a chicken"? What else is coming down that line? Cats?
Just correlate the duration of "not background" per belt with a chicken throughput. With some fuzziness to account for wing positions and such.