@@ -29,11 +29,29 @@ private static void log(String message) {
29
29
AkazeImageFinder .setupOpenCVEnv ();
30
30
}
31
31
32
+
33
+ /**
34
+ * Find the location of the reference image on the screen
35
+ *
36
+ * @param searchedImageFilePath Path to the reference image file to be searched
37
+ * @param sceneImageFilePath Path to the scene file in which the image is going to be searched for
38
+ * @param platform Defines the platform (phone operating system) that is in use. PlatformType.ANDROID for Android and PlatformType.IOS for iOS
39
+ * @return Returns the location of the image or null if image has not been found
40
+ */
32
41
public static ImageLocation findImage (String searchedImageFilePath , String sceneImageFilePath , PlatformType platform ) throws Exception {
33
42
ImageRecognitionSettings setting = new ImageRecognitionSettings ();
34
43
return findImage (searchedImageFilePath , sceneImageFilePath , setting , platform );
35
44
}
36
45
46
+ /**
47
+ * Find the location of the reference image on the screen
48
+ * @param searchedImageFilePath Path to the reference image file to be searched
49
+ * @param sceneImageFilePath Path to the scene file in which the image is going to be searched for
50
+ * @param settings Image recognition related settings
51
+ * @param platform Defines the platform (phone operating system) that is in use. PlatformType.ANDROID for Android and PlatformType.IOS for iOS
52
+ * @return Returns the location of the image or null if image has not been found
53
+ * @throws Exception
54
+ */
37
55
public static ImageLocation findImage (String searchedImageFilePath , String sceneImageFilePath , ImageRecognitionSettings settings , PlatformType platform ) throws Exception {
38
56
log ("Searching for " + searchedImageFilePath );
39
57
log ("Searching in " + sceneImageFilePath );
@@ -95,6 +113,15 @@ private static boolean isPointInsideScreenBounds(Point center, Dimension screenS
95
113
}
96
114
97
115
116
+ /**
117
+ * Checks whether image disappears from screen before a predefined timeout.
118
+ *
119
+ * @param searchedImageFilePath Path to the reference image file to be searched
120
+ * @param screenshotBaseDirectory Path to the directory in which the screenshots should be stored
121
+ * @param platform Defines the platform (phone operating system) that is in use. PlatformType.ANDROID for Android and PlatformType.IOS for iOS
122
+ * @return True if the image cannot be found or disappears successfully. False if the image can be found and the function timeouts.
123
+ * @throws Exception
124
+ */
98
125
public static boolean hasImageDissappearedFromScreenBeforeTimeout (String searchedImageFilePath ,
99
126
String screenshotBaseDirectory , PlatformType platform ) throws Exception {
100
127
log ("==> Trying to find image: " + searchedImageFilePath );
@@ -114,6 +141,12 @@ public static boolean hasImageDissappearedFromScreenBeforeTimeout(String searche
114
141
return false ;
115
142
}
116
143
144
+ /**
145
+ * Extract text from an image.
146
+ *
147
+ * @param imageInput Path to the image file in which a text should be found
148
+ * @return The found text in the image.
149
+ */
117
150
public static String getTextStringFromImage (String imageInput ) {
118
151
String [] tesseractCommand = {"tesseract" , imageInput , "stdout" };
119
152
String value = "" ;
@@ -137,8 +170,18 @@ public static String getTextStringFromImage(String imageInput) {
137
170
138
171
139
172
140
- public static ImageSearchResult findImageOnScreen (String searchedImagePath , String screenshotBaseDirectory , ImageRecognitionSettings settings , PlatformType platform ) throws InterruptedException , IOException , Exception {
141
- ImageSearchResult imageSearchResult = findImageLoop (searchedImagePath , screenshotBaseDirectory , settings , platform );
173
+ /**
174
+ * @param searchedImageFilePath Path to the reference image file to be searched
175
+ * @param screenshotBaseDirectory Path to the directory in which the screenshots should be stored
176
+ * @param settings Image recognition related settings
177
+ * @param platform Defines the platform (phone operating system) that is in use. PlatformType.ANDROID for Android and PlatformType.IOS for iOS
178
+ * @return ImageSearchResult, an object containing information about the location of the found image and a screenshot from the moment the reference image was found.
179
+ * @throws InterruptedException
180
+ * @throws IOException
181
+ * @throws Exception
182
+ */
183
+ public static ImageSearchResult findImageOnScreen (String searchedImageFilePath , String screenshotBaseDirectory , ImageRecognitionSettings settings , PlatformType platform ) throws InterruptedException , IOException , Exception {
184
+ ImageSearchResult imageSearchResult = findImageLoop (searchedImageFilePath , screenshotBaseDirectory , settings , platform );
142
185
if (imageSearchResult .isFound () && settings .isCrop ()) {
143
186
log ("Cropping image.." );
144
187
imageFinder .cropImage (imageSearchResult );
0 commit comments