Image/Pixel-Color Operations

<< Click to Display Table of Contents >>

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

Image/Pixel-Color Operations

JFP.- / JNP. - Jump If Find Pattern

Previous Top Next


MiniRobotLanguage (MRL)

 

JFP. - Jump if Find Pattern
JNP. - Jump if Not Find Pattern

 
Check if a specified Pattern can be found in an Image-Register (IR) and if so Jump to a Label

 

 

Intention

 

This command check if a specified Pattern can be found or not. If the Condition is met, the Jump to the specified Label will be made.

 

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 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 differnece 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. Genrally "0" means "wait forever" while "-1" means "return immediately".

 

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

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

 

JFP.P1[|P2][|P3][|P4]

JNP.P1[|P2][|P3][|P4]

 

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 - Label - Label where the Jump will go if the condition is met. With the SPR Labels can also be dynamic and in Variables.

 

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, this is the default option.

 

The Command will leave the number of finds on 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: