Problems with Image Recognition and OCR.

Version 19.1.2 Linux (Red Hat)
I’ve noticed since our last 2 Eggplant Functional updates that the image search (and OCR) are failing FAR more often, especially on tests that have been running fine for 6 months. With OCR we’ll see OCR work, then after a few runs suddenly it can’t find the text that it successfully found 5 minutes prior. Several of our Developers have noticed similar issues with the image matching, I wanted to know of other users are seeing the same issues.

In an effort to figure out this issue, I’m going to document what’s been going on an what we’ve done to figure out the problem. First the issue has been noticed by myself and another tester, a third coworker has not been seeing the issue. Now I’ll note the two of us seeing failures are running the linux version (noted above) while the other person is running the Windows version.

To test I tried using a very basic script that is used often in my automated tests: It right clicks on an image (to drop a menu), then selects a item, which drops down another menu and it selects and item from that menu. This script has been running fine for a year now, until recently it’s never had any problems/errors.

Lately when using a RightClick to find the image you can see the cursor move to the image, then it suddenly snaps back to it’s previous location to right click. Till now I’ve used Click “” to select the menu items but a very recent color change to the menu background (it’s gone a little lighter) caused the 'Click on an item" to not find the image. So I switched to OCR to select the menu items as I’ve had good experiences with it. Usually after first starting the Eggplant GUI the first time the script is run it runs fine. When I try to run it again, now the OCR can’t find the menu text, even though NOTHING has changed from the previous run. Run it again and the issue with the pointer finding then leaving the image before clicking starts - and the OCR will still not find the menu text. One of the issues OCR will cite is contrast, but with white text on a black background I can’s see how this is the case.

What we’ve done to try to track down the issue:
1) Removed the SuiteInfo file, I had noticed we had 2 Suites with the same EncodedTextKey so I removed the file in order for Eggplant to generate a new one… No change in reaction.

2) Ran a different Suite/script (with similar commands) on a Windows machine (and it ran perfectly). I ran the same suite/script from my Linux Eggplant GUI with 2 different SUTs and the test ran perfectly. No problems.

3) I then created a new version of my script (with a newly captured image) and I’m getting the same problems. Runs fine the first time, but after that I get inconsistent points of failure.

Note I checked both the new and old images that I need to right click on; both had the same ‘hot spot’ dead center on the image.

In Preferences I’ve:
Enable Aggressive Text Extraction
Ignore Spaces
Enhance Local Contrast
Check for low contrast text during OCR search
Check for low contrast text during image search

Please submit this as a support case to Eggplant. The forums are intended as a community resource, not a mechanism for support. I can tell you that there have been no changes to the image search algorithms in years, or the OCR engine recently. The behavior you describe with right clicks is not something we've heard from anywhere else and I can think of nothing that would explain it other than an issue on the SUT -- the mouse should only move in response to directions from Eggplant Functional, and there's nothing in the code that would send instructions to return to a prior location.

I would never recommend "Aggressive Text Extraction" -- that's generally going to cause more problems that it could solve. The two "checks" are for usability, not for OCR functionality. IgnoreSpaces is only going to help if the issue is actually due to spaces being seen where they aren't or not seen where they are. You can often diagnose that issue by using a ReadText on the area where you expect the text to be found.

Thanks to SchneiderAPL we have a ‘fix’. By forcing the OCR or image search to a particular area by using Set Search Rectangle we have gotten the code to work once again!

Our application uses several Java windows and a map that is not Java based, even though it was supposed to search the entire display it seems the search engines were primarily focused on the Java based windows. When the search rectangle was set to the map area it found the image and text with no issues. When the rectangle was set to default () or I put in the coordinates for the entire screen then it was hit or miss on detecting images & text that were in the map window.

EggplantMatt. Thanks I will send this to Eggplant support. We’ve noticed since the last update that the entire screen is not being looked at. (see previous post). Today I had an OCR string that is usually found not being found - but when the search area text was dumped the text was clearly seen (I grabbed a screen shot which I’ll post to support).

The OCR Tuner is helpful in seeing how different options affect the OCR search.
When I have issues with OCR finding the text where the background (and foreground) colors change, I will create a if imagefound(Contrast:TRUE, ContrastColor(R,G,B)) then click foundlocation(), else imagefound(…. and so on, using the different background contrast colors.