Package org.sikuli.script
Class Pattern
- java.lang.Object
-
- org.sikuli.script.Pattern
-
public class Pattern extends Object
to define a more complex search target
- non-standard minimum similarity
- click target other than center
- image as in-memory image
-
-
Constructor Summary
Constructors Constructor Description Pattern()creates empty Pattern object at least setFilename() or setBImage() must be used before the Pattern object is ready for anythingPattern(BufferedImage bimg)A Pattern from a BufferedImagePattern(String imgpath)create a Pattern based on an image file namePattern(URL url)Pattern from a Java resource (Object.class.getResource)Pattern(Image img)create a Pattern with given imagePattern(Pattern p)create a new Pattern from another (attribs are copied)Pattern(ScreenImage simg)A Pattern from a ScreenImage
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PatternasMask()Patternexact()sets the minimum Similarity to 0.99 which means exact matchBufferedImagegetBImage()ONLY FOR INTERNAL USE!StringgetFilename()the current image's absolute filepath
will return null, if image is in jar or in web
use getFileURL in this caseURLgetFileURL()the current image's URLImagegetImage()get the Pattern's imageorg.opencv.core.MatgetMask()floatgetResize()doublegetSimilar()LocationgetTargetOffset()intgetTimeAfter()
TODO: Usage to be implemented!booleanhasMask()booleanisImagePattern()true if Pattern was created from ImagebooleanisValid()check wether the image is validPatternmask()Patternmask(String sMask)Patternmask(Image iMask)Patternmask(Pattern pMask)Patternresize(float factor)PatternsetBImage(BufferedImage bimg)ONLY FOR INTERNAL USE!PatternsetFilename(String fileName)set a new image for this patternPatternsetFilename(URL fileURL)set a new image for this patternPatternsetFilename(Image img)set a new image for this patternPatternsetImage(Image img)sets the Pattern's imagevoidsetTimeAfter(int secs)set the seconds to wait, after this pattern is acted onPatternsimilar(double sim)sets the minimum Similarity to use with findXPatternsimilar(float sim)PatterntargetOffset(int dx, int dy)set the offset from the match's center to be used with mouse actionsPatterntargetOffset(Location loc)set the offset from the match's center to be used with mouse actionsStringtoString()PatternwithMask()PatternwithMask(Pattern pMask)
-
-
-
Constructor Detail
-
Pattern
public Pattern()
creates empty Pattern object at least setFilename() or setBImage() must be used before the Pattern object is ready for anything
-
Pattern
public Pattern(Pattern p)
create a new Pattern from another (attribs are copied)- Parameters:
p- other Pattern
-
Pattern
public Pattern(Image img)
create a Pattern with given image- Parameters:
img- Image
-
Pattern
public Pattern(String imgpath)
create a Pattern based on an image file name- Parameters:
imgpath- image filename
-
Pattern
public Pattern(URL url)
Pattern from a Java resource (Object.class.getResource)- Parameters:
url- image file URL
-
Pattern
public Pattern(BufferedImage bimg)
A Pattern from a BufferedImage- Parameters:
bimg- BufferedImage
-
Pattern
public Pattern(ScreenImage simg)
A Pattern from a ScreenImage- Parameters:
simg- ScreenImage
-
-
Method Detail
-
resize
public Pattern resize(float factor)
-
getResize
public float getResize()
-
isImagePattern
public boolean isImagePattern()
true if Pattern was created from Image- Returns:
- true/false
-
isValid
public boolean isValid()
check wether the image is valid- Returns:
- true if image is useable
-
getMask
public org.opencv.core.Mat getMask()
-
hasMask
public boolean hasMask()
-
mask
public Pattern mask()
-
asMask
public Pattern asMask()
-
withMask
public Pattern withMask()
-
setFilename
public Pattern setFilename(String fileName)
set a new image for this pattern- Parameters:
fileName- image filename- Returns:
- the Pattern itself
-
setFilename
public Pattern setFilename(URL fileURL)
set a new image for this pattern- Parameters:
fileURL- image file URL- Returns:
- the Pattern itself
-
setFilename
public Pattern setFilename(Image img)
set a new image for this pattern- Parameters:
img- Image- Returns:
- the Pattern itself
-
getFilename
public String getFilename()
the current image's absolute filepath
will return null, if image is in jar or in web
use getFileURL in this case- Returns:
- might be null
-
getFileURL
public URL getFileURL()
the current image's URL- Returns:
- might be null
-
similar
public Pattern similar(double sim)
sets the minimum Similarity to use with findX- Parameters:
sim- value 0 to 1- Returns:
- the Pattern object itself
-
similar
public Pattern similar(float sim)
-
exact
public Pattern exact()
sets the minimum Similarity to 0.99 which means exact match- Returns:
- the Pattern object itself
-
getSimilar
public double getSimilar()
- Returns:
- the current minimum similarity
-
targetOffset
public Pattern targetOffset(int dx, int dy)
set the offset from the match's center to be used with mouse actions- Parameters:
dx- x offsetdy- y offset- Returns:
- the Pattern object itself
-
targetOffset
public Pattern targetOffset(Location loc)
set the offset from the match's center to be used with mouse actions- Parameters:
loc- Location- Returns:
- the Pattern object itself
-
getTargetOffset
public Location getTargetOffset()
- Returns:
- the current offset
-
getBImage
public BufferedImage getBImage()
ONLY FOR INTERNAL USE! Might vanish without notice!- Returns:
- might be null
-
setBImage
public Pattern setBImage(BufferedImage bimg)
ONLY FOR INTERNAL USE! Might vanish without notice!- Parameters:
bimg- BufferedImage- Returns:
- the Pattern object itself
-
setImage
public Pattern setImage(Image img)
sets the Pattern's image- Parameters:
img- Image- Returns:
- the Pattern object itself
-
getImage
public Image getImage()
get the Pattern's image- Returns:
- Image
-
setTimeAfter
public void setTimeAfter(int secs)
set the seconds to wait, after this pattern is acted on- Parameters:
secs- seconds
-
getTimeAfter
public int getTimeAfter()
TODO: Usage to be implemented! get the seconds to wait, after this pattern is acted on- Returns:
- time in seconds
-
-