Java Code Examples for org.sikuli.basics.Settings#AlwaysResize

The following examples show how to use org.sikuli.basics.Settings#AlwaysResize . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Finder.java    From SikuliX1 with MIT License 6 votes vote down vote up
private Mat possibleImageResizeOrCallback(Image img, float oneTimeResize) {
  double factor = oneTimeResize;
  if (factor == 0 && Settings.AlwaysResize > 0 && Settings.AlwaysResize != 1) {
    factor = Settings.AlwaysResize;
  }
  Mat mat = SXOpenCV.makeMat(img.getBufferedImage(), false);
  if (factor > 0 && factor != 1) {
    Debug.log(3, "Finder::possibleImageResizeOrCallback: resize");
    if (!mat.empty()) {
      SXOpenCV.resize(mat, factor);
    }
  } else if (Settings.ImageCallback != null) {
    Debug.log(3, "Finder::possibleImageResizeOrCallback: callback");
    BufferedImage newBimg = Settings.ImageCallback.callback(img);
    mat = SXOpenCV.makeMat(newBimg, false);
  }
  if (mat.empty()) {
    log(-1, "%s: conversion error --- find will fail", img);
  }
  return mat;
}
 
Example 2
Source File: FindAttributes.java    From SikuliX1 with MIT License 5 votes vote down vote up
private Mat possibleImageResizeOrCallback(Image image, Mat what) {
  Mat originalContent = what;
  if (Settings.ImageCallback != null) {
    Mat contentResized = SXOpenCV.makeMat(Settings.ImageCallback.callback(image), false);
    if (!contentResized.empty()) {
      return contentResized;
    }
  } else {
    double factor = image.resize() == 1 ? Settings.AlwaysResize : image.resize();
    if (factor > 0.1 && factor != 1) {
      return SXOpenCV.cvResize(originalContent.clone(), factor, Image.Interpolation.CUBIC);
    }
  }
  return originalContent;
}
 
Example 3
Source File: SXTest.java    From SikuliX1 with MIT License 5 votes vote down vote up
public void setUpBase() {
  Settings.NewAPI = true;
  Settings.AlwaysResize = 1;
  Settings.CheckLastSeen = false;
  if (null == bundlePath) {
    setUpTime = new Date().getTime();
    File bundleFile = new File(runTime.fWorkDir, "src/main/resources/images");
    ImagePath.setBundleFolder(bundleFile);
    bundlePath = ImagePath.getBundlePath();
    setUpTime = new Date().getTime() - setUpTime;
  }
}
 
Example 4
Source File: ElementImageTest.java    From SikuliX1 with MIT License 5 votes vote down vote up
@Test
  public void test090_ImageFindResizeUp() {
    testIntro();
    Image shot = new Image(testBaseX2);
    Assert.assertTrue("", shot.isValid());
    Match match = null;
    Settings.AlwaysResize = 2;
    try {
      match = shot.find(testName);
    } catch (FindFailed findFailed) {
    }
//    Image.resetCache();
    testOutro("%s in %s is %s", testName, shot, match);
    Assert.assertNotNull(testName + " not found in " + testBaseX2, match);
  }
 
Example 5
Source File: ElementImageTest.java    From SikuliX1 with MIT License 5 votes vote down vote up
@Test
public void test091_ImageFindResizeOff() {
  testIntro();
  Image shot = new Image(testBase);
  Assert.assertTrue("", shot.isValid());
  Match match = null;
  Settings.AlwaysResize = 1;
  try {
    match = shot.find(testName);
  } catch (FindFailed findFailed) {
  }
  testOutro("%s in %s is %s", testName, shot, match);
  Assert.assertNotNull(testName + " not found", match);
}
 
Example 6
Source File: ElementImageTest.java    From SikuliX1 with MIT License 5 votes vote down vote up
@Test
public void test092_ImageFindResizeDown() {
  testIntro();
  Image shot = new Image(testBase);
  Assert.assertTrue("", shot.isValid());
  Match match = null;
  Settings.AlwaysResize = 0.5;
  try {
    match = shot.find(testNameX2);
  } catch (FindFailed findFailed) {
  }
  Image.resetCache();
  testOutro("%s in %s is %s", testName, shot, match);
  Assert.assertNotNull(testNameX2 + " not found", match);
}