Ask Your Question
2

Counting eggs of hen

asked 2017-08-28 21:23:16 -0600

nanuyo gravatar image

updated 2017-09-05 21:18:37 -0600

Hi Experts,

I'm trying to count eggs on this picture with Opencv. but, I don't know what is the best way. image description

If you recommend me any way of counting eggs on the picture, please let me know your advice. if using classifier is the best way, pls let me know how to make classifier. or, could you pls provide me existing classifier for egg counting..?

thanks a lot..

Best Regards, HJ PS: As Ziri asked, I added more pictures and the colors of egg I want to count are white and brown. thanks a lot. Ziri image description

edit retag flag offensive close merge delete

Comments

You can count egg blobs doing simple color threshold (choose color space model ) For overlapping eggs you can use watershed algorithm with Distance transform like in this example but instead of doing simple threshold

threshold(bw, bw, 40, 255, CV_THRESH_BINARY | CV_THRESH_OTSU);

Use InRange function.

Ziri gravatar imageZiri ( 2017-08-29 00:40:02 -0600 )edit

please provide some additional images if you have. let's think on a more general solution.

sturkmen gravatar imagesturkmen ( 2017-08-29 09:45:08 -0600 )edit

@Ziri.. Just, I have one doubt. If the color of the holder and eggs are same

vps gravatar imagevps ( 2017-08-31 09:40:12 -0600 )edit

Hi Ziri, Thanks a lot for your kind help.. I added 2 more pictures.. and , I want to count white and brown eggs

nanuyo gravatar imagenanuyo ( 2017-09-01 00:16:53 -0600 )edit

You can start by preparing training data ( positive and negative images) of egg with different colors in different situations... then use cascade classifier Check this link . -If results are not satisfying you'll have to use better methods ( Convolutional Neural Network ).

Ziri gravatar imageZiri ( 2017-09-01 00:37:37 -0600 )edit

Hi Ziri, Thanks again.. I'll test cascade classifier first and try CNN if needed..

nanuyo gravatar imagenanuyo ( 2017-09-01 03:06:35 -0600 )edit

i think cascade classifier dont work. try new train_HOG.cpp there is a PR waiting to be accepted.

sturkmen gravatar imagesturkmen ( 2017-09-01 10:48:36 -0600 )edit

As worse as a cascade classifier will fail at this (to simply object and not rotation invariant) it will fail with HOG also. Your task needs something more versatile like DPM, DeepLearning, ACF/ICF ... although those are not available through OpenCV.

StevenPuttemans gravatar imageStevenPuttemans ( 2017-09-04 05:47:03 -0600 )edit

@nanuyo you keep updating the question, with little to no response. Can you at least respond to peoples suggestions?

StevenPuttemans gravatar imageStevenPuttemans ( 2017-09-06 02:08:44 -0600 )edit

sorry to Steven, as you advised, I reallised that it is not easy to count eggs on the basket with legacy computer vision algorithms. so, I will try to count eggs on the case only and removed a picture(eggs in the basket).and I want to add more simpler pictures for you .. but this editor (add comment) doesn't provide us attaching pictures.. Can I add the other pictures into the main story ?

nanuyo gravatar imagenanuyo ( 2017-09-07 21:43:44 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
5

answered 2017-09-08 06:38:01 -0600

updated 2017-09-09 03:54:18 -0600

i tried to test new train_HOG.cpp on your image and get this result.

(color of the detection rectangles differs according to returned value of foundWeights. brighter rectangles means they are found with higher confidence)

image description

sample detection 1

sample detection 2

sample detection 4

all images showing detections can bu found here

i cant say that it is the best method but it is worthy to try.

you can find the code and the data in this Github repository HOG-object-detection

edit flag offensive delete link more

Comments

I am wondering, how did you train the model? If it is with the same data, than this says nothing. How does it perform on the second image?

StevenPuttemans gravatar imageStevenPuttemans ( 2017-09-08 06:42:56 -0600 )edit

hi @StevenPuttemans, you can find training data in the mentioned repo. indeed i did not care to prepare a perfect data. but i know if the data will be prepared well then the results will be better. it will be great if you try it. ( if you have a few free time)

sturkmen gravatar imagesturkmen ( 2017-09-08 06:46:57 -0600 )edit

I agree, but I am wondering how the change in viewpoint affects your model. I do not have the time to do this myself now, so can you have a try at image 2 and report back results?

StevenPuttemans gravatar imageStevenPuttemans ( 2017-09-09 03:09:53 -0600 )edit
1

i updated the answer. you can see results here

sturkmen gravatar imagesturkmen ( 2017-09-09 03:55:53 -0600 )edit

Is there a a reason of the different color ranges?

StevenPuttemans gravatar imageStevenPuttemans ( 2017-09-09 04:12:55 -0600 )edit
1

no, i just did some simple try and see. i am not focused on training a perfect egg detector ( let's leave it for the OP )

sturkmen gravatar imagesturkmen ( 2017-09-09 04:31:01 -0600 )edit

I mean the colour of your bounding boxes :D

StevenPuttemans gravatar imageStevenPuttemans ( 2017-09-09 07:51:31 -0600 )edit

i explained in the answer. green boxes means higher confidence. maybe it will be formulated better see the code

sturkmen gravatar imagesturkmen ( 2017-09-09 08:03:24 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2017-08-28 21:23:16 -0600

Seen: 2,389 times

Last updated: Sep 09 '17