Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find a fix number of (almost) fixed proportion rectangles with opencv?

Tags:

python

opencv

I am writing a simple fly tracking software and I would love some input from opencv experts.

The image I have looks pretty much like:

sample image for fly tracking

I used to do tracking using kmeans and PIL/numpy but I re-wrote everything to use blob detection in opencv. Tracking works OK but I would also like to automatize division of ROI. What I need to do is find each of the 32 grooves that appear in the picture, where flies live. See the black rectangle on the image as example of what I mean.

I think cornerHarris may be what I need but how do I specify only the grooves and not each single rectangle found in the image? All those grooves have proportions of roughly 10:1.

Thanks!

like image 842
Giorgio Gilestro Avatar asked Jul 26 '11 12:07

Giorgio Gilestro


1 Answers

I don't think cvCornerHarris is even close to what you need.

A much better start would be to experiment with the demo available at: OpenCV-2.3.0/samples/cpp/squares.cpp. This technique uses Canny(), dilate() and findCountour().

Right out of the box, this demo outputs:

enter image description here

I believe that with a few tweaks here and there you can have your party started.

like image 160
karlphillip Avatar answered Oct 27 '22 01:10

karlphillip