Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support appium #583

Open
wants to merge 9 commits into
base: release_2.0.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions API/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

<modelVersion>4.0.0</modelVersion>

<groupId>com.sikulix</groupId>
<groupId>io.github.thinhdnn</groupId>
<artifactId>sikulixapi</artifactId>
<version>2.0.6-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>

<packaging>jar</packaging>

Expand All @@ -35,27 +35,27 @@
</developers>

<scm>
<connection>scm:git:[email protected]:RaiMan/SikuliX1.git</connection>
<developerConnection>scm:git:[email protected]:RaiMan/SikuliX1.git</developerConnection>
<url>[email protected]:RaiMan/SikuliX1.git</url>
<connection>scm:git:[email protected]:thinhdnn/SikuliX1.git</connection>
<developerConnection>scm:git:[email protected]:thinhdnn/SikuliX1.git</developerConnection>
<url>[email protected]:thinhdnn/SikuliX1.git</url>
</scm>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>maven</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<repositories>
<repository>
<id>OSSRH</id>
<id>ossrh</id>
<snapshots></snapshots>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>

Expand Down
3 changes: 2 additions & 1 deletion API/src/main/java/org/sikuli/script/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -781,9 +781,10 @@ public List<List<Match>> getAnyAll(double time, List<Object> targets) {
long maxDuration = 0;
for (Future result : fResults) {
try {
results.add(0L);
Object[] current = (Object[]) result.get();
maxDuration = Math.max((Long) current[1], maxDuration);
results.add((Integer) current[0], (Long) current[1]);
results.set((Integer) current[0], (Long) current[1]);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
Expand Down
187 changes: 187 additions & 0 deletions API/src/main/java/org/sikuli/script/ImageAsScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
package org.sikuli.script;

import org.sikuli.script.support.IRobot;
import org.sikuli.script.support.IScreen;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;

public class ImageAsScreen extends Region implements IScreen {

protected BufferedImage image;
private Dimension dimension = new Dimension(700, 1000);

public ImageAsScreen() {
}

public void setImage(BufferedImage image) {
this.image = image;
}

public void setDimension(Dimension dimension) {
this.dimension = dimension;
}

ScreenImage toImage(Rectangle roi) {
if (this.image == null) {
BufferedImage image = new BufferedImage(this.dimension.width, this.dimension.height,
BufferedImage.TYPE_INT_RGB);
return new ScreenImage(roi, image);
} else {
return new ScreenImage(roi, this.image);
}
}

private Rectangle dimensionRectangle() {
return new Rectangle(0, 0, this.dimension.width, this.dimension.height);
}

@Override
public int getID() {
return 1;
}

@Override
public int getIdFromPoint(int srcx, int srcy) {
return 1;
}

@Override
public String getIDString() {
return Integer.toString(1);
}

@Override
public IRobot getRobot() {
return null;
}

@Override
public ScreenImage capture() {
return toImage(dimensionRectangle());
}

@Override
public ScreenImage capture(int x, int y, int w, int h) {
return toImage(new Rectangle(x, y, w, h));
}

@Override
public ScreenImage capture(Rectangle rect) {
return toImage(rect);
}

@Override
public ScreenImage capture(Region reg) {
Rectangle rect = new Rectangle(reg.x, reg.y, reg.w, reg.h);
return toImage(rect);
}

@Override
public ScreenImage userCapture(String string) {
throw new IllegalStateException("Not implemented: userCapture");
}

@Override
public ScreenImage getLastScreenImageFromScreen() {
return toImage(dimensionRectangle());
}

@Override
public String getLastScreenImageFile(String path, String name) throws IOException {
throw new IllegalStateException("Not implemented: getLastScreenImageFile");
}

@Override
public int getX() {
return 0;
}

@Override
public int getW() {
return dimension.width;
}

@Override
public int getY() {
return 0;
}

@Override
public int getH() {
return dimension.height;
}

@Override
public Rectangle getBounds() {
return dimensionRectangle();
}

@Override
public Rectangle getRect() {
return dimensionRectangle();
}

@Override
public boolean isOtherScreen() {
return true;
}

@Override
public Region setOther(Region element) {
return element.setOtherScreen(this);
}

@Override
public Location setOther(Location element) {
return element.setOtherScreen(this);
}

@Override
public Location newLocation(int x, int y) {
return new Location(x, y).setOtherScreen(this);
}

@Override
public Location newLocation(Location loc) {
return (new Location(loc)).copyTo(this);
}

@Override
public Region newRegion(int x, int y, int w, int h) {
Location loc = new Location(x, y);
loc.setOtherScreen(this);
return newRegion(loc, w, h);
}

@Override
public Region newRegion(Location loc, int width, int height) {
Location loc2 = loc.copyTo(this);
loc2.setOtherScreen(this);
return Region.create(loc2, width, height);
}

@Override
public Region newRegion(Region reg) {
throw new IllegalStateException("Not implemented: newRegion");
}

@Override
public void waitAfterAction() {

}

@Override
public Object action(String action, Object... args) {
return null;
}

@Override
public String toString() {
return "ImageAsScreen{" +
"image=" + image +
", dimension=" + dimension +
'}';
}
}
18 changes: 18 additions & 0 deletions API/src/main/java/org/sikuli/script/OCR.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public Options clone() {
options.language = language;
options.dataPath = dataPath;
options.isLightFont = isLightFont;
options.isGrayFont = isGrayFont;
options.textHeight = textHeight;
options.resizeInterpolation = resizeInterpolation;
options.variables = new LinkedHashMap<>(variables);
Expand Down Expand Up @@ -171,6 +172,7 @@ public Options reset() {
language = "eng";
dataPath = null;
isLightFont = false;
isGrayFont = false;
textHeight = getDefaultTextHeight();
resizeInterpolation = Image.Interpolation.LINEAR;
variables.clear();
Expand Down Expand Up @@ -437,6 +439,22 @@ public boolean isLightFont() {
return isLightFont;
}

private boolean isGrayFont = false;

public Options grayFont() {
isGrayFont = true;
return this;
}
public boolean isGrayFont() {
return isGrayFont;
}

public Options resetFontSetting() {
isLightFont = false;
isGrayFont = false;
return this;
}

/**
* Convenience: Configure the Option's optimization.
* <p>
Expand Down
5 changes: 5 additions & 0 deletions API/src/main/java/org/sikuli/script/TextRecognizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ private BufferedImage optimize(BufferedImage bimg) {
// else if (Core.mean(mimg).val[0] < 127) {
// Core.bitwise_not(mimg, mimg);
// }

if (options.isGrayFont()) {
Imgproc.adaptiveThreshold(mimg, mimg, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C,
Imgproc.THRESH_BINARY, 17, 10);
}

return Image.getBufferedImage(mimg);
}
Expand Down
25 changes: 18 additions & 7 deletions IDE/pom.xml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<modelVersion>4.0.0</modelVersion>

<groupId>com.sikulix</groupId>
<groupId>io.github.thinhdnn</groupId>
<artifactId>sikulixide</artifactId>
<version>2.0.6-SNAPSHOT</version>

Expand All @@ -33,16 +33,27 @@
</developers>

<scm>
<connection>scm:git:[email protected]:RaiMan/SikuliX1.git</connection>
<developerConnection>scm:git:[email protected]:RaiMan/SikuliX1.git</developerConnection>
<url>[email protected]:RaiMan/SikuliX1.git</url>
<connection>scm:git:[email protected]:thinhdnn/SikuliX1.git</connection>
<developerConnection>scm:git:[email protected]:thinhdnn/SikuliX1.git</developerConnection>
<url>[email protected]:thinhdnn/SikuliX1.git</url>
</scm>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>maven</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<repositories>
<repository>
<id>OSSRH</id>
<id>ossrh</id>
<snapshots></snapshots>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>

Expand Down Expand Up @@ -96,7 +107,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.4.1</version>
<version>2.13.4.2</version>
</dependency>
</dependencies>

Expand Down