Looking for some advise

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Looking for some advise

malcolm.varsity
Hi list,

I recently bought the O'Reilly Learning OpenCV book and have been
working through some examples in order to gauge their suitability for
what I'm trying to achieve.  I thought I'd also ask this group too
whilst I try to get my head around some of the concepts from the book.

Can anyone suggest ways of finding the position on a still image of a
circular red dot?  The colour will always be red however lighting
conditons may slightly change how "red" this red circle is.  The
shape
will always be circular however camera position may slightly alter
how
"circular" the circle is.  There will always be other circles in the
still image so matching on colour AND shape is necessary (I guess).

Ideally once this circle is detected the centre point of the matched
shape will be known as well as the circumference.

I've tried cvMatchPattern where a square difference match is the
only "success" (correlation, correlation coefficient and normalised
matches simply return a black image).  The SQDIFF match returns a
dark
circular area indicating the match kind of worked, however I'm unsure
how to use this match and the associated values to progress with the
detection of other shapes.

I have a feeling histograms might be the way to go however asking
this
group seems like a shortcut at the moment!

Any help or suggestions are much appreciated.

Many thanks

 

Reply | Threaded
Open this post in threaded view
|

Re: Looking for some advise

Golan Levin
Will there be other red objects in the scene? Will this be the
"reddest" object in the scene?

My first inclination would be to extract the red channel of the image,
and threshold (binarize) it. That should yield a bright blob which is
your object. You could basically be done at that point if you compute
the centroid of that blob; there's your XY coordinate. As for choosing
a threshold, there are a lot of methods; choose a fixed red-value
(like 128 out of 255), or consult with the HIPR online for more
complex ideas (e.g. Otsu's method).

If you have other red objects which are equally red, but differently
shaped (squares and triangles), then this is more complicated.
Threshold the red channel as before, find and label the blobs as
connected components. Then eliminate blobs whose areas are too small
or too large to be your target, to the best of your knowlege. Then
extract the contours of the remaining blobs, and analyze the contours.
Circular or near-circular contours will have low ratios for their
perimeter-squared to their area. There are a lot of other shape
descriptors you could compute, such as the standard deviation of the
radii from the points on the contour to that blob's centroid;
obviously, circles and ellipses will have low stdv's.

You may want to do a quick gaussian or box-windowed blur on the red
channel to eliminate noise before doing all of this.

best
Golan



--- In [hidden email], "malcolm.varsity" <malcolm.varsity@...>
wrote:

>
> Hi list,
>
> I recently bought the O'Reilly Learning OpenCV book and have been
> working through some examples in order to gauge their suitability for
> what I'm trying to achieve.  I thought I'd also ask this group too
> whilst I try to get my head around some of the concepts from the book.
>
> Can anyone suggest ways of finding the position on a still image of a
> circular red dot?  The colour will always be red however lighting
> conditons may slightly change how "red" this red circle is.  The
> shape
> will always be circular however camera position may slightly alter
> how
> "circular" the circle is.  There will always be other circles in the
> still image so matching on colour AND shape is necessary (I guess).
>
> Ideally once this circle is detected the centre point of the matched
> shape will be known as well as the circumference.
>
> I've tried cvMatchPattern where a square difference match is the
> only "success" (correlation, correlation coefficient and normalised
> matches simply return a black image).  The SQDIFF match returns a
> dark
> circular area indicating the match kind of worked, however I'm unsure
> how to use this match and the associated values to progress with the
> detection of other shapes.
>
> I have a feeling histograms might be the way to go however asking
> this
> group seems like a shortcut at the moment!
>
> Any help or suggestions are much appreciated.
>
> Many thanks
>


Reply | Threaded
Open this post in threaded view
|

Re: Re: Looking for some advise

malcolm.varsity
> Will there be other red objects in the scene? Will this be
> the
> "reddest" object in the scene?

There will be other equally red objects in the image but none of them circular, so I'd imagine (only imagine because I'm new to OpenCV) that a combination of colour and shape (edge/contour?) detection would pinpoint the red circle and get the particular x,y I'm after.

Pages 214-219 of the O'Reilly book describes an example of cvMatchTemplate, where the image is two men in a light aircraft on an air strip and the template is one of the men's face.  The results show the different levels of detection that each matching method offers.
But what the book doesn't explain as part of this example is what is possible once the template has been found in the image.

As I said in the original post, the SQDIFF cvMatchTemplate does return a dark circle but I'm at a loss as to what to do next.

Many thanks

back to the book...



 

>
> My first inclination would be to extract the red channel of
> the image,
> and threshold (binarize) it. That should yield a bright
> blob which is
> your object. You could basically be done at that point if
> you compute
> the centroid of that blob; there's your XY coordinate.
> As for choosing
> a threshold, there are a lot of methods; choose a fixed
> red-value
> (like 128 out of 255), or consult with the HIPR online for
> more
> complex ideas (e.g. Otsu's method).
>
> If you have other red objects which are equally red, but
> differently
> shaped (squares and triangles), then this is more
> complicated.
> Threshold the red channel as before, find and label the
> blobs as
> connected components. Then eliminate blobs whose areas are
> too small
> or too large to be your target, to the best of your
> knowlege. Then
> extract the contours of the remaining blobs, and analyze
> the contours.
> Circular or near-circular contours will have low ratios for
> their
> perimeter-squared to their area. There are a lot of other
> shape
> descriptors you could compute, such as the standard
> deviation of the
> radii from the points on the contour to that blob's
> centroid;
> obviously, circles and ellipses will have low stdv's.
>
> You may want to do a quick gaussian or box-windowed blur on
> the red
> channel to eliminate noise before doing all of this.
>
> best
> Golan
>
>
>
> --- In [hidden email], "malcolm.varsity"
> <malcolm.varsity@...>
> wrote:
> >
> > Hi list,
> >
> > I recently bought the O'Reilly Learning OpenCV
> book and have been
> > working through some examples in order to gauge their
> suitability for
> > what I'm trying to achieve.  I thought I'd
> also ask this group too
> > whilst I try to get my head around some of the
> concepts from the book.
> >
> > Can anyone suggest ways of finding the position on a
> still image of a
> > circular red dot?  The colour will always be red
> however lighting
> > conditons may slightly change how "red" this
> red circle is.  The
> > shape
> > will always be circular however camera position may
> slightly alter
> > how
> > "circular" the circle is.  There will always
> be other circles in the
> > still image so matching on colour AND shape is
> necessary (I guess).
> >
> > Ideally once this circle is detected the centre point
> of the matched
> > shape will be known as well as the circumference.
> >
> > I've tried cvMatchPattern where a square
> difference match is the
> > only "success" (correlation, correlation
> coefficient and normalised
> > matches simply return a black image).  The SQDIFF
> match returns a
> > dark
> > circular area indicating the match kind of worked,
> however I'm unsure
> > how to use this match and the associated values to
> progress with the
> > detection of other shapes.
> >
> > I have a feeling histograms might be the way to go
> however asking
> > this
> > group seems like a shortcut at the moment!
> >
> > Any help or suggestions are much appreciated.
> >
> > Many thanks
> >