OpenCv Separate objects

Hello ,for an internship I need to detect and count some pigs. I can separate them to the background but not separate one to another when they are too close. I'm starting to learn image processing and OpenCv so maybe I'm doing bad.

I tried two approaches ,one with haartraining and one with color and contours of pigs.

Let's start with the first one.

I've trained my cascade with 35 positives images of pigs
like this
https://drive.google.com/file/d/0BwH79wKOtHB5MkpaUDBNVTFtYU0/view?usp=sharing
or this
https://drive.google.com/file/d/0BwH79wKOtHB5WE1rV1pWd2ZIM1E/view?usp=sharing

my 25 negative images are the background of the images.
like this
https://drive.google.com/file/d/0BwH79wKOtHB5VHJtU3prcFgtREk/view?usp=sharing

That is my command to create the cascade :
haartraining.exe -data cascades -vec vector/vector.vec -bg negative/bg.txt -npos 35 -nneg 25 -nstages 15 -mem 1024 -mode ALL -w 24 -h 24 -bt DAB

My programme to detect :
cascade.detectMultiScale( frame, faces, 1.1, 1, 0|CASCADE_SCALE_IMAGE, Size(150, 150) );

The issue is the programme detect a lot of pigs inside one pigs.
As you can see here.
https://drive.google.com/open?id=0BwH79wKOtHB5OWtFYU12NTNFemc

I would like to know if i do something wrong or it is just i haven't trained my cascade with images enough .


About my second approach,

I have divided my image in two part with HSV segmentation. Pigs and not pigs
like this :
https://drive.google.com/file/d/0BwH79wKOtHB5aTZyaHhZcWdVZkU/view?usp=sharing

and I would like to use contours of the images to separate one pigs to another but contours are too much or not enought
As you can see

too much :
https://drive.google.com/file/d/0BwH79wKOtHB5eFFtLU81QkVhQms/view?usp=sharing
or not enought :
https://drive.google.com/file/d/0BwH79wKOtHB5dnRuY2FSQm1WSzA/view?usp=sharing

Does someone have an idea to use them to separate pigs ?


Thanks for your help.
Topic archived. No new replies allowed.