Image/Pixel-Color Operations

<< Click to Display Table of Contents >>

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

Image/Pixel-Color Operations

ITP.- / NFP. - If Find Pattern

Previous Top Next


MiniRobotLanguage (MRL)

 

ITP. - If Find Pattern
NFP. - Not Find Pattern

 
Check if a specified Pattern can be found in an Image-Register (IR)

 

 

Intention

 

This command will check if at least one of two specified Pattern will be found in the specified IR.

You will find the number of the Pattern (1 or 2) that has appeared on the TOS below the Coordinates.

 

It will then find the Locations where the specified Object is and locate the Coordinates immediately.

 

The command 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 and use the "Not Found branch" after the "ELS." Command.

 

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

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

 

If the Pattern can be found, it will then find the Locations where a specified Object is in an Image.

And put the number of found occurrences on the TOS, as well as all occurrences limited by the Setting of MaxResults (See SFP.-Command).

It uses only 2  Pattern and optional 3 Parameter which are similar to the Parameters in LTP.

 

NTP. is generally just the Opposite of ITP. technically just the Blocks of "IF .(Block 1). ELS. .(Block 2). EIF." are swapped for NTP.

 

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

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

 

The ITP./NFP.-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.

 

Technically the ITP. is an enhanced Version of the WTP.-Command, as it has the same Parameters. With the difference that if you do NOT specify  the Timeout-Value P3, then WTP. will "wait forever" while ITP. will "return immediately". You can change this behavior with the P3-Value. Genrally "0" means "wait forever" while "-1" means "return immediately".

 

Please see the LTP.-Commands for more  Details.

 

1. Use ITP 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.ct|PBWindowClass:0|JK - IDE 2.

SWP.0,0|2807,1800|T

$$LAA=?pattern\JK_8.bmp

$$LAB=?pattern\JK_10.bmp

' P1/P2 - Pattern-Files, P3 - Target-Position adjust

ITP.$$LAA|$$LAB|0,50

   MMV.

ELS.

   MBX.Pattern was not found.

EIF.

' And here the same Sample using NFP.

NTP.$$LAA|$$LAB|0,50

   MBX.Pattern was not found.

ELS.

   MMV.

EIF.

ENR.

 

 

WFP_Stack

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.

 

 

2. Advance Use of ITP. / NTP.

 

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

You can use Inline-Data using "ID:$$DTA".

And you can use directly pictures in an Image-Register - for example 1 - using "IR:1"

 

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

ITP.$$LAA|0,50

   MMV.

ELS.

   MBX.Pattern was not found.

EIF.

' And here the same Sample using NFP.

NFP.$$LAA|0,50

   MBX.Pattern was not found.

ELS.

   MMV.

EIF.

ENR.

 

 

 

Syntax

 

ITP.P1|P2[|P3][|P4][|P5] ... ELS. ... EIF.

NTP.P1|P2[|P3][|P4][|P5] ... ELS. ... EIF.

 

Parameter Explanation

 

P1 - Pattern A 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 - Pattern B 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.

 

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. Wait-Time in Seconds Command will wait until the time is over if that Pattern will appear.

                   If  not specified the Command will return immediately. If 0 is specified the command will wait "Forever". If "-1" is specified the command will not wait and therefore return immediately.

 

P5 - opt. Variable for Result. This variable will contain the number of Finds.
                   If omitted the result will be placed on TOS.

 

The Command will leave a the number of finds in P5 (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 be 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

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: