@@ -29,11 +29,29 @@ private static void log(String message) {
2929 AkazeImageFinder .setupOpenCVEnv ();
3030 }
3131
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+ */
3241 public static ImageLocation findImage (String searchedImageFilePath , String sceneImageFilePath , PlatformType platform ) throws Exception {
3342 ImageRecognitionSettings setting = new ImageRecognitionSettings ();
3443 return findImage (searchedImageFilePath , sceneImageFilePath , setting , platform );
3544 }
3645
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+ */
3755 public static ImageLocation findImage (String searchedImageFilePath , String sceneImageFilePath , ImageRecognitionSettings settings , PlatformType platform ) throws Exception {
3856 log ("Searching for " + searchedImageFilePath );
3957 log ("Searching in " + sceneImageFilePath );
@@ -95,6 +113,15 @@ private static boolean isPointInsideScreenBounds(Point center, Dimension screenS
95113 }
96114
97115
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+ */
98125 public static boolean hasImageDissappearedFromScreenBeforeTimeout (String searchedImageFilePath ,
99126 String screenshotBaseDirectory , PlatformType platform ) throws Exception {
100127 log ("==> Trying to find image: " + searchedImageFilePath );
@@ -114,6 +141,12 @@ public static boolean hasImageDissappearedFromScreenBeforeTimeout(String searche
114141 return false ;
115142 }
116143
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+ */
117150 public static String getTextStringFromImage (String imageInput ) {
118151 String [] tesseractCommand = {"tesseract" , imageInput , "stdout" };
119152 String value = "" ;
@@ -137,8 +170,18 @@ public static String getTextStringFromImage(String imageInput) {
137170
138171
139172
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 );
142185 if (imageSearchResult .isFound () && settings .isCrop ()) {
143186 log ("Cropping image.." );
144187 imageFinder .cropImage (imageSearchResult );
0 commit comments