Reputation: 2061
i'm searching for the fastest way to find one or more reference points, (could be +, or a rectangle).
My first idea is, to go from the mid point of the image and look iterative in all 4 directions for the coloured pixels. But in this case it is not clear for me how to handle a symbol like + .
Hopefully my description is clear. Greetings
UPDATE
Like in this image, the rectangle should normally in the mid. For the detection it would be ok, if the initial finding of the positions would take longer and a "check" must be really fast.:
Upvotes: 1
Views: 945
Reputation: 207465
I don't know the relative performance of all the aspects of the OpenCV code, but I assume it is pretty good at vector type operations across whole rows of an image rather than scalar operations such as you suggest when you propose doing ever increasing circles radiating from the centre to find the cross. Here is one approach that may work.
First, squidge (TM) all the pixels together to make a column as tall as the original image but just a single pixel wide. I have coloured this in red in the diagram. The darkest pixel in this column gives you the y-coordinate of your reference points.
Then, squidge (TM) all the pixels together to make a row as wide as the original image but just a single pixel high. I have coloured this in blue in the diagram. The darkest of the middle black bar then gives you the x-coordinate of your central reference point.
This will also handle small rotations as well as translations - and if the rotations are larger, you will get 3 black bars on the right.
You may also decide that, in general, and to save time, you only need process the image from the 1/3 to the 2/3 point in the vertical direction and the 1/4 to the 3/4 point in the horizontal direction since that is most likely to include the reference points.
Upvotes: 1