Problem solved thanks to Steven and his very nice idea! Indeed, he thought about something which is very simple but that I didn't see: algaes are attached to the ground and fishes aren't. Meaning that if we compare the x coordinate of each center of each shapes, we can deduce what's a fish and what's not.
To help those having a similar problem here's how I did it using openCV.
The solution, in details
First, you need to get the contours of your image/video frame (using findContours on a thresholded image).
Second, you need to get the openCV moments for each shape (simply go through your contours returned vector and apply the moments function each time). You can now easily calculate the center of each contours and put it in a list so that you can calculate the variance (have a look at the doc)
Then I created another list to keep the x-variance between each center. By "variance" I mean a simple subtraction (coordX[i] - coordX[i-1] with i running from 1 to (your list length - 1)).
And basically after that you only need to set a threshold and if your variance is higher, then it's a fish (because it moved more than the algae).
Other ideas
I also tried to work with colors but with the sudden and unpredictable lighting condition in an underwater environment, didn't get nice results. Getting the number of edges for each shapes was a good idea as well but not radical enough (I still had algae here and there on my video). Using the solution described above, I have exactly what I wanted :)
Thanks again for helping me, I hope this will help future students :)
Given that fish can be at odd angles I would think looking for color would be a better place to start.
maybe have a look at moments and matchShapes
I do think so yes. Don't have a system here to check it out for you.
Colors are not usable since I am in an underwater environment (which means a lot of lighting variations). Working with the inner pixels is cool but once again I'll always have one algae that'll be taken by my algorithm. Basically, every algae are very different from the fishes but I don't know how I could use that in real-time. There's no openCV function that simply says if a shape is smooth or not?
I just tried switching the color space but the results are not good. The detection is less precise. Anyway I've got a thresholded image and I'm quite happy with the results I have. The last thing I need to do is removing the remaining noise now and then. Colors ain't help me for that, or I might have misunderstood what you implied. If you had the exact image I put in my question, and were asked to show only the fish, how would you do?
I will think about it and get back to you!
Actually with water flow, the algae are moving as well. And I use background subtraction + thresholding + findContours + moments + arcLength + other not OpenCV things to get here. So I've already used the movement. And describing how smooth the edge of my objects contours are is what I'm trying to do now.