@@ -35,15 +35,11 @@ public double getSceneWidth() {
35
35
return scene_width ;
36
36
}
37
37
38
- public Point [] findImage (String object_filename_nopng , String scene_filename_nopng , double tolerance ) {
38
+ public Point [] findImage (String queryImageFile , String sceneFile , double tolerance ) {
39
39
40
40
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 );
47
43
48
44
Mat resized_img_scene = new Mat ();
49
45
scene_height = img_scene .rows ();
@@ -59,16 +55,16 @@ public Point[] findImage(String object_filename_nopng, String scene_filename_nop
59
55
if (resizeFactor > 1 ) {
60
56
Size size = new Size (scene_width / resizeFactor , scene_height / resizeFactor );
61
57
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 );
64
60
logger .info ("Image was resized, resize factor is: " + resizeFactor );
65
61
lastResizeFactor = resizeFactor ;
66
62
} else
67
63
resizeFactor = 1 ;
68
64
69
65
String jsonResults = null ;
70
66
try {
71
- jsonResults = runAkazeMatch (object_filename , scene_filename );
67
+ jsonResults = runAkazeMatch (queryImageFile , sceneFile );
72
68
} catch (InterruptedException e ) {
73
69
e .printStackTrace ();
74
70
return null ;
@@ -83,7 +79,7 @@ public Point[] findImage(String object_filename_nopng, String scene_filename_nop
83
79
double initial_height = img_object .size ().height ;
84
80
double initial_width = img_object .size ().width ;
85
81
86
- Highgui .imwrite (scene_filename , img_scene );
82
+ Highgui .imwrite (sceneFile , img_scene );
87
83
88
84
//finding homography
89
85
LinkedList <Point > objList = new LinkedList <Point >();
@@ -133,7 +129,7 @@ public Point[] findImage(String object_filename_nopng, String scene_filename_nop
133
129
134
130
Mat H = Calib3d .findHomography (obj , scene );
135
131
136
- Mat scene_corners = drawFoundHomography (scene_filename_nopng , img_object , scene_filename , H );
132
+ Mat scene_corners = drawFoundHomography (img_object , sceneFile , H );
137
133
Point top_left = new Point (scene_corners .get (0 , 0 ));
138
134
Point top_right = new Point (scene_corners .get (1 , 0 ));
139
135
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
242
238
Highgui .imwrite (scene_filename , croppedImage );
243
239
}
244
240
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 ) {
246
242
Mat obj_corners = new Mat (4 , 1 , CvType .CV_32FC2 );
247
243
Mat scene_corners = new Mat (4 , 1 , CvType .CV_32FC2 );
248
244
@@ -260,7 +256,6 @@ private Mat drawFoundHomography(String scene_filename_nopng, Mat img_object, Str
260
256
Core .line (img , new Point (scene_corners .get (2 , 0 )), new Point (scene_corners .get (3 , 0 )), new Scalar (0 , 255 , 0 ), 4 );
261
257
Core .line (img , new Point (scene_corners .get (3 , 0 )), new Point (scene_corners .get (0 , 0 )), new Scalar (0 , 255 , 0 ), 4 );
262
258
263
- filename = scene_filename_nopng + ".png" ;
264
259
Highgui .imwrite (filename , img );
265
260
266
261
return scene_corners ;
0 commit comments