Modifying a read and readLine Method
Hi,
I'm trying to read values displaying in a website. The values I'm reading are changing multiple times a second for example 2.01, 9.11, 12.43 and so and I read these values every second.
The image i'm capturing have red values in colour and the background have stripes (lines). I'm using Tesseract Tess4J-4.5.4 in java and I use the below methods which modify the image and text background, remove stripes in an image and I get 100 % results all the time.
The challenge is I have to take a screenshot every second and the BufferedImage
is slowing my problem considerably and stopping it with full memory exception.
I try to use the flush() method to flush the BufferedImage but I still get the same problem.
I now use SikuliXapi Version-2.0.5 for Windows. I use these methods region.text() or region.textLine() and the slowing down of the program has improved considerably and it almost gone to the point that I decided to use Sikuli alone. The
challenge now is that the results I get from Sikuli are about 70 % and based on my program I need the results to be 100 % all the time.
Now my question is using Sikuli and looking at my below code, how can I add the "CHANGE IMAGE BACKGROUND AND TEXT" and "REMOVING STRIPES ON AN IMAGE" to my sikuli code so I can get the
100 % resuls? Is there a way to do this kind of modification in Sikuli?
MY CODE:
//METHOD START
private static void readValue() throws IOException, AWTException, InterruptedExce
Tesseract tessEndValue = new Tesseract();
tessEndValue.
tessEndValue.
Rectangle regionEndValue = new Rectangle(
BufferedImage readEndValueimage = robot.createScr
//CHANGE IMAGE BACKGROUND AND TEXT
for (int a = 0; a < readEndValueima
for (int b = 0; b < readEndValueima
int rgba = readEndValueima
Color col = new Color(rgba, true);
col = new Color(255 - col.getRed(), 255 - col.getGreen(), 255 - col.getBlue());
readEndValueima
}}
//REMOVING STRIPES ON AN IMAGE
Color lightest = Color.BLACK;
Color darkest = Color.WHITE;
for (int x = 0; x < readEndValueima
for (int y = 0; y < readEndValueima
Color color = new Color(readEndVa
if (isDarker(color, darkest)) darkest = color;
if (isLighter(color, lightest)) lightest = color;
}}
for (int x = 0; x < readEndValueima
for (int y = 0; y < readEndValueima
Color color = new Color(readEndVa
if (differenceSqua
readEndValueima
}
else {
readEndValueima
}
}}
String endValue = tessEndValue.
}
catch(Exception e) {
System.
}
}
//METHOD ENDS
private static boolean isLighter(Color color, Color lightest) {
return ( (color.getRed() + color.getGreen() + color.getBlue()) > (lightest.getRed() +
lightest.getGreen() + lightest.getBlue()) );
}
private static boolean isDarker(Color color, Color darkest) {
return ( (color.getRed() + color.getGreen() + color.getBlue()) < (darkest.getRed() +
darkest.getGreen() + darkest.getBlue()) );
}
private static double differenceSquar
return Math.pow(a.getRed() - b.getRed(), 2) + Math.pow(
Math.pow(
}
Thank you!
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- sibusiso mbambo
- Solved:
- Last query:
- Last reply: