Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem solved!

Problem solved!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.
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).

Thanks again for helping me, I hope this will help future students :)

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 :)

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 :)