diff --git a/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/MainActivity.java b/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/MainActivity.java index 32a82c6fa0e31275c70857034711edd866347a75..f932718dcab99e59e63ccf341c35de9c547926cb 100644 --- a/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/MainActivity.java +++ b/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/MainActivity.java @@ -280,20 +280,13 @@ public class MainActivity extends AppCompatActivity { tvStatus.setText("STATUS: run model failed"); } - public void onImageChanged(Bitmap image) { - // Rerun model if users pick test image from gallery or camera - if (image != null && predictor.isLoaded()) { - predictor.setInputImage(image); - runModel(); - } - } - public void set_img() { // Load test image from path and run model try { assetManager = getAssets(); InputStream in = assetManager.open(imagePath); Bitmap bmp = BitmapFactory.decodeStream(in); + cur_predict_image = bmp; ivInputImage.setImageBitmap(bmp); } catch (IOException e) { Toast.makeText(MainActivity.this, "Load image failed!", Toast.LENGTH_SHORT).show(); @@ -420,7 +413,7 @@ public class MainActivity extends AppCompatActivity { Cursor cursor = managedQuery(uri, proj, null, null, null); cursor.moveToFirst(); if (image != null) { -// onImageChanged(image); + cur_predict_image = image; ivInputImage.setImageBitmap(image); } } catch (IOException e) { @@ -441,7 +434,7 @@ public class MainActivity extends AppCompatActivity { Bitmap image = BitmapFactory.decodeFile(currentPhotoPath); image = Utils.rotateBitmap(image, orientation); if (image != null) { -// onImageChanged(image); + cur_predict_image = image; ivInputImage.setImageBitmap(image); } } else { @@ -464,14 +457,14 @@ public class MainActivity extends AppCompatActivity { } public void btn_run_model_click(View view) { - cur_predict_image = ((BitmapDrawable) ivInputImage.getDrawable()).getBitmap(); - if (cur_predict_image == null) { + Bitmap image = ((BitmapDrawable) ivInputImage.getDrawable()).getBitmap(); + if (image == null) { tvStatus.setText("STATUS: image is not exists"); } else if (!predictor.isLoaded()) { tvStatus.setText("STATUS: model is not loaded"); } else { tvStatus.setText("STATUS: run model ...... "); - predictor.setInputImage(cur_predict_image); + predictor.setInputImage(image); runModel(); } } diff --git a/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/Predictor.java b/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/Predictor.java index b977bfb5249b2a828f1205983e64c9d0d6e8d658..ab312161d14ba2c1cdbad278b248bd68b042ed39 100644 --- a/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/Predictor.java +++ b/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/Predictor.java @@ -230,7 +230,7 @@ public class Predictor { OcrResultModel result = results.get(i); StringBuilder sb = new StringBuilder(""); if(result.getPoints().size()>0){ - sb.append("; Det: "); + sb.append("Det: "); for (Point p : result.getPoints()) { sb.append("(").append(p.x).append(",").append(p.y).append(") "); }