user753503
user753503

Reputation: 59

OpenCV TextBox Detection

I am writing a tool for Gui Automation Test. By specify a text string, I want to get the coordinate of its nearest Textbox on current screen.

The signature of the function should looks like this:

Point GetNearestTextBoxPosition(string textOnLabel)

I have managed to get the coordinate of the given string of textOnLabel, so the I have to only implement this function:

Point GetNearestTextBoxPosition(Point textLabelPosition)

I want to implement this functionality using the computer vision technology such as Rectangular Detection. Is there one who can tell me how to achieve this goal using OpenCV?

Upvotes: 2

Views: 1788

Answers (2)

Dave Durbin
Dave Durbin

Reputation: 3642

Assuming you only have a bitmap image of the screen in question, I'd suggest using histograms to identify the approximate locations of text on the screen, then OCR within those regions to determine the text. If you find text that matches the string you're searching for then you can use a simple horizontal and vertical gradient test working out from the bounds of the text to find the containing box (assuming that it has either a different coloured border or background colour).

Without seeing a sample input it's harder to be more specific than this.

Upvotes: 0

peakxu
peakxu

Reputation: 6675

You can detect rectangles with Hough Transforms very easily.

That said, are you sure a computer vision approach is appropriate?

If your GUI is web, you can drive at the DOM level using libraries like Watir or Selenium. If your GUI is a native app, there are controls for manipulating them as well.

Upvotes: 2

Related Questions