Detecting matched texts
How to detect matched texts and get their color code in hexadecimal numbers.
Ensure that you have captured and saved one or more training images. These are images that are similar in appearance to the images expected from the AUT during automation. Note that it is less essential that the text strings be identical than that such things as background, color, text size and font be similar to the expected test images.
- To capture screenshots of desktop applications, use the Picture Capturing tool.
- To capture screenshots of mobile applications, use the Device Live Screen tool together with the Picture Capturing tool.
You will train the system by establishing optimal settings for detecting text during automation. To determine these settings, carry out the following steps:
With TestArchitect open, select Tools > OCR Detector Tool.
In the OCR Detector Tool dialog box, click the button next to the Select file to test field.
Note:Only .png images are supported.In the Save dialog box, browse to the training image containing the text you want to detect, then click Select.
The selected training image is loaded into the OCR Detector Tool dialog box.
Optional: For some images, it is easier to see the effect of the edge detection process when the color information is removed from the image’s display. To do this, select the Gray Scale check box under the Settings tab.
Under the Settings tab, select the Pick Color check box to enable color code selection and retrieval of desired text.
Tip:To zoom out or zoom in on the image, use Zoom Out (-) or Zoom In (+) button, respectively.The mouse cursor changes into a eyedropper pointer.
Position the eyedropper pointer over a portion of the text that needs detecting.
If the text varies in shading or color, you should choose a color that covers most of the text or is most representative of all the text.
The color code at the selected text is displayed as three hexadecimal numbers in RGB order, below the Pick Color check box.
Important:Make note of these three hexadecimal values for manual entry into the text color argument of whichever OCR-related built-in actions you use in your test.Click the Scan Picture button to filter out colors which do not match the color selected from the text.
The unmatched colors are filled with the inverse of the color selected previously.
Click the Detect button to detect and highlight all objects which match the color selected previously.
The detected objects are highlighted with bounding rectangles.
Click the Recognize button to scan and return texts whose color matches the color selected previously.
A list of recognized text fragments is displayed. (Note that all text fragments are presented in lowercase, and with spaces removed.)
Select the text you want to detect from the list of recognized texts.
The selected text is highlighted in the training image with its bounding rectangle, with the (x,y) coordinates of the top-left corner of the bounding rectangle displayed.
If your text of interest is unrecognizable or improperly recognized, try using the OCR advanced settings.