@@ -293,17 +293,7 @@ public void processBuilder(String[] adbCommand) {
293
293
}
294
294
}
295
295
296
- /**
297
- * ======================================================================================
298
- * CROP IMAGE
299
- * ======================================================================================
300
- */
301
296
302
- public void findAndCropImageFromScreen (String image ) throws Exception {
303
- ImageRecognitionSettingsDTO settings = new ImageRecognitionSettingsDTO ();
304
- settings .setCrop (true );
305
- findImageOnScreen (image , settings );
306
- }
307
297
308
298
/**
309
299
* ======================================================================================
@@ -312,29 +302,17 @@ public void findAndCropImageFromScreen(String image) throws Exception {
312
302
*/
313
303
314
304
public String grabText (String image ) throws Exception {
315
- findAndCropImageFromScreen (image );
316
- String imageInput = screenshotsFolder + getScreenshotsCounter () + "_" + image + "_screenshot" + getRetryCounter () + "_" + timeDifferenceStartTest + "sec" + ".png" ;
317
- String [] tesseractCommand = {"tesseract" , imageInput , "stdout" };
318
- String value = "" ;
319
- try {
320
- ProcessBuilder p = new ProcessBuilder (tesseractCommand );
321
- Process proc = p .start ();
322
- InputStream stdin = proc .getInputStream ();
323
- InputStreamReader isr = new InputStreamReader (stdin );
324
- BufferedReader br = new BufferedReader (isr );
325
- String line ;
326
- String [] size = null ;
327
- String [] splitLines ;
328
- while ((line = br .readLine ()) != null ) {
329
- value += line ;
330
- }
331
-
332
- } catch (Throwable t ) {
333
- t .printStackTrace ();
334
- }
335
- return value ;
305
+ ImageRecognitionSettingsDTO settings = new ImageRecognitionSettingsDTO ();
306
+ settings .setCrop (true );
307
+ ImageSearchDTO imageSearch = findImageOnScreen2 (image , settings );
308
+
309
+ String imageInput = imageSearch .getScreenshotFile ();
310
+ return ImageRecognition .getTextStringFromImage (imageInput );
336
311
}
337
312
313
+
314
+
315
+
338
316
/**
339
317
* ======================================================================================
340
318
* OTHER UTILITIES
0 commit comments