mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 00:33:03 +08:00
[Android] Configure face recognition and segmentation details page (#619)
* 1.Classification Code submission; 2.Specification code format. * Specification code format. * Update strings.xml * 1.Display ocr, detection and classification results. 2.Specification code format. * Configure face recognition and semantic segmentation details page. Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package com.baidu.paddle.fastdeploy.app.examples.classification;
|
||||
|
||||
import static com.baidu.paddle.fastdeploy.app.ui.Utils.decodeBitmap;
|
||||
import static com.baidu.paddle.fastdeploy.app.ui.Utils.getRealPathFromURI;
|
||||
import static com.baidu.paddle.fastdeploy.app.ui.Utils.readTxt;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
@@ -36,9 +37,9 @@ import com.baidu.paddle.fastdeploy.app.ui.Utils;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.view.adapter.BaseResultAdapter;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.view.model.BaseResultModel;
|
||||
import com.baidu.paddle.fastdeploy.vision.ClassifyResult;
|
||||
import com.baidu.paddle.fastdeploy.vision.Visualize;
|
||||
import com.baidu.paddle.fastdeploy.vision.classification.PaddleClasModel;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -62,27 +63,33 @@ public class ClassificationMainActivity extends Activity implements View.OnClick
|
||||
private SeekBar confidenceSeekbar;
|
||||
private TextView seekbarText;
|
||||
private float resultNum = 1.0f;
|
||||
private ResultListView detectResultView;
|
||||
private ResultListView resultView;
|
||||
private Bitmap shutterBitmap;
|
||||
private Bitmap originShutterBitmap;
|
||||
private Bitmap picBitmap;
|
||||
private Bitmap originPicBitmap;
|
||||
private boolean isShutterBitmapCopied = false;
|
||||
|
||||
public static final int TYPE_UNKNOWN = -1;
|
||||
public static final int BTN_SHUTTER = 0;
|
||||
public static final int ALBUM_SELECT = 1;
|
||||
private static int TYPE = TYPE_UNKNOWN;
|
||||
public static final int REALTIME_DETECT = 2;
|
||||
private static int TYPE = REALTIME_DETECT;
|
||||
|
||||
private static final int REQUEST_PERMISSION_CODE_STORAGE = 101;
|
||||
private static final int INTENT_CODE_PICK_IMAGE = 100;
|
||||
private static final int TIME_SLEEP_INTERVAL = 50; // ms
|
||||
|
||||
String savedImagePath = "result.jpg";
|
||||
long timeElapsed = 0;
|
||||
long frameCounter = 0;
|
||||
|
||||
// Call 'init' and 'release' manually later
|
||||
PaddleClasModel predictor = new PaddleClasModel();
|
||||
|
||||
private float[] scores;
|
||||
private int[] labelId;
|
||||
private boolean initialized;
|
||||
private List<String> labelText;
|
||||
private List<BaseResultModel> results = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -114,12 +121,8 @@ public class ClassificationMainActivity extends Activity implements View.OnClick
|
||||
break;
|
||||
case R.id.btn_shutter:
|
||||
TYPE = BTN_SHUTTER;
|
||||
svPreview.onPause();
|
||||
cameraPageView.setVisibility(View.GONE);
|
||||
resultPageView.setVisibility(View.VISIBLE);
|
||||
seekbarText.setText(resultNum + "");
|
||||
confidenceSeekbar.setProgress((int) (resultNum * 100));
|
||||
resultImage.setImageBitmap(shutterBitmap);
|
||||
shutterAndPauseCamera();
|
||||
resultView.setAdapter(null);
|
||||
break;
|
||||
case R.id.btn_settings:
|
||||
startActivity(new Intent(ClassificationMainActivity.this, ClassificationSettingsActivity.class));
|
||||
@@ -130,7 +133,7 @@ public class ClassificationMainActivity extends Activity implements View.OnClick
|
||||
case R.id.back_in_preview:
|
||||
finish();
|
||||
break;
|
||||
case R.id.albumSelect:
|
||||
case R.id.iv_select:
|
||||
TYPE = ALBUM_SELECT;
|
||||
// Judge whether authority has been granted.
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
@@ -141,16 +144,84 @@ public class ClassificationMainActivity extends Activity implements View.OnClick
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(intent, INTENT_CODE_PICK_IMAGE);
|
||||
}
|
||||
resultView.setAdapter(null);
|
||||
break;
|
||||
case R.id.back_in_result:
|
||||
resultPageView.setVisibility(View.GONE);
|
||||
cameraPageView.setVisibility(View.VISIBLE);
|
||||
svPreview.onResume();
|
||||
back();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
back();
|
||||
}
|
||||
|
||||
private void back() {
|
||||
resultPageView.setVisibility(View.GONE);
|
||||
cameraPageView.setVisibility(View.VISIBLE);
|
||||
TYPE = REALTIME_DETECT;
|
||||
isShutterBitmapCopied = false;
|
||||
svPreview.onResume();
|
||||
results.clear();
|
||||
if (scores != null) {
|
||||
scores = null;
|
||||
}
|
||||
if (labelId != null) {
|
||||
labelId = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void shutterAndPauseCamera() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// Sleep some times to ensure picture has been correctly shut.
|
||||
Thread.sleep(TIME_SLEEP_INTERVAL * 10); // 500ms
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
runOnUiThread(new Runnable() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void run() {
|
||||
// These code will run in main thread.
|
||||
svPreview.onPause();
|
||||
cameraPageView.setVisibility(View.GONE);
|
||||
resultPageView.setVisibility(View.VISIBLE);
|
||||
seekbarText.setText(resultNum + "");
|
||||
confidenceSeekbar.setProgress((int) (resultNum * 100));
|
||||
if (shutterBitmap != null && !shutterBitmap.isRecycled()) {
|
||||
resultImage.setImageBitmap(shutterBitmap);
|
||||
} else {
|
||||
new AlertDialog.Builder(ClassificationMainActivity.this)
|
||||
.setTitle("Empty Result!")
|
||||
.setMessage("Current picture is empty, please shutting it again!")
|
||||
.setCancelable(true)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void copyBitmapFromCamera(Bitmap ARGB8888ImageBitmap) {
|
||||
if (isShutterBitmapCopied || ARGB8888ImageBitmap == null) {
|
||||
return;
|
||||
}
|
||||
if (!ARGB8888ImageBitmap.isRecycled()) {
|
||||
synchronized (this) {
|
||||
shutterBitmap = ARGB8888ImageBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
}
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL);
|
||||
isShutterBitmapCopied = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
@@ -163,7 +234,6 @@ public class ClassificationMainActivity extends Activity implements View.OnClick
|
||||
Uri uri = data.getData();
|
||||
String path = getRealPathFromURI(this, uri);
|
||||
picBitmap = decodeBitmap(path, 720, 1280);
|
||||
originPicBitmap = picBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
resultImage.setImageBitmap(picBitmap);
|
||||
}
|
||||
}
|
||||
@@ -190,34 +260,17 @@ public class ClassificationMainActivity extends Activity implements View.OnClick
|
||||
|
||||
@Override
|
||||
public boolean onTextureChanged(Bitmap ARGB8888ImageBitmap) {
|
||||
String savedImagePath = "";
|
||||
synchronized (this) {
|
||||
savedImagePath = Utils.getDCIMDirectory() + File.separator + "result.jpg";
|
||||
}
|
||||
if (TYPE == BTN_SHUTTER) {
|
||||
shutterBitmap = ARGB8888ImageBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
originShutterBitmap = ARGB8888ImageBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
} else {
|
||||
// Only reference in predict loops.
|
||||
shutterBitmap = ARGB8888ImageBitmap;
|
||||
originShutterBitmap = ARGB8888ImageBitmap;
|
||||
copyBitmapFromCamera(ARGB8888ImageBitmap);
|
||||
return false;
|
||||
}
|
||||
boolean modified = false;
|
||||
|
||||
long tc = System.currentTimeMillis();
|
||||
ClassifyResult result = predictor.predict(
|
||||
ARGB8888ImageBitmap, true, ClassificationSettingsActivity.scoreThreshold);
|
||||
|
||||
ClassifyResult result = predictor.predict(ARGB8888ImageBitmap);
|
||||
timeElapsed += (System.currentTimeMillis() - tc);
|
||||
frameCounter++;
|
||||
|
||||
Visualize.visClassification(ARGB8888ImageBitmap, result, resultNum, 12);
|
||||
modified = result.initialized();
|
||||
if (!savedImagePath.isEmpty()) {
|
||||
synchronized (this) {
|
||||
ClassificationMainActivity.this.savedImagePath = "result.jpg";
|
||||
}
|
||||
}
|
||||
|
||||
frameCounter++;
|
||||
if (frameCounter >= 30) {
|
||||
final int fps = (int) (1000 / (timeElapsed / 30));
|
||||
runOnUiThread(new Runnable() {
|
||||
@@ -259,7 +312,7 @@ public class ClassificationMainActivity extends Activity implements View.OnClick
|
||||
}
|
||||
|
||||
public void initView() {
|
||||
TYPE = BTN_SHUTTER;
|
||||
TYPE = REALTIME_DETECT;
|
||||
svPreview = (CameraSurfaceView) findViewById(R.id.sv_preview);
|
||||
svPreview.setOnTextureChangedListener(this);
|
||||
tvStatus = (TextView) findViewById(R.id.tv_status);
|
||||
@@ -273,7 +326,7 @@ public class ClassificationMainActivity extends Activity implements View.OnClick
|
||||
realtimeToggleButton.setOnClickListener(this);
|
||||
backInPreview = findViewById(R.id.back_in_preview);
|
||||
backInPreview.setOnClickListener(this);
|
||||
albumSelectButton = findViewById(R.id.albumSelect);
|
||||
albumSelectButton = findViewById(R.id.iv_select);
|
||||
albumSelectButton.setOnClickListener(this);
|
||||
cameraPageView = findViewById(R.id.camera_page);
|
||||
resultPageView = findViewById(R.id.result_page);
|
||||
@@ -282,15 +335,7 @@ public class ClassificationMainActivity extends Activity implements View.OnClick
|
||||
backInResult.setOnClickListener(this);
|
||||
confidenceSeekbar = findViewById(R.id.confidence_seekbar);
|
||||
seekbarText = findViewById(R.id.seekbar_text);
|
||||
detectResultView = findViewById(R.id.result_list_view);
|
||||
|
||||
List<BaseResultModel> results = new ArrayList<>();
|
||||
results.add(new BaseResultModel(1, "cup", 0.4f));
|
||||
results.add(new BaseResultModel(2, "pen", 0.6f));
|
||||
results.add(new BaseResultModel(3, "tang", 1.0f));
|
||||
final BaseResultAdapter adapter = new BaseResultAdapter(this, R.layout.classification_result_page_item, results);
|
||||
detectResultView.setAdapter(adapter);
|
||||
detectResultView.invalidate();
|
||||
resultView = findViewById(R.id.result_list_view);
|
||||
|
||||
confidenceSeekbar.setMax(100);
|
||||
confidenceSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@@ -301,6 +346,7 @@ public class ClassificationMainActivity extends Activity implements View.OnClick
|
||||
resultNum = bd.setScale(1, BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
seekbarText.setText(resultNum + "");
|
||||
confidenceSeekbar.setProgress((int) (resultNum * 100));
|
||||
results.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -315,22 +361,45 @@ public class ClassificationMainActivity extends Activity implements View.OnClick
|
||||
public void run() {
|
||||
if (TYPE == ALBUM_SELECT) {
|
||||
SystemClock.sleep(500);
|
||||
predictor.predict(picBitmap, savedImagePath, resultNum);
|
||||
resultImage.setImageBitmap(picBitmap);
|
||||
picBitmap = originPicBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
resultNum = 1.0f;
|
||||
detail(picBitmap);
|
||||
} else {
|
||||
SystemClock.sleep(500);
|
||||
predictor.predict(shutterBitmap, savedImagePath, resultNum);
|
||||
resultImage.setImageBitmap(shutterBitmap);
|
||||
shutterBitmap = originShutterBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
svPreview.onPause();
|
||||
detail(shutterBitmap);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void detail(Bitmap bitmap) {
|
||||
ClassifyResult result = predictor.predict(bitmap, true, ClassificationSettingsActivity.scoreThreshold);
|
||||
if (scores == null) {
|
||||
scores = result.mScores;
|
||||
}
|
||||
if (labelId == null) {
|
||||
labelId = result.mLabelIds;
|
||||
}
|
||||
initialized = result.initialized();
|
||||
if (initialized) {
|
||||
for (int i = 0; i < labelId.length; i++) {
|
||||
for (int j = 0; j < labelText.size(); j++) {
|
||||
if (scores[i] > resultNum) {
|
||||
if (labelId[i] == Integer.parseInt(labelText.get(j).substring(0, labelText.get(j).indexOf(" ")))) {
|
||||
results.add(new BaseResultModel(labelId[i], labelText.get(j), scores[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BaseResultAdapter adapter = new BaseResultAdapter(getBaseContext(), R.layout.ocr_result_page_item, results);
|
||||
resultView.setAdapter(adapter);
|
||||
resultView.invalidate();
|
||||
|
||||
resultImage.setImageBitmap(bitmap);
|
||||
resultNum = 1.0f;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public void initSettings() {
|
||||
@@ -352,6 +421,7 @@ public class ClassificationMainActivity extends Activity implements View.OnClick
|
||||
String paramsFile = realModelDir + "/" + "inference.pdiparams";
|
||||
String configFile = realModelDir + "/" + "inference_cls.yaml";
|
||||
String labelFile = realLabelPath;
|
||||
labelText = readTxt(labelFile);
|
||||
RuntimeOption option = new RuntimeOption();
|
||||
option.setCpuThreadNum(ClassificationSettingsActivity.cpuThreadNum);
|
||||
option.setLitePowerMode(ClassificationSettingsActivity.cpuPowerMode);
|
||||
|
@@ -8,18 +8,14 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
@@ -31,7 +27,6 @@ import android.widget.TextView;
|
||||
|
||||
import com.baidu.paddle.fastdeploy.RuntimeOption;
|
||||
import com.baidu.paddle.fastdeploy.app.examples.R;
|
||||
import com.baidu.paddle.fastdeploy.app.examples.facedet.FaceDetMainActivity;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.view.CameraSurfaceView;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.view.ResultListView;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.Utils;
|
||||
@@ -43,8 +38,8 @@ import com.baidu.paddle.fastdeploy.vision.detection.PicoDet;
|
||||
|
||||
import static com.baidu.paddle.fastdeploy.app.ui.Utils.decodeBitmap;
|
||||
import static com.baidu.paddle.fastdeploy.app.ui.Utils.getRealPathFromURI;
|
||||
import static com.baidu.paddle.fastdeploy.app.ui.Utils.readTxt;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -68,11 +63,9 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe
|
||||
private SeekBar confidenceSeekbar;
|
||||
private TextView seekbarText;
|
||||
private float resultNum = 1.0f;
|
||||
private ResultListView detectResultView;
|
||||
private ResultListView resultView;
|
||||
private Bitmap shutterBitmap;
|
||||
private Bitmap originShutterBitmap;
|
||||
private Bitmap picBitmap;
|
||||
private Bitmap originPicBitmap;
|
||||
private boolean isShutterBitmapCopied = false;
|
||||
|
||||
public static final int TYPE_UNKNOWN = -1;
|
||||
@@ -85,13 +78,18 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe
|
||||
private static final int INTENT_CODE_PICK_IMAGE = 100;
|
||||
private static final int TIME_SLEEP_INTERVAL = 50; // ms
|
||||
|
||||
String savedImagePath = "result.jpg";
|
||||
long timeElapsed = 0;
|
||||
long frameCounter = 0;
|
||||
|
||||
// Call 'init' and 'release' manually later
|
||||
PicoDet predictor = new PicoDet();
|
||||
|
||||
private float[] scores;
|
||||
private int[] labelId;
|
||||
private boolean initialized;
|
||||
private List<String> labelText;
|
||||
private List<BaseResultModel> results = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -124,6 +122,7 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe
|
||||
case R.id.btn_shutter:
|
||||
TYPE = BTN_SHUTTER;
|
||||
shutterAndPauseCamera();
|
||||
resultView.setAdapter(null);
|
||||
break;
|
||||
case R.id.btn_settings:
|
||||
startActivity(new Intent(DetectionMainActivity.this, DetectionSettingsActivity.class));
|
||||
@@ -134,7 +133,7 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe
|
||||
case R.id.back_in_preview:
|
||||
finish();
|
||||
break;
|
||||
case R.id.albumSelect:
|
||||
case R.id.iv_select:
|
||||
TYPE = ALBUM_SELECT;
|
||||
// Judge whether authority has been granted.
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
@@ -145,14 +144,32 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(intent, INTENT_CODE_PICK_IMAGE);
|
||||
}
|
||||
resultView.setAdapter(null);
|
||||
break;
|
||||
case R.id.back_in_result:
|
||||
back();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
back();
|
||||
}
|
||||
|
||||
private void back() {
|
||||
resultPageView.setVisibility(View.GONE);
|
||||
cameraPageView.setVisibility(View.VISIBLE);
|
||||
TYPE = REALTIME_DETECT;
|
||||
isShutterBitmapCopied = false;
|
||||
svPreview.onResume();
|
||||
break;
|
||||
results.clear();
|
||||
if (scores != null) {
|
||||
scores = null;
|
||||
}
|
||||
if (labelId != null) {
|
||||
labelId = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +215,6 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe
|
||||
if (!ARGB8888ImageBitmap.isRecycled()) {
|
||||
synchronized (this) {
|
||||
shutterBitmap = ARGB8888ImageBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
originShutterBitmap = ARGB8888ImageBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
}
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL);
|
||||
isShutterBitmapCopied = true;
|
||||
@@ -217,7 +233,6 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe
|
||||
Uri uri = data.getData();
|
||||
String path = getRealPathFromURI(this, uri);
|
||||
picBitmap = decodeBitmap(path, 720, 1280);
|
||||
originPicBitmap = picBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
resultImage.setImageBitmap(picBitmap);
|
||||
}
|
||||
}
|
||||
@@ -248,27 +263,12 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe
|
||||
copyBitmapFromCamera(ARGB8888ImageBitmap);
|
||||
return false;
|
||||
}
|
||||
|
||||
String savedImagePath = "";
|
||||
synchronized (this) {
|
||||
savedImagePath = Utils.getDCIMDirectory() + File.separator + "result.jpg";
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
|
||||
long tc = System.currentTimeMillis();
|
||||
DetectionResult result = predictor.predict(ARGB8888ImageBitmap);
|
||||
timeElapsed += (System.currentTimeMillis() - tc);
|
||||
|
||||
Visualize.visDetection(ARGB8888ImageBitmap, result, DetectionSettingsActivity.scoreThreshold);
|
||||
|
||||
modified = result.initialized();
|
||||
if (!savedImagePath.isEmpty()) {
|
||||
synchronized (this) {
|
||||
DetectionMainActivity.this.savedImagePath = "result.jpg";
|
||||
}
|
||||
}
|
||||
|
||||
frameCounter++;
|
||||
if (frameCounter >= 30) {
|
||||
final int fps = (int) (1000 / (timeElapsed / 30));
|
||||
@@ -325,7 +325,7 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe
|
||||
realtimeToggleButton.setOnClickListener(this);
|
||||
backInPreview = findViewById(R.id.back_in_preview);
|
||||
backInPreview.setOnClickListener(this);
|
||||
albumSelectButton = findViewById(R.id.albumSelect);
|
||||
albumSelectButton = findViewById(R.id.iv_select);
|
||||
albumSelectButton.setOnClickListener(this);
|
||||
cameraPageView = findViewById(R.id.camera_page);
|
||||
resultPageView = findViewById(R.id.result_page);
|
||||
@@ -334,15 +334,7 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe
|
||||
backInResult.setOnClickListener(this);
|
||||
confidenceSeekbar = findViewById(R.id.confidence_seekbar);
|
||||
seekbarText = findViewById(R.id.seekbar_text);
|
||||
detectResultView = findViewById(R.id.result_list_view);
|
||||
|
||||
List<BaseResultModel> results = new ArrayList<>();
|
||||
results.add(new BaseResultModel(1, "cup", 0.4f));
|
||||
results.add(new BaseResultModel(2, "pen", 0.6f));
|
||||
results.add(new BaseResultModel(3, "tang", 1.0f));
|
||||
final BaseResultAdapter adapter = new BaseResultAdapter(this, R.layout.detection_result_page_item, results);
|
||||
detectResultView.setAdapter(adapter);
|
||||
detectResultView.invalidate();
|
||||
resultView = findViewById(R.id.result_list_view);
|
||||
|
||||
confidenceSeekbar.setMax(100);
|
||||
confidenceSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@@ -353,6 +345,7 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe
|
||||
resultNum = bd.setScale(1, BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
seekbarText.setText(resultNum + "");
|
||||
confidenceSeekbar.setProgress((int) (resultNum * 100));
|
||||
results.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -367,26 +360,46 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe
|
||||
public void run() {
|
||||
if (TYPE == ALBUM_SELECT) {
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL * 10);
|
||||
if (!picBitmap.isRecycled()) {
|
||||
predictor.predict(picBitmap, true, resultNum);
|
||||
resultImage.setImageBitmap(picBitmap);
|
||||
picBitmap = originPicBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
}
|
||||
resultNum = 1.0f;
|
||||
detail(picBitmap);
|
||||
} else {
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL * 10);
|
||||
if (!shutterBitmap.isRecycled()) {
|
||||
predictor.predict(shutterBitmap, true, resultNum);
|
||||
resultImage.setImageBitmap(shutterBitmap);
|
||||
shutterBitmap = originShutterBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
svPreview.onPause();
|
||||
detail(shutterBitmap);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void detail(Bitmap bitmap) {
|
||||
DetectionResult result = predictor.predict(
|
||||
bitmap, true, DetectionSettingsActivity.scoreThreshold);
|
||||
if (scores == null) {
|
||||
scores = result.mScores;
|
||||
}
|
||||
if (labelId == null) {
|
||||
labelId = result.mLabelIds;
|
||||
}
|
||||
initialized = result.initialized();
|
||||
if (initialized) {
|
||||
for (int i = 0; i < labelId.length; i++) {
|
||||
for (int j = 0; j < labelText.size(); j++) {
|
||||
if (scores[i] > resultNum) {
|
||||
if (labelId[i] == j) {
|
||||
results.add(new BaseResultModel(labelId[i], labelText.get(j), scores[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BaseResultAdapter adapter = new BaseResultAdapter(getBaseContext(), R.layout.ocr_result_page_item, results);
|
||||
resultView.setAdapter(adapter);
|
||||
resultView.invalidate();
|
||||
|
||||
resultImage.setImageBitmap(bitmap);
|
||||
resultNum = 1.0f;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public void initSettings() {
|
||||
@@ -408,6 +421,7 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe
|
||||
String paramsFile = realModelDir + "/" + "model.pdiparams";
|
||||
String configFile = realModelDir + "/" + "infer_cfg.yml";
|
||||
String labelFile = realLabelPath;
|
||||
labelText = readTxt(labelFile);
|
||||
RuntimeOption option = new RuntimeOption();
|
||||
option.setCpuThreadNum(DetectionSettingsActivity.cpuThreadNum);
|
||||
option.setLitePowerMode(DetectionSettingsActivity.cpuPowerMode);
|
||||
|
@@ -8,14 +8,11 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
@@ -43,7 +40,6 @@ import com.baidu.paddle.fastdeploy.vision.facedet.SCRFD;
|
||||
import static com.baidu.paddle.fastdeploy.app.ui.Utils.decodeBitmap;
|
||||
import static com.baidu.paddle.fastdeploy.app.ui.Utils.getRealPathFromURI;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -67,11 +63,9 @@ public class FaceDetMainActivity extends Activity implements View.OnClickListene
|
||||
private SeekBar confidenceSeekbar;
|
||||
private TextView seekbarText;
|
||||
private float resultNum = 1.0f;
|
||||
private ResultListView detectResultView;
|
||||
private ResultListView resultView;
|
||||
private Bitmap shutterBitmap;
|
||||
private Bitmap originShutterBitmap;
|
||||
private Bitmap picBitmap;
|
||||
private Bitmap originPicBitmap;
|
||||
private boolean isShutterBitmapCopied = false;
|
||||
|
||||
public static final int TYPE_UNKNOWN = -1;
|
||||
@@ -84,13 +78,16 @@ public class FaceDetMainActivity extends Activity implements View.OnClickListene
|
||||
private static final int INTENT_CODE_PICK_IMAGE = 100;
|
||||
private static final int TIME_SLEEP_INTERVAL = 50; // ms
|
||||
|
||||
String savedImagePath = "result.jpg";
|
||||
long timeElapsed = 0;
|
||||
long frameCounter = 0;
|
||||
|
||||
// Call 'init' and 'release' manually later
|
||||
SCRFD predictor = new SCRFD();
|
||||
|
||||
public float[] scores; // [n]
|
||||
public boolean initialized = false;
|
||||
private List<BaseResultModel> results = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -123,6 +120,7 @@ public class FaceDetMainActivity extends Activity implements View.OnClickListene
|
||||
case R.id.btn_shutter:
|
||||
TYPE = BTN_SHUTTER;
|
||||
shutterAndPauseCamera();
|
||||
resultView.setAdapter(null);
|
||||
break;
|
||||
case R.id.btn_settings:
|
||||
startActivity(new Intent(FaceDetMainActivity.this, FaceDetSettingsActivity.class));
|
||||
@@ -144,14 +142,29 @@ public class FaceDetMainActivity extends Activity implements View.OnClickListene
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(intent, INTENT_CODE_PICK_IMAGE);
|
||||
}
|
||||
resultView.setAdapter(null);
|
||||
break;
|
||||
case R.id.back_in_result:
|
||||
back();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
back();
|
||||
}
|
||||
|
||||
private void back() {
|
||||
resultPageView.setVisibility(View.GONE);
|
||||
cameraPageView.setVisibility(View.VISIBLE);
|
||||
TYPE = REALTIME_DETECT;
|
||||
isShutterBitmapCopied = false;
|
||||
svPreview.onResume();
|
||||
break;
|
||||
results.clear();
|
||||
if (scores != null) {
|
||||
scores = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +210,6 @@ public class FaceDetMainActivity extends Activity implements View.OnClickListene
|
||||
if (!ARGB8888ImageBitmap.isRecycled()) {
|
||||
synchronized (this) {
|
||||
shutterBitmap = ARGB8888ImageBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
originShutterBitmap = ARGB8888ImageBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
}
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL);
|
||||
isShutterBitmapCopied = true;
|
||||
@@ -216,7 +228,6 @@ public class FaceDetMainActivity extends Activity implements View.OnClickListene
|
||||
Uri uri = data.getData();
|
||||
String path = getRealPathFromURI(this, uri);
|
||||
picBitmap = decodeBitmap(path, 720, 1280);
|
||||
originPicBitmap = picBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
resultImage.setImageBitmap(picBitmap);
|
||||
}
|
||||
}
|
||||
@@ -248,29 +259,14 @@ public class FaceDetMainActivity extends Activity implements View.OnClickListene
|
||||
copyBitmapFromCamera(ARGB8888ImageBitmap);
|
||||
return false;
|
||||
}
|
||||
|
||||
String savedImagePath = "";
|
||||
synchronized (this) {
|
||||
savedImagePath = Utils.getDCIMDirectory() + File.separator + "result.jpg";
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
|
||||
long tc = System.currentTimeMillis();
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL);
|
||||
FaceDetectionResult result = predictor.predict(
|
||||
ARGB8888ImageBitmap, FaceDetSettingsActivity.scoreThreshold, 0.4f);
|
||||
|
||||
timeElapsed += (System.currentTimeMillis() - tc);
|
||||
|
||||
Visualize.visFaceDetection(ARGB8888ImageBitmap, result);
|
||||
|
||||
modified = result.initialized();
|
||||
if (!savedImagePath.isEmpty()) {
|
||||
synchronized (this) {
|
||||
FaceDetMainActivity.this.savedImagePath = "result.jpg";
|
||||
}
|
||||
}
|
||||
|
||||
frameCounter++;
|
||||
if (frameCounter >= 30) {
|
||||
final int fps = (int) (1000 / (timeElapsed / 30));
|
||||
@@ -336,16 +332,7 @@ public class FaceDetMainActivity extends Activity implements View.OnClickListene
|
||||
backInResult.setOnClickListener(this);
|
||||
confidenceSeekbar = findViewById(R.id.confidence_seekbar);
|
||||
seekbarText = findViewById(R.id.seekbar_text);
|
||||
detectResultView = findViewById(R.id.result_list_view);
|
||||
|
||||
List<BaseResultModel> results = new ArrayList<>();
|
||||
// TODO: add model results from FaceDetectionResult instead of using fake data.
|
||||
results.add(new BaseResultModel(1, "face", 0.4f));
|
||||
results.add(new BaseResultModel(2, "face", 0.6f));
|
||||
results.add(new BaseResultModel(3, "face", 1.0f));
|
||||
final BaseResultAdapter adapter = new BaseResultAdapter(this, R.layout.facedet_result_page_item, results);
|
||||
detectResultView.setAdapter(adapter);
|
||||
detectResultView.invalidate();
|
||||
resultView = findViewById(R.id.result_list_view);
|
||||
|
||||
confidenceSeekbar.setMax(100);
|
||||
confidenceSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@@ -356,6 +343,7 @@ public class FaceDetMainActivity extends Activity implements View.OnClickListene
|
||||
resultNum = bd.setScale(1, BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
seekbarText.setText(resultNum + "");
|
||||
confidenceSeekbar.setProgress((int) (resultNum * 100));
|
||||
results.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -370,26 +358,39 @@ public class FaceDetMainActivity extends Activity implements View.OnClickListene
|
||||
public void run() {
|
||||
if (TYPE == ALBUM_SELECT) {
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL * 10); // 500ms
|
||||
if (!picBitmap.isRecycled()) {
|
||||
predictor.predict(picBitmap, true, resultNum, 0.4f);
|
||||
resultImage.setImageBitmap(picBitmap);
|
||||
picBitmap = originPicBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
}
|
||||
resultNum = 1.0f;
|
||||
detail(picBitmap);
|
||||
} else {
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL * 10); // 500ms
|
||||
if (!shutterBitmap.isRecycled()) {
|
||||
predictor.predict(shutterBitmap, true, resultNum, 0.4f);
|
||||
resultImage.setImageBitmap(shutterBitmap);
|
||||
shutterBitmap = originShutterBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
svPreview.onPause();
|
||||
detail(shutterBitmap);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void detail(Bitmap bitmap) {
|
||||
FaceDetectionResult result = predictor.predict(bitmap, true, FaceDetSettingsActivity.scoreThreshold, 0.4f);
|
||||
if (scores == null) {
|
||||
scores = result.mScores;
|
||||
}
|
||||
initialized = result.initialized();
|
||||
Log.e("GBD", initialized + "---initialized");
|
||||
if (initialized) {
|
||||
for (int i = 0; i < scores.length; i++) {
|
||||
if (scores[i] > resultNum) {
|
||||
results.add(new BaseResultModel(i + 1, "face", scores[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
BaseResultAdapter adapter = new BaseResultAdapter(getBaseContext(), R.layout.ocr_result_page_item, results);
|
||||
resultView.setAdapter(adapter);
|
||||
resultView.invalidate();
|
||||
|
||||
resultImage.setImageBitmap(bitmap);
|
||||
resultNum = 1.0f;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public void initSettings() {
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package com.baidu.paddle.fastdeploy.app.examples.ocr;
|
||||
|
||||
import static com.baidu.paddle.fastdeploy.app.ui.Utils.decodeBitmap;
|
||||
import static com.baidu.paddle.fastdeploy.app.ui.Utils.getRealPathFromURI;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
@@ -10,32 +12,39 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.baidu.paddle.fastdeploy.RuntimeOption;
|
||||
import com.baidu.paddle.fastdeploy.app.examples.R;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.Utils;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.view.CameraSurfaceView;
|
||||
import com.baidu.paddle.fastdeploy.vision.OCRResult;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.view.ResultListView;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.Utils;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.view.adapter.BaseResultAdapter;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.view.model.BaseResultModel;
|
||||
import com.baidu.paddle.fastdeploy.pipeline.PPOCRv2;
|
||||
import com.baidu.paddle.fastdeploy.vision.OCRResult;
|
||||
import com.baidu.paddle.fastdeploy.vision.Visualize;
|
||||
import com.baidu.paddle.fastdeploy.vision.ocr.Classifier;
|
||||
import com.baidu.paddle.fastdeploy.vision.ocr.DBDetector;
|
||||
import com.baidu.paddle.fastdeploy.vision.ocr.Recognizer;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class OcrMainActivity extends Activity implements View.OnClickListener, CameraSurfaceView.OnTextureChangedListener {
|
||||
private static final String TAG = OcrMainActivity.class.getSimpleName();
|
||||
@@ -48,14 +57,40 @@ public class OcrMainActivity extends Activity implements View.OnClickListener, C
|
||||
ImageView realtimeToggleButton;
|
||||
boolean isRealtimeStatusRunning = false;
|
||||
ImageView backInPreview;
|
||||
private ImageView albumSelectButton;
|
||||
private View cameraPageView;
|
||||
private ViewGroup resultPageView;
|
||||
private ImageView resultImage;
|
||||
private ImageView backInResult;
|
||||
private SeekBar confidenceSeekbar;
|
||||
private TextView seekbarText;
|
||||
private float resultNum = 1.0f;
|
||||
private ResultListView resultView;
|
||||
private Bitmap shutterBitmap;
|
||||
private Bitmap picBitmap;
|
||||
private boolean isShutterBitmapCopied = false;
|
||||
|
||||
String savedImagePath = "result.jpg";
|
||||
int lastFrameIndex = 0;
|
||||
long lastFrameTime;
|
||||
public static final int TYPE_UNKNOWN = -1;
|
||||
public static final int BTN_SHUTTER = 0;
|
||||
public static final int ALBUM_SELECT = 1;
|
||||
public static final int REALTIME_DETECT = 2;
|
||||
private static int TYPE = REALTIME_DETECT;
|
||||
|
||||
private static final int REQUEST_PERMISSION_CODE_STORAGE = 101;
|
||||
private static final int INTENT_CODE_PICK_IMAGE = 100;
|
||||
private static final int TIME_SLEEP_INTERVAL = 50; // ms
|
||||
|
||||
long timeElapsed = 0;
|
||||
long frameCounter = 0;
|
||||
|
||||
// Call 'init' and 'release' manually later
|
||||
PPOCRv2 predictor = new PPOCRv2();
|
||||
|
||||
private String[] texts;
|
||||
private float[] recScores;
|
||||
private boolean initialized;
|
||||
private List<BaseResultModel> results = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -86,12 +121,9 @@ public class OcrMainActivity extends Activity implements View.OnClickListener, C
|
||||
svPreview.switchCamera();
|
||||
break;
|
||||
case R.id.btn_shutter:
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
SimpleDateFormat date = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
|
||||
synchronized (this) {
|
||||
savedImagePath = Utils.getDCIMDirectory() + File.separator + date.format(new Date()).toString() + ".png";
|
||||
}
|
||||
Toast.makeText(OcrMainActivity.this, "Save snapshot to " + savedImagePath, Toast.LENGTH_SHORT).show();
|
||||
TYPE = BTN_SHUTTER;
|
||||
shutterAndPauseCamera();
|
||||
resultView.setAdapter(null);
|
||||
break;
|
||||
case R.id.btn_settings:
|
||||
startActivity(new Intent(OcrMainActivity.this, OcrSettingsActivity.class));
|
||||
@@ -102,6 +134,109 @@ public class OcrMainActivity extends Activity implements View.OnClickListener, C
|
||||
case R.id.back_in_preview:
|
||||
finish();
|
||||
break;
|
||||
case R.id.iv_select:
|
||||
TYPE = ALBUM_SELECT;
|
||||
// Judge whether authority has been granted.
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
// If this permission was requested before the application but the user refused the request, this method will return true.
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_PERMISSION_CODE_STORAGE);
|
||||
} else {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK);
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(intent, INTENT_CODE_PICK_IMAGE);
|
||||
}
|
||||
resultView.setAdapter(null);
|
||||
break;
|
||||
case R.id.back_in_result:
|
||||
back();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
back();
|
||||
}
|
||||
|
||||
private void back() {
|
||||
resultPageView.setVisibility(View.GONE);
|
||||
cameraPageView.setVisibility(View.VISIBLE);
|
||||
TYPE = REALTIME_DETECT;
|
||||
isShutterBitmapCopied = false;
|
||||
svPreview.onResume();
|
||||
results.clear();
|
||||
if (texts != null) {
|
||||
texts = null;
|
||||
}
|
||||
if (recScores != null) {
|
||||
recScores = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void shutterAndPauseCamera() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// Sleep some times to ensure picture has been correctly shut.
|
||||
Thread.sleep(TIME_SLEEP_INTERVAL * 10); // 500ms
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
runOnUiThread(new Runnable() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void run() {
|
||||
// These code will run in main thread.
|
||||
svPreview.onPause();
|
||||
cameraPageView.setVisibility(View.GONE);
|
||||
resultPageView.setVisibility(View.VISIBLE);
|
||||
seekbarText.setText(resultNum + "");
|
||||
confidenceSeekbar.setProgress((int) (resultNum * 100));
|
||||
if (shutterBitmap != null && !shutterBitmap.isRecycled()) {
|
||||
resultImage.setImageBitmap(shutterBitmap);
|
||||
} else {
|
||||
new AlertDialog.Builder(OcrMainActivity.this)
|
||||
.setTitle("Empty Result!")
|
||||
.setMessage("Current picture is empty, please shutting it again!")
|
||||
.setCancelable(true)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void copyBitmapFromCamera(Bitmap ARGB8888ImageBitmap) {
|
||||
if (isShutterBitmapCopied || ARGB8888ImageBitmap == null) {
|
||||
return;
|
||||
}
|
||||
if (!ARGB8888ImageBitmap.isRecycled()) {
|
||||
synchronized (this) {
|
||||
shutterBitmap = ARGB8888ImageBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
}
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL);
|
||||
isShutterBitmapCopied = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == INTENT_CODE_PICK_IMAGE) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
cameraPageView.setVisibility(View.GONE);
|
||||
resultPageView.setVisibility(View.VISIBLE);
|
||||
seekbarText.setText(resultNum + "");
|
||||
confidenceSeekbar.setProgress((int) (resultNum * 100));
|
||||
Uri uri = data.getData();
|
||||
String path = getRealPathFromURI(this, uri);
|
||||
picBitmap = decodeBitmap(path, 720, 1280);
|
||||
resultImage.setImageBitmap(picBitmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,29 +261,27 @@ public class OcrMainActivity extends Activity implements View.OnClickListener, C
|
||||
|
||||
@Override
|
||||
public boolean onTextureChanged(Bitmap ARGB8888ImageBitmap) {
|
||||
String savedImagePath = "";
|
||||
synchronized (this) {
|
||||
savedImagePath = OcrMainActivity.this.savedImagePath;
|
||||
if (TYPE == BTN_SHUTTER) {
|
||||
copyBitmapFromCamera(ARGB8888ImageBitmap);
|
||||
return false;
|
||||
}
|
||||
boolean modified = false;
|
||||
OCRResult result = predictor.predict(ARGB8888ImageBitmap, savedImagePath);
|
||||
long tc = System.currentTimeMillis();
|
||||
OCRResult result = predictor.predict(ARGB8888ImageBitmap, true);
|
||||
timeElapsed += (System.currentTimeMillis() - tc);
|
||||
Visualize.visOcr(ARGB8888ImageBitmap, result);
|
||||
modified = result.initialized();
|
||||
if (!savedImagePath.isEmpty()) {
|
||||
synchronized (this) {
|
||||
OcrMainActivity.this.savedImagePath = "result.jpg";
|
||||
}
|
||||
}
|
||||
lastFrameIndex++;
|
||||
if (lastFrameIndex >= 30) {
|
||||
final int fps = (int) (lastFrameIndex * 1e9 / (System.nanoTime() - lastFrameTime));
|
||||
frameCounter++;
|
||||
if (frameCounter >= 30) {
|
||||
final int fps = (int) (1000 / (timeElapsed / 30));
|
||||
runOnUiThread(new Runnable() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void run() {
|
||||
tvStatus.setText(Integer.toString(fps) + "fps");
|
||||
}
|
||||
});
|
||||
lastFrameIndex = 0;
|
||||
lastFrameTime = System.nanoTime();
|
||||
frameCounter = 0;
|
||||
timeElapsed = 0;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
@@ -180,6 +313,7 @@ public class OcrMainActivity extends Activity implements View.OnClickListener, C
|
||||
}
|
||||
|
||||
public void initView() {
|
||||
TYPE = REALTIME_DETECT;
|
||||
svPreview = (CameraSurfaceView) findViewById(R.id.sv_preview);
|
||||
svPreview.setOnTextureChangedListener(this);
|
||||
tvStatus = (TextView) findViewById(R.id.tv_status);
|
||||
@@ -193,6 +327,75 @@ public class OcrMainActivity extends Activity implements View.OnClickListener, C
|
||||
realtimeToggleButton.setOnClickListener(this);
|
||||
backInPreview = findViewById(R.id.back_in_preview);
|
||||
backInPreview.setOnClickListener(this);
|
||||
albumSelectButton = findViewById(R.id.iv_select);
|
||||
albumSelectButton.setOnClickListener(this);
|
||||
cameraPageView = findViewById(R.id.camera_page);
|
||||
resultPageView = findViewById(R.id.result_page);
|
||||
resultImage = findViewById(R.id.result_image);
|
||||
backInResult = findViewById(R.id.back_in_result);
|
||||
backInResult.setOnClickListener(this);
|
||||
confidenceSeekbar = findViewById(R.id.confidence_seekbar);
|
||||
seekbarText = findViewById(R.id.seekbar_text);
|
||||
resultView = findViewById(R.id.result_list_view);
|
||||
|
||||
confidenceSeekbar.setMax(100);
|
||||
confidenceSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
float resultConfidence = seekBar.getProgress() / 100f;
|
||||
BigDecimal bd = new BigDecimal(resultConfidence);
|
||||
resultNum = bd.setScale(1, BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
seekbarText.setText(resultNum + "");
|
||||
confidenceSeekbar.setProgress((int) (resultNum * 100));
|
||||
results.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (TYPE == ALBUM_SELECT) {
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL * 10);
|
||||
detail(picBitmap);
|
||||
} else {
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL * 10);
|
||||
svPreview.onPause();
|
||||
detail(shutterBitmap);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void detail(Bitmap bitmap) {
|
||||
OCRResult result = predictor.predict(bitmap, true);
|
||||
if (texts == null) {
|
||||
texts = result.mText;
|
||||
}
|
||||
if (recScores == null) {
|
||||
recScores = result.mRecScores;
|
||||
}
|
||||
initialized = result.initialized();
|
||||
if (initialized) {
|
||||
for (int i = 0; i < texts.length; i++) {
|
||||
if (recScores[i] > resultNum) {
|
||||
results.add(new BaseResultModel(i + 1, texts[i], recScores[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
BaseResultAdapter adapter = new BaseResultAdapter(getBaseContext(), R.layout.ocr_result_page_item, results);
|
||||
resultView.setAdapter(adapter);
|
||||
resultView.invalidate();
|
||||
|
||||
resultImage.setImageBitmap(bitmap);
|
||||
resultNum = 1.0f;
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
|
@@ -1,8 +1,5 @@
|
||||
package com.baidu.paddle.fastdeploy.app.examples.segmentation;
|
||||
|
||||
import static com.baidu.paddle.fastdeploy.app.ui.Utils.decodeBitmap;
|
||||
import static com.baidu.paddle.fastdeploy.app.ui.Utils.getRealPathFromURI;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
@@ -31,16 +28,17 @@ import android.widget.TextView;
|
||||
|
||||
import com.baidu.paddle.fastdeploy.RuntimeOption;
|
||||
import com.baidu.paddle.fastdeploy.app.examples.R;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.Utils;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.view.CameraSurfaceView;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.view.ResultListView;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.view.adapter.BaseResultAdapter;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.Utils;
|
||||
import com.baidu.paddle.fastdeploy.app.ui.view.model.BaseResultModel;
|
||||
import com.baidu.paddle.fastdeploy.vision.SegmentationResult;
|
||||
import com.baidu.paddle.fastdeploy.vision.Visualize;
|
||||
import com.baidu.paddle.fastdeploy.vision.segmentation.PaddleSegModel;
|
||||
|
||||
import java.io.File;
|
||||
import static com.baidu.paddle.fastdeploy.app.ui.Utils.decodeBitmap;
|
||||
import static com.baidu.paddle.fastdeploy.app.ui.Utils.getRealPathFromURI;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -64,11 +62,9 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
private SeekBar confidenceSeekbar;
|
||||
private TextView seekbarText;
|
||||
private float resultNum = 1.0f;
|
||||
private ResultListView detectResultView;
|
||||
private ResultListView resultView;
|
||||
private Bitmap shutterBitmap;
|
||||
private Bitmap originShutterBitmap;
|
||||
private Bitmap picBitmap;
|
||||
private Bitmap originPicBitmap;
|
||||
private boolean isShutterBitmapCopied = false;
|
||||
|
||||
public static final int TYPE_UNKNOWN = -1;
|
||||
@@ -81,12 +77,12 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
private static final int INTENT_CODE_PICK_IMAGE = 100;
|
||||
private static final int TIME_SLEEP_INTERVAL = 50; // ms
|
||||
|
||||
String savedImagePath = "result.jpg";
|
||||
long timeElapsed = 0;
|
||||
long frameCounter = 0;
|
||||
|
||||
// Call 'init' and 'release' manually later
|
||||
PaddleSegModel predictor = new PaddleSegModel();
|
||||
private List<BaseResultModel> results = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -120,6 +116,7 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
case R.id.btn_shutter:
|
||||
TYPE = BTN_SHUTTER;
|
||||
shutterAndPauseCamera();
|
||||
resultView.setAdapter(null);
|
||||
break;
|
||||
case R.id.btn_settings:
|
||||
startActivity(new Intent(SegmentationMainActivity.this, SegmentationSettingsActivity.class));
|
||||
@@ -141,15 +138,27 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(intent, INTENT_CODE_PICK_IMAGE);
|
||||
}
|
||||
resultView.setAdapter(null);
|
||||
break;
|
||||
case R.id.back_in_result:
|
||||
back();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
back();
|
||||
}
|
||||
|
||||
private void back() {
|
||||
resultPageView.setVisibility(View.GONE);
|
||||
cameraPageView.setVisibility(View.VISIBLE);
|
||||
TYPE = REALTIME_DETECT;
|
||||
isShutterBitmapCopied = false;
|
||||
svPreview.onResume();
|
||||
break;
|
||||
}
|
||||
results.clear();
|
||||
}
|
||||
|
||||
private void shutterAndPauseCamera() {
|
||||
@@ -172,7 +181,7 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
seekbarText.setText(resultNum + "");
|
||||
confidenceSeekbar.setProgress((int) (resultNum * 100));
|
||||
if (shutterBitmap != null && !shutterBitmap.isRecycled()) {
|
||||
resultImage.setImageBitmap(shutterBitmap);
|
||||
detail(shutterBitmap);
|
||||
} else {
|
||||
new AlertDialog.Builder(SegmentationMainActivity.this)
|
||||
.setTitle("Empty Result!")
|
||||
@@ -193,7 +202,6 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
if (!ARGB8888ImageBitmap.isRecycled()) {
|
||||
synchronized (this) {
|
||||
shutterBitmap = ARGB8888ImageBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
originShutterBitmap = ARGB8888ImageBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
}
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL);
|
||||
isShutterBitmapCopied = true;
|
||||
@@ -211,9 +219,10 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
confidenceSeekbar.setProgress((int) (resultNum * 100));
|
||||
Uri uri = data.getData();
|
||||
String path = getRealPathFromURI(this, uri);
|
||||
picBitmap = decodeBitmap(path, 720, 1280);
|
||||
originPicBitmap = picBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
resultImage.setImageBitmap(picBitmap);
|
||||
Bitmap bitmap = decodeBitmap(path, 720, 1280);
|
||||
picBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL * 10); // 500ms
|
||||
detail(picBitmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -244,27 +253,12 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
copyBitmapFromCamera(ARGB8888ImageBitmap);
|
||||
return false;
|
||||
}
|
||||
|
||||
String savedImagePath = "";
|
||||
synchronized (this) {
|
||||
savedImagePath = Utils.getDCIMDirectory() + File.separator + "result.jpg";
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
|
||||
long tc = System.currentTimeMillis();
|
||||
SegmentationResult result = predictor.predict(ARGB8888ImageBitmap);
|
||||
timeElapsed += (System.currentTimeMillis() - tc);
|
||||
|
||||
Visualize.visSegmentation(ARGB8888ImageBitmap, result);
|
||||
|
||||
modified = result.initialized();
|
||||
if (!savedImagePath.isEmpty()) {
|
||||
synchronized (this) {
|
||||
SegmentationMainActivity.this.savedImagePath = "result.jpg";
|
||||
}
|
||||
}
|
||||
|
||||
frameCounter++;
|
||||
if (frameCounter >= 30) {
|
||||
final int fps = (int) (1000 / (timeElapsed / 30));
|
||||
@@ -308,16 +302,8 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
|
||||
public void initView() {
|
||||
TYPE = REALTIME_DETECT;
|
||||
// For front face camera and human seg, the smaller width and height
|
||||
// may get both better result and performance. EXPECTED_PREVIEW_HEIGHT
|
||||
// should be 'width' and EXPECTED_PREVIEW_WIDTH should be 'height' if
|
||||
// your camera display orientation is rotate (degree == 90 || degree == 270).
|
||||
// The transformation will auto process in camera.
|
||||
CameraSurfaceView.EXPECTED_PREVIEW_HEIGHT = 360;
|
||||
CameraSurfaceView.EXPECTED_PREVIEW_WIDTH = 720;
|
||||
svPreview = (CameraSurfaceView) findViewById(R.id.sv_preview);
|
||||
svPreview.setOnTextureChangedListener(this);
|
||||
svPreview.switchCamera(); // switch to front camera for human seg
|
||||
tvStatus = (TextView) findViewById(R.id.tv_status);
|
||||
btnSwitch = (ImageButton) findViewById(R.id.btn_switch);
|
||||
btnSwitch.setOnClickListener(this);
|
||||
@@ -338,16 +324,7 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
backInResult.setOnClickListener(this);
|
||||
confidenceSeekbar = findViewById(R.id.confidence_seekbar);
|
||||
seekbarText = findViewById(R.id.seekbar_text);
|
||||
detectResultView = findViewById(R.id.result_list_view);
|
||||
|
||||
List<BaseResultModel> results = new ArrayList<>();
|
||||
// TODO: add model results from SegmentationResult instead of using fake data.
|
||||
results.add(new BaseResultModel(1, "human", 1.0f));
|
||||
results.add(new BaseResultModel(2, "human", 1.0f));
|
||||
results.add(new BaseResultModel(3, "human", 1.0f));
|
||||
final BaseResultAdapter adapter = new BaseResultAdapter(this, R.layout.facedet_result_page_item, results);
|
||||
detectResultView.setAdapter(adapter);
|
||||
detectResultView.invalidate();
|
||||
resultView = findViewById(R.id.result_list_view);
|
||||
|
||||
confidenceSeekbar.setMax(100);
|
||||
confidenceSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@@ -358,6 +335,7 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
resultNum = bd.setScale(1, BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
seekbarText.setText(resultNum + "");
|
||||
confidenceSeekbar.setProgress((int) (resultNum * 100));
|
||||
results.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -367,30 +345,27 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (TYPE == ALBUM_SELECT) {
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL * 10); // 500ms
|
||||
if (!picBitmap.isRecycled()) {
|
||||
predictor.predict(picBitmap, true, resultNum);
|
||||
resultImage.setImageBitmap(picBitmap);
|
||||
picBitmap = originPicBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
}
|
||||
resultNum = 1.0f;
|
||||
} else {
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL * 10); // 500ms
|
||||
if (!shutterBitmap.isRecycled()) {
|
||||
predictor.predict(shutterBitmap, true, resultNum);
|
||||
resultImage.setImageBitmap(shutterBitmap);
|
||||
shutterBitmap = originShutterBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
}
|
||||
resultNum = 1.0f;
|
||||
}
|
||||
// runOnUiThread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// if (TYPE == ALBUM_SELECT) {
|
||||
// SystemClock.sleep(TIME_SLEEP_INTERVAL * 10); // 500ms
|
||||
// detail(picBitmap);
|
||||
// } else {
|
||||
// SystemClock.sleep(TIME_SLEEP_INTERVAL * 10); // 500ms
|
||||
// svPreview.onPause();
|
||||
// detail(shutterBitmap);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
private void detail(Bitmap bitmap) {
|
||||
predictor.predict(bitmap, true, 0.6f);
|
||||
resultImage.setImageBitmap(bitmap);
|
||||
resultNum = 1.0f;
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
@@ -448,32 +423,5 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
return ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
|
||||
&& ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -16,12 +16,16 @@ import android.view.WindowManager;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Utils {
|
||||
@@ -286,4 +290,24 @@ public class Utils {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<String> readTxt(String txtPath) {
|
||||
File file = new File(txtPath);
|
||||
if (file.isFile() && file.exists()) {
|
||||
try {
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
|
||||
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
|
||||
String text;
|
||||
List<String> labels = new ArrayList<>();
|
||||
while ((text = bufferedReader.readLine()) != null) {
|
||||
labels.add(text);
|
||||
}
|
||||
return labels;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -64,7 +64,7 @@
|
||||
android:layout_centerInParent="true" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/albumSelect"
|
||||
android:id="@+id/iv_select"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentRight="true"
|
||||
|
@@ -62,7 +62,7 @@
|
||||
android:layout_centerInParent="true" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/albumSelect"
|
||||
android:id="@+id/iv_select"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentRight="true"
|
||||
|
@@ -47,14 +47,13 @@
|
||||
<TextView
|
||||
android:id="@+id/action_realtime_btn"
|
||||
style="@style/action_btn"
|
||||
android:layout_width="300px"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/action_bar_realtime"
|
||||
android:textAlignment="center" />
|
||||
</LinearLayout>
|
||||
</com.baidu.paddle.fastdeploy.app.ui.layout.ActionBarLayout>
|
||||
|
||||
<!-- 实时-->
|
||||
<com.baidu.paddle.fastdeploy.app.ui.view.CameraSurfaceView
|
||||
android:id="@+id/sv_preview"
|
||||
android:layout_width="match_parent"
|
||||
@@ -64,7 +63,7 @@
|
||||
android:layout_centerInParent="true" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/albumSelect"
|
||||
android:id="@+id/iv_select"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentRight="true"
|
||||
|
Reference in New Issue
Block a user