Image/Pixel-Color Operations

<< Click to Display Table of Contents >>

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

Image/Pixel-Color Operations

IFP.- / NFP. - If Find Pattern

Previous Top Next


MiniRobotLanguage (MRL)

 

IFP. - If Find Pattern
NFP. - Not Find Pattern

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

 

 

Intention

 

This command will  just check if a specified Pattern can be found or not.

 

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 1 Pattern and 3 Parameter which are similar to the Parameters in LFP.

 

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

 

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

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

 

The IFP./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 IFP. is an enhanced Version of the WFP.-Command, as it has the same Parameters. With the difference that if you do NOT specify  the Timeout-Value P3,

 

then WFP. will "wait forever" while IFP. will "return immediately". You can change this behavior with the P3-Value. Generally "0" means "wait forever" while "-1" means "return immediately".

 

Please see the LFP.-Commands for more  Details.

 

1. Use IFP 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

' P1 - Pattern-File, P2 - Target-Position adjust

IFP.$$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.

 

 

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 IFP. / NFP.

 

You can change more advanced Parameters that IFP. 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

IFP.$$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

 

IFP.P1[|P2][|P3][|P4] ... ELS. ... EIF.

NFP.P1[|P2][|P3][|P4] ... ELS. ... EIF.

 

Parameter Explanation

 

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

 

P4 - 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 P3 (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: