<< Click to Display Table of Contents >> Navigation: 3. Script Language > Image/Pixel-Color Operations > Pattern-Search > Image/Pixel-Color Operations |
MiniRobotLanguage (MRL)
LTP. Locate and Find one or two Pattern
Get Locations of one or two specified Pattern-Objects in an Image-Register (IR)
Intention
This command will find the Locations where a specified Objects are in an Image. It uses only 4 Parameter and is easy to use.
Assume that you want to recognize the state in which a GUI is, that is not accessible to other commands.
Then you can record 2 Patterns and locate them using a single command.
If there are more then 2 Patterns that shall be taken into consideration, maybe use the SCS. and the CFP.-Command
it can work with an unlimited number of Patterns.
This command uses internally multiple Levels (4 Levels) of Fuzzy-Logic.
It will search all of the currently localized Top-Window.
The LFP-Command will use additional Parameters that can be changed using the SFP.-Command.
These are for example the Color-Tolerance and the number of "needed Pixel-Hits".
Hereby Pixel-Hits are the number of Pixels that do match the Pattern using the given Color-Tolerance.
To use the FindPattern-Command, there is additional Program called "Human-Eye-Recorder" available with this distribution.
See a Description here: Human Eye-Recorder
Using the HE-Recorder the recording of Patterns is easy and fast.
Here is an important Notice: if you record a Pattern, and you use "Check Pattern"
and the Pattern is not found, then you have "Mouseover Effects".
This means that the Color of the Object changes if Mouse is nearby or over the Object.
You may not see this change visually.
The Pattern Matcher will definitely see it and avoid the Pattern, if Color Tolerance is zwero.
You can handle these Events best, if you first make a Screenshot from that Window and record the Pattern from the Screenshot.
Again, do never use a JPG or loosing Compression for working with the Pattern-Matcher Commands.
Due to Compression Artefacts the quality of the results is unknown. Best use ".bmp" or ".png".
Alternatively you can do the recording with an higher Color-Tolerance.
Which is not the best choice - but will work most often.
Now you can find out which of multiple Patterns was found for example with
WTP.$$PAA|$$PAB|30,40|60
GFP.LastPattern|$$PAT
MBX.$$PAT
1. Use LTP with 4 Parameters and default settings
This will include all Screens on a Dual-Screen System. Here we search a Pattern on the complete Desktop.
STW.ct|PBWindowClass:0|JK - IDE 2.
VAR.$$PAA=?pattern\Py.bmp
VAR.$$PAB=?pattern\Pa.bmp
' LTP. uses 4 Parameters
LTP.$$PAA|$$PAB|0,0|$$RES
DMP.6
MBX.$$RES
ENR.
If you Specify P3, then P3 is the number of findings, limited by thesetting of Max-Results ( see SFP.-Command).
On the TOS you will find all the Results.
If you omit the $$RES then you get the number of finds on TOS.
VAR.$$PAA=?pattern\Py.bmp
VAR.$$PAB=?pattern\Pa.bmp
STW.ct|PBWindowClass:0|JK - IDE 2.
$$LAA=?pattern\SP_5.bmp
' LTP. uses only 3 Parameters
LTP.$$PAA|$$PAB|0,0
DMP.6
MBX.$$RES
ENR.
2. Use LTP. and set the default Parameters with SFP. before
You can change the Parameters that LTP. uses with the SFP.-Command.
VAR.$$PAA=?pattern\Py.bmp
VAR.$$PAB=?pattern\Pa.bmp
STW.ct|PBWindowClass:0|JK - IDE 2.
' Set Maxmimum Results Number to 4
SFP.MaxResults|4
' Set Minimum Pixel-Hits to 63
SFP.PixelHits|63
' Set Color-Tolerance to 12
SFP.ColorTolerance|12
$$LAA=?pattern\SP_8.bmp
LTP.$$PAA|$$PAB|0,0|$$RES
DMP.6
MBX.$$RES
ENR.
Syntax
LTP.P1|P2[|P3][|P4]
Parameter Explanation
P1 - Pattern File A - Name and Path
or Specify "IR:" and Image-Register number for Pattern from an Image-Register..
or Specify "ID:$$DTA" und directly use Inline-Data as Pattern.
P2 - Pattern File B - Name and Path
or Specify "IR:" and Image-Register number for Pattern from an Image-Register..
or Specify "ID:$$DTA" und directly use Inline-Data as Pattern.
P3 - opt. Destination Point Shift, will be used to move the target point by a specified amount of Pixels.
For example, if the Target is found at 100,50 and you specify here -10,40 then the final Point will be at 90,90.
P4 - opt. Variable for Result. if omitted the result will be placed on TOS.
The Command will leave a the number of finds in P4 (if given) or the TOS.
The Result "0" means "nothing found", a result of -1 means "Error", while a "1" or a higher number shows the number of found matches.
The maximum Number of found Locations is limited by the "Max-Results" Setting that can be changed using the "SFP.-Command".
The last found Position will automatically set as the "Active Point".
If the Pattern does not exist then you will get a result "0" on TOS. The program will not generate an Error-Message.
Example
-
Remarks
Speed Considerations:
1. The Command is "Multithreaded" and works best with a Multicore CPU.
2. The Command will need a lot of CPU-Power, it may also use the GPU at some point internally.
3. Generally the Command is very fast even in very large windows, as long as the Computer has a modern CPU.
4. The larger the Pattern, the slower the process.
5. Currently it may speed up the process, if you have the pattern touch the upper left corner. This may change in the future.
6. If a Pattern is very slow, just record another Pattern. And try this again. Check that there are no empty Lines on Top of the Pattern.
7. A pattern that is completely empty will not work as there is nothing to recognize in it.
Do not use ".jpg" Images or images that are compressed with Artefacts. Generally use ".bmp" or ".png" Images. Otherwise the result will be hard to predict.
Limitations:
The resolution of the Pattern-Images that can be used is limited to those resolutions that can be saved with the "Human Eye-Recorder"-Tool.
See also:
•