26
26
public class AkazeImageFinder {
27
27
28
28
private static final Logger logger = LoggerFactory .getLogger (AkazeImageFinder .class );
29
- double lastResizeFactor ; //TODO Severi remove this
30
29
31
30
public double getSceneHeight (String sceneFile ) {
32
31
Mat img_scene = Highgui .imread (sceneFile , Highgui .CV_LOAD_IMAGE_UNCHANGED );
@@ -64,9 +63,9 @@ public ImageLocation findImage(String queryImageFile, String sceneFile, double t
64
63
Highgui .imwrite (sceneFile , resized_img_scene );
65
64
img_scene = Highgui .imread (sceneFile , Highgui .CV_LOAD_IMAGE_UNCHANGED );
66
65
logger .info ("Image was resized, resize factor is: " + resizeFactor );
67
- lastResizeFactor = resizeFactor ;
68
- } else
69
- resizeFactor = 1 ;
66
+ } else {
67
+ resizeFactor = 1 ;
68
+ }
70
69
71
70
String jsonResults = null ;
72
71
try {
@@ -240,6 +239,7 @@ public ImageLocation findImage(String queryImageFile, String sceneFile, double t
240
239
location .setBottomRight (points [2 ]);
241
240
location .setBottomLeft (points [3 ]);
242
241
location .setCenter (centerOriginal );
242
+ location .setResizeFactor (resizeFactor );
243
243
244
244
return location ;
245
245
}
@@ -250,19 +250,15 @@ public void cropImage(ImageSearchDTO imageDto) {
250
250
double width = imageDto .getImageLocation ().getWidth ();
251
251
double height = imageDto .getImageLocation ().getHeight ();
252
252
String scene_filename = imageDto .getScreenshotFile ();
253
-
254
- log ("x: " +x );
255
- log ("y: " +y );
256
- log ("width:" +width );
257
- log ("height: " +height );
258
- log ("lastResizeFactor: " +lastResizeFactor );
253
+ int scaleFactor = imageDto .getImageLocation ().getScaleFactor ();
254
+ double resizeFactor = imageDto .getImageLocation ().getResizeFactor ();
259
255
260
256
Mat img_object = Highgui .imread (scene_filename );
261
257
262
- int x_resized = (int ) (x / lastResizeFactor ) ;
263
- int y_resized = (int ) (y / lastResizeFactor ) ;
264
- int width_resized = (int ) (width / lastResizeFactor ) ;
265
- int height_resized = (int ) (height / lastResizeFactor ) ;
258
+ int x_resized = (int ) (x / resizeFactor )* scaleFactor ;
259
+ int y_resized = (int ) (y / resizeFactor )* scaleFactor ;
260
+ int width_resized = (int ) (width / resizeFactor )* scaleFactor ;
261
+ int height_resized = (int ) (height / resizeFactor )* scaleFactor ;
266
262
Rect croppedRect = new Rect (x_resized , y_resized , width_resized , height_resized );
267
263
log (img_object .toString ());
268
264
log (croppedRect .toString ());
0 commit comments