Image/Pixel-Color Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Image/Pixel-Color Operations > Pattern-Search >

Image/Pixel-Color Operations

WFP.- Wait For Pattern

Previous Top Next


MiniRobotLanguage (MRL)

 

WFP. Wait For Pattern

Wait for appearance of a Pattern and then get the Locations of a specified Pattern-Object in an Image-Register (IR)

 

 

Intention

 

This command will wait until a specified Pattern will appear or disappear.

It will then find the Locations where a specified Object is in an Image. It uses only 3 Parameter and is easy to use.

The cammand can be given a Timeout Value, if this specified time is over the Command will exit and set the Timeout-Flag

and put a "0" on the TOS.

 

This command uses internally multiple Levels (4 Levels) of Fuzzy-Logic.

It will search all of the currently localized Top-Window.

 

The WFP.-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.

 

Please see the LFP.-Commands for more  Details.

 

1. Use WFP with 3 Parameters and default settings

This will include all Screens on a Dual-Screen System. Here we search a Pattern on the complete Desktop.

 

STW.BAct|PBWindowClass:0|JK - IDE 2.

SWP.0,0|2807,1800|T

$$LAA=?pattern\JK_8.bmp

' P1 - Pattern-File, P2 - Target-Position adjust, P3- Timeout in Seconds

WFP.$$LAA|0,50|60

MMV.

ENR.

 

 

WFP_Stack

If you Specify P3, then P3 is the timeout value..

On the TOS you will find all the Results.

 

 

2. Use WFP. and set the default Parameters with SFP. before

 

You can change more advanced Parameters that WFP. uses with the SFP.-Command.

 

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

' P1 - Pattern-File, P2 - Target-Position adjust, P3- Timeout in Seconds

WFP.$$LAA|0,50|60

MMV.

ENR.

 

 

3. Use WFP. together with Image-Register and Inline-Data

 

You can use Inline-Data instead of pictures from files.

 

STW.ct|TFrmHelpMan|minirobot.hm

GSB.PattA

ANA.#FromVar|1|$$DTA

$$PAT=IR:1

SFP.ColorTolerance|0

SFP.PixelHits|57

SFP.DebugMode|0

' Patternfile | Point-Shift| Timeout 60 Seconds

WFP.$$PAT|0,0|60

' We take away the number of Hits from TOS

POP.$$NOH

' If no Hits, jump away to Lab_NoHits.

JIZ.$$NOH=0|Lab_NoHits1

MMV.

:Lab_NoHits1

ENR.

 

 

' You can also use Formula for the IR

WFP.IR:($$PAT+5)|0,0|60

 

 

4. Use WFP. directly with Inline-Data

 

You can use Inline-Data instead of pictures from files.

 

STW.Act|TFrmHelpMan|minirobot.hm

GSB.PattA

$$PAT=ID:$$DTA

' P1 - Target, P2 - Pattern, P3 - Color-Tolerance, P4 - min. Hits (Pixel) maximum Number:64 . We use -10%, P5 - Debugmode 0/1

SFP.ColorTolerance|0

SFP.PixelHits|57

SFP.DebugMode|1

' Patternfile | Point-Shift| Timeout 60 Seconds

WFP.$$PAT|0,0|60

' We take away the number of Hits from TOS

POP.$$NOH

' If no Hits, jump away to Lab_NoHits.

JIZ.$$NOH=0|Lab_NoHits1

MMV.

:Lab_NoHits1

ENR.

 

 

' Alternativ you can also write:

WFP.ID:$$DTA|0,0|60

 

 

 

Syntax

 

WFP.[!]P1[|P2][|P3]

 

Parameter Explanation

 

! - If the ! is specified then the Command will wait for the Patterns to disappear, ("Wait for no Pattern")

P1 - Pattern File-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 - 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.

P3 - opt. Timeout value. If omitted the command will wait "Forever".

 

The Command will leave a the number of finds on  the TOS, followed by all finds.

 

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 did not appear in teh given Time, then you will get a result "0" on TOS and the Timeout-Flag will be set.
The program will not generate an Error-Message.

 

 

Example

 

-

 

 

Remarks

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: