Skip to content
This repository was archived by the owner on Dec 7, 2020. It is now read-only.

Commit 005cf0a

Browse files
author
Severi Haverila
committed
working version on ios
1 parent 66abbba commit 005cf0a

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ target/
22
testdroid.properties
33
run-tests.sh
44
*.zip
5+
application.ipa
6+
application.apk

src/main/java/library/AkazeImageFinder.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,11 @@ public double getSceneWidth() {
3535
return scene_width;
3636
}
3737

38-
public Point[] findImage(String object_filename_nopng, String scene_filename_nopng, double tolerance) {
38+
public Point[] findImage(String queryImageFile, String sceneFile, double tolerance) {
3939

4040
long start_time = System.nanoTime();
41-
42-
String object_filename = object_filename_nopng + ".png";
43-
String scene_filename = scene_filename_nopng + ".png";
44-
45-
Mat img_object = Highgui.imread(object_filename, Highgui.CV_LOAD_IMAGE_UNCHANGED);
46-
Mat img_scene = Highgui.imread(scene_filename, Highgui.CV_LOAD_IMAGE_UNCHANGED);
41+
Mat img_object = Highgui.imread(queryImageFile, Highgui.CV_LOAD_IMAGE_UNCHANGED);
42+
Mat img_scene = Highgui.imread(sceneFile, Highgui.CV_LOAD_IMAGE_UNCHANGED);
4743

4844
Mat resized_img_scene = new Mat();
4945
scene_height = img_scene.rows();
@@ -59,16 +55,16 @@ public Point[] findImage(String object_filename_nopng, String scene_filename_nop
5955
if (resizeFactor > 1) {
6056
Size size = new Size(scene_width / resizeFactor, scene_height / resizeFactor);
6157
resize(img_scene, resized_img_scene, size);
62-
Highgui.imwrite(scene_filename, resized_img_scene);
63-
img_scene = Highgui.imread(scene_filename, Highgui.CV_LOAD_IMAGE_UNCHANGED);
58+
Highgui.imwrite(sceneFile, resized_img_scene);
59+
img_scene = Highgui.imread(sceneFile, Highgui.CV_LOAD_IMAGE_UNCHANGED);
6460
logger.info("Image was resized, resize factor is: " + resizeFactor);
6561
lastResizeFactor = resizeFactor;
6662
} else
6763
resizeFactor = 1;
6864

6965
String jsonResults = null;
7066
try {
71-
jsonResults = runAkazeMatch(object_filename, scene_filename);
67+
jsonResults = runAkazeMatch(queryImageFile, sceneFile);
7268
} catch (InterruptedException e) {
7369
e.printStackTrace();
7470
return null;
@@ -83,7 +79,7 @@ public Point[] findImage(String object_filename_nopng, String scene_filename_nop
8379
double initial_height = img_object.size().height;
8480
double initial_width = img_object.size().width;
8581

86-
Highgui.imwrite(scene_filename, img_scene);
82+
Highgui.imwrite(sceneFile, img_scene);
8783

8884
//finding homography
8985
LinkedList<Point> objList = new LinkedList<Point>();
@@ -133,7 +129,7 @@ public Point[] findImage(String object_filename_nopng, String scene_filename_nop
133129

134130
Mat H = Calib3d.findHomography(obj, scene);
135131

136-
Mat scene_corners = drawFoundHomography(scene_filename_nopng, img_object, scene_filename, H);
132+
Mat scene_corners = drawFoundHomography(img_object, sceneFile, H);
137133
Point top_left = new Point(scene_corners.get(0, 0));
138134
Point top_right = new Point(scene_corners.get(1, 0));
139135
Point bottom_left = new Point(scene_corners.get(3, 0));
@@ -242,7 +238,7 @@ public void cropImage(String scene_filename_nopng, double x, double y, double wi
242238
Highgui.imwrite(scene_filename, croppedImage);
243239
}
244240

245-
private Mat drawFoundHomography(String scene_filename_nopng, Mat img_object, String filename, Mat h) {
241+
private Mat drawFoundHomography(Mat img_object, String filename, Mat h) {
246242
Mat obj_corners = new Mat(4, 1, CvType.CV_32FC2);
247243
Mat scene_corners = new Mat(4, 1, CvType.CV_32FC2);
248244

@@ -260,7 +256,6 @@ private Mat drawFoundHomography(String scene_filename_nopng, Mat img_object, Str
260256
Core.line(img, new Point(scene_corners.get(2, 0)), new Point(scene_corners.get(3, 0)), new Scalar(0, 255, 0), 4);
261257
Core.line(img, new Point(scene_corners.get(3, 0)), new Point(scene_corners.get(0, 0)), new Scalar(0, 255, 0), 4);
262258

263-
filename = scene_filename_nopng + ".png";
264259
Highgui.imwrite(filename, img);
265260

266261
return scene_corners;

src/test/java/iOSSample.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public void mainPageTest() throws Exception {
5656
log("Keyboard not present; going forward.");
5757
}
5858

59-
findImageOnScreen("bitbar_logo");
59+
findImageOnScreen("bitbar_logo.png");
60+
// waitForImageToDisappearFromScreen("bitbar_logo.png");
6061
log("Success.");
6162
}
6263
}

0 commit comments

Comments
 (0)