append Merge branch 'develop' into gbd_android

This commit is contained in:
DefTruth
2022-11-07 20:25:30 +08:00
committed by WinterGeng
46 changed files with 1388 additions and 298 deletions

View File

@@ -15,14 +15,14 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".detection.MainActivity">
<activity android:name=".ocr.OcrMainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".detection.SettingsActivity"
android:name=".ocr.OcrSettingsActivity"
android:label="Settings">
</activity>
</application>

View File

@@ -44,8 +44,8 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends Activity implements View.OnClickListener, CameraSurfaceView.OnTextureChangedListener {
private static final String TAG = MainActivity.class.getSimpleName();
public class DetectionMainActivity extends Activity implements View.OnClickListener, CameraSurfaceView.OnTextureChangedListener {
private static final String TAG = DetectionMainActivity.class.getSimpleName();
CameraSurfaceView svPreview;
TextView tvStatus;
@@ -90,7 +90,7 @@ public class MainActivity extends Activity implements View.OnClickListener, Came
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.default_activity_main);
setContentView(R.layout.detection_activity_main);
// Clear all setting items to avoid app crashing due to the incorrect settings
initSettings();
@@ -121,7 +121,7 @@ public class MainActivity extends Activity implements View.OnClickListener, Came
resultImage.setImageBitmap(shutterBitmap);
break;
case R.id.btn_settings:
startActivity(new Intent(MainActivity.this, SettingsActivity.class));
startActivity(new Intent(DetectionMainActivity.this, DetectionSettingsActivity.class));
break;
case R.id.realtime_toggle_btn:
toggleRealtimeStyle();
@@ -216,11 +216,11 @@ public class MainActivity extends Activity implements View.OnClickListener, Came
originShutterBitmap = ARGB8888ImageBitmap.copy(Bitmap.Config.ARGB_8888,true);
boolean modified = false;
DetectionResult result = predictor.predict(
ARGB8888ImageBitmap, savedImagePath, SettingsActivity.scoreThreshold);
ARGB8888ImageBitmap, savedImagePath, DetectionSettingsActivity.scoreThreshold);
modified = result.initialized();
if (!savedImagePath.isEmpty()) {
synchronized (this) {
MainActivity.this.savedImagePath = "result.jpg";
DetectionMainActivity.this.savedImagePath = "result.jpg";
}
}
lastFrameIndex++;
@@ -325,7 +325,7 @@ public class MainActivity extends Activity implements View.OnClickListener, Came
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 DetectResultAdapter adapter = new DetectResultAdapter(this, R.layout.default_result_page_item, results);
final DetectResultAdapter adapter = new DetectResultAdapter(this, R.layout.detection_result_page_item, results);
detectResultView.setAdapter(adapter);
detectResultView.invalidate();
@@ -375,25 +375,25 @@ public class MainActivity extends Activity implements View.OnClickListener, Came
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.clear();
editor.commit();
SettingsActivity.resetSettings();
DetectionSettingsActivity.resetSettings();
}
public void checkAndUpdateSettings() {
if (SettingsActivity.checkAndUpdateSettings(this)) {
String realModelDir = getCacheDir() + "/" + SettingsActivity.modelDir;
Utils.copyDirectoryFromAssets(this, SettingsActivity.modelDir, realModelDir);
String realLabelPath = getCacheDir() + "/" + SettingsActivity.labelPath;
Utils.copyFileFromAssets(this, SettingsActivity.labelPath, realLabelPath);
if (DetectionSettingsActivity.checkAndUpdateSettings(this)) {
String realModelDir = getCacheDir() + "/" + DetectionSettingsActivity.modelDir;
Utils.copyDirectoryFromAssets(this, DetectionSettingsActivity.modelDir, realModelDir);
String realLabelPath = getCacheDir() + "/" + DetectionSettingsActivity.labelPath;
Utils.copyFileFromAssets(this, DetectionSettingsActivity.labelPath, realLabelPath);
String modelFile = realModelDir + "/" + "model.pdmodel";
String paramsFile = realModelDir + "/" + "model.pdiparams";
String configFile = realModelDir + "/" + "infer_cfg.yml";
String labelFile = realLabelPath;
RuntimeOption option = new RuntimeOption();
option.setCpuThreadNum(SettingsActivity.cpuThreadNum);
option.setLitePowerMode(SettingsActivity.cpuPowerMode);
option.setCpuThreadNum(DetectionSettingsActivity.cpuThreadNum);
option.setLitePowerMode(DetectionSettingsActivity.cpuPowerMode);
option.enableRecordTimeOfRuntime();
if (Boolean.parseBoolean(SettingsActivity.enableLiteFp16)) {
if (Boolean.parseBoolean(DetectionSettingsActivity.enableLiteFp16)) {
option.enableLiteFp16();
}
predictor.init(modelFile, paramsFile, configFile, labelFile, option);
@@ -405,7 +405,7 @@ public class MainActivity extends Activity implements View.OnClickListener, Came
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (grantResults[0] != PackageManager.PERMISSION_GRANTED || grantResults[1] != PackageManager.PERMISSION_GRANTED) {
new AlertDialog.Builder(MainActivity.this)
new AlertDialog.Builder(DetectionMainActivity.this)
.setTitle("Permission denied")
.setMessage("Click to force quit the app, then open Settings->Apps & notifications->Target " +
"App->Permissions to grant all of the permissions.")
@@ -413,7 +413,7 @@ public class MainActivity extends Activity implements View.OnClickListener, Came
.setPositiveButton("Exit", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
MainActivity.this.finish();
DetectionMainActivity.this.finish();
}
}).show();
}

View File

@@ -16,9 +16,9 @@ import com.baidu.paddle.fastdeploy.app.ui.Utils;
import java.util.ArrayList;
import java.util.List;
public class SettingsActivity extends AppCompatPreferenceActivity implements
public class DetectionSettingsActivity extends AppCompatPreferenceActivity implements
SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = SettingsActivity.class.getSimpleName();
private static final String TAG = DetectionSettingsActivity.class.getSimpleName();
static public int selectedModelIdx = -1;
static public String modelDir = "";

View File

@@ -25,8 +25,8 @@ 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.CameraSurfaceView;
import com.baidu.paddle.fastdeploy.app.ui.view.Utils;
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.pipeline.PPOCRv2;
import com.baidu.paddle.fastdeploy.vision.ocr.Classifier;
@@ -37,8 +37,8 @@ import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
public class MainActivity extends Activity implements View.OnClickListener, CameraSurfaceView.OnTextureChangedListener {
private static final String TAG = MainActivity.class.getSimpleName();
public class OcrMainActivity extends Activity implements View.OnClickListener, CameraSurfaceView.OnTextureChangedListener {
private static final String TAG = OcrMainActivity.class.getSimpleName();
CameraSurfaceView svPreview;
TextView tvStatus;
@@ -64,7 +64,7 @@ public class MainActivity extends Activity implements View.OnClickListener, Came
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
setContentView(R.layout.ocr_activity_main);
// Clear all setting items to avoid app crashing due to the incorrect settings
initSettings();
@@ -91,10 +91,10 @@ public class MainActivity extends Activity implements View.OnClickListener, Came
synchronized (this) {
savedImagePath = Utils.getDCIMDirectory() + File.separator + date.format(new Date()).toString() + ".png";
}
Toast.makeText(MainActivity.this, "Save snapshot to " + savedImagePath, Toast.LENGTH_SHORT).show();
Toast.makeText(OcrMainActivity.this, "Save snapshot to " + savedImagePath, Toast.LENGTH_SHORT).show();
break;
case R.id.btn_settings:
startActivity(new Intent(MainActivity.this, SettingsActivity.class));
startActivity(new Intent(OcrMainActivity.this, OcrSettingsActivity.class));
break;
case R.id.realtime_toggle_btn:
toggleRealtimeStyle();
@@ -128,14 +128,14 @@ public class MainActivity extends Activity implements View.OnClickListener, Came
public boolean onTextureChanged(Bitmap ARGB8888ImageBitmap) {
String savedImagePath = "";
synchronized (this) {
savedImagePath = MainActivity.this.savedImagePath;
savedImagePath = OcrMainActivity.this.savedImagePath;
}
boolean modified = false;
OCRResult result = predictor.predict(ARGB8888ImageBitmap, savedImagePath);
modified = result.initialized();
if (!savedImagePath.isEmpty()) {
synchronized (this) {
MainActivity.this.savedImagePath = "result.jpg";
OcrMainActivity.this.savedImagePath = "result.jpg";
}
}
lastFrameIndex++;
@@ -201,12 +201,12 @@ public class MainActivity extends Activity implements View.OnClickListener, Came
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.clear();
editor.commit();
SettingsActivity.resetSettings();
OcrSettingsActivity.resetSettings();
}
public void checkAndUpdateSettings() {
if (SettingsActivity.checkAndUpdateSettings(this)) {
String realModelDir = getCacheDir() + "/" + SettingsActivity.modelDir;
if (OcrSettingsActivity.checkAndUpdateSettings(this)) {
String realModelDir = getCacheDir() + "/" + OcrSettingsActivity.modelDir;
// String detModelName = "ch_PP-OCRv2_det_infer";
String detModelName = "ch_PP-OCRv3_det_infer";
// String detModelName = "ch_ppocr_mobile_v2.0_det_infer";
@@ -217,14 +217,14 @@ public class MainActivity extends Activity implements View.OnClickListener, Came
String realDetModelDir = realModelDir + "/" + detModelName;
String realClsModelDir = realModelDir + "/" + clsModelName;
String realRecModelDir = realModelDir + "/" + recModelName;
String srcDetModelDir = SettingsActivity.modelDir + "/" + detModelName;
String srcClsModelDir = SettingsActivity.modelDir + "/" + clsModelName;
String srcRecModelDir = SettingsActivity.modelDir + "/" + recModelName;
String srcDetModelDir = OcrSettingsActivity.modelDir + "/" + detModelName;
String srcClsModelDir = OcrSettingsActivity.modelDir + "/" + clsModelName;
String srcRecModelDir = OcrSettingsActivity.modelDir + "/" + recModelName;
Utils.copyDirectoryFromAssets(this, srcDetModelDir, realDetModelDir);
Utils.copyDirectoryFromAssets(this, srcClsModelDir, realClsModelDir);
Utils.copyDirectoryFromAssets(this, srcRecModelDir, realRecModelDir);
String realLabelPath = getCacheDir() + "/" + SettingsActivity.labelPath;
Utils.copyFileFromAssets(this, SettingsActivity.labelPath, realLabelPath);
String realLabelPath = getCacheDir() + "/" + OcrSettingsActivity.labelPath;
Utils.copyFileFromAssets(this, OcrSettingsActivity.labelPath, realLabelPath);
String detModelFile = realDetModelDir + "/" + "inference.pdmodel";
String detParamsFile = realDetModelDir + "/" + "inference.pdiparams";
@@ -236,16 +236,16 @@ public class MainActivity extends Activity implements View.OnClickListener, Came
RuntimeOption detOption = new RuntimeOption();
RuntimeOption clsOption = new RuntimeOption();
RuntimeOption recOption = new RuntimeOption();
detOption.setCpuThreadNum(SettingsActivity.cpuThreadNum);
clsOption.setCpuThreadNum(SettingsActivity.cpuThreadNum);
recOption.setCpuThreadNum(SettingsActivity.cpuThreadNum);
detOption.setLitePowerMode(SettingsActivity.cpuPowerMode);
clsOption.setLitePowerMode(SettingsActivity.cpuPowerMode);
recOption.setLitePowerMode(SettingsActivity.cpuPowerMode);
detOption.setCpuThreadNum(OcrSettingsActivity.cpuThreadNum);
clsOption.setCpuThreadNum(OcrSettingsActivity.cpuThreadNum);
recOption.setCpuThreadNum(OcrSettingsActivity.cpuThreadNum);
detOption.setLitePowerMode(OcrSettingsActivity.cpuPowerMode);
clsOption.setLitePowerMode(OcrSettingsActivity.cpuPowerMode);
recOption.setLitePowerMode(OcrSettingsActivity.cpuPowerMode);
detOption.enableRecordTimeOfRuntime();
clsOption.enableRecordTimeOfRuntime();
recOption.enableRecordTimeOfRuntime();
if (Boolean.parseBoolean(SettingsActivity.enableLiteFp16)) {
if (Boolean.parseBoolean(OcrSettingsActivity.enableLiteFp16)) {
detOption.enableLiteFp16();
clsOption.enableLiteFp16();
recOption.enableLiteFp16();
@@ -263,7 +263,7 @@ public class MainActivity extends Activity implements View.OnClickListener, Came
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (grantResults[0] != PackageManager.PERMISSION_GRANTED || grantResults[1] != PackageManager.PERMISSION_GRANTED) {
new AlertDialog.Builder(MainActivity.this)
new AlertDialog.Builder(OcrMainActivity.this)
.setTitle("Permission denied")
.setMessage("Click to force quit the app, then open Settings->Apps & notifications->Target " +
"App->Permissions to grant all of the permissions.")
@@ -271,7 +271,7 @@ public class MainActivity extends Activity implements View.OnClickListener, Came
.setPositiveButton("Exit", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
MainActivity.this.finish();
OcrMainActivity.this.finish();
}
}).show();
}

View File

@@ -10,15 +10,15 @@ import android.preference.PreferenceManager;
import android.support.v7.app.ActionBar;
import com.baidu.paddle.fastdeploy.app.examples.R;
import com.baidu.paddle.fastdeploy.app.ui.AppCompatPreferenceActivity;
import com.baidu.paddle.fastdeploy.app.ui.view.Utils;
import com.baidu.paddle.fastdeploy.app.ui.Utils;
import com.baidu.paddle.fastdeploy.app.ui.view.AppCompatPreferenceActivity;
import java.util.ArrayList;
import java.util.List;
public class SettingsActivity extends AppCompatPreferenceActivity implements
public class OcrSettingsActivity extends AppCompatPreferenceActivity implements
SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = SettingsActivity.class.getSimpleName();
private static final String TAG = OcrSettingsActivity.class.getSimpleName();
static public int selectedModelIdx = -1;
static public String modelDir = "";

View File

@@ -1,99 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
tools:context="com.baidu.paddle.fastdeploy.app.examples.ocr.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWindow">
<com.baidu.paddle.fastdeploy.app.ui.view.CameraSurfaceView
android:id="@+id/sv_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true" />
<RelativeLayout
android:layout_width="@dimen/top_bar_height"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:background="@color/colorTopBar">
<TextView
android:id="@+id/tv_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="@dimen/top_bar_left_right_margin"
android:layout_marginBottom="@dimen/top_bar_left_right_margin"
android:textColor="@color/colorText"
android:gravity="center"
android:textSize="@dimen/small_font_size" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="@color/colorBottomBar"
android:orientation="horizontal">
<LinearLayout
android:layout_width="@dimen/bottom_bar_top_margin"
android:layout_height="match_parent"
android:orientation="horizontal"></LinearLayout>
<RelativeLayout
android:layout_width="@dimen/large_button_height"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/btn_switch"
android:layout_width="@dimen/small_button_width"
android:layout_height="@dimen/small_button_height"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/bottom_bar_left_right_margin"
android:layout_marginBottom="@dimen/bottom_bar_left_right_margin"
android:background="#00000000"
android:scaleType="fitXY"
android:src="@drawable/btn_switch" />
<ImageButton
android:id="@+id/btn_shutter"
android:layout_width="@dimen/large_button_width"
android:layout_height="@dimen/large_button_height"
android:layout_centerInParent="true"
android:background="@null"
android:focusable="true"
android:focusableInTouchMode="true"
android:scaleType="fitXY"
android:src="@drawable/btn_shutter" />
<ImageButton
android:id="@+id/btn_settings"
android:layout_width="@dimen/small_button_width"
android:layout_height="@dimen/small_button_width"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/bottom_bar_left_right_margin"
android:background="@null"
android:scaleType="fitXY"
android:src="@drawable/btn_settings" />
</RelativeLayout>
<LinearLayout
android:layout_width="@dimen/bottom_bar_bottom_margin"
android:layout_height="match_parent"
android:orientation="horizontal"></LinearLayout>
</LinearLayout>
</RelativeLayout>
</android.support.constraint.ConstraintLayout>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/detection_camera_page"
android:id="@+id/camera_page"></include>
<include
layout="@layout/detection_result_page"
android:id="@+id/result_page"
android:visibility="gone"></include>
</FrameLayout>

View File

@@ -4,11 +4,11 @@
android:layout_height="match_parent">
<include
layout="@layout/default_camera_page"
layout="@layout/ocr_camera_page"
android:id="@+id/camera_page"></include>
<include
layout="@layout/default_result_page"
layout="@layout/ocr_result_page"
android:id="@+id/result_page"
android:visibility="gone"></include>
</FrameLayout>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/detection_camera_page"
android:id="@+id/camera_page"></include>
<include
layout="@layout/detection_result_page"
android:id="@+id/result_page"
android:visibility="gone"></include>
</FrameLayout>

View File

@@ -0,0 +1,161 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
tools:context=".detection.DetectionMainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWindow">
<com.baidu.paddle.fastdeploy.app.ui.layout.ActionBarLayout
android:id="@+id/action_bar_main"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/back_in_preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cropToPadding="true"
android:paddingLeft="40px"
android:paddingTop="60px"
android:paddingRight="60px"
android:paddingBottom="40px"
android:src="@drawable/back_btn" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="50px"
android:orientation="horizontal">
<TextView
android:id="@+id/action_takepicture_btn"
style="@style/action_btn_selected"
android:layout_width="300px"
android:layout_height="wrap_content"
android:text="@string/action_bar_take_photo"
android:textAlignment="center"
android:visibility="gone"/>
<TextView
android:id="@+id/action_realtime_btn"
style="@style/action_btn"
android:layout_width="300px"
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"
android:layout_height="match_parent"
android:layout_above="@+id/contral"
android:layout_below="@+id/action_bar_main"
android:layout_centerInParent="true" />
<ImageView
android:id="@+id/albumSelect"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="20dp"
android:layout_marginBottom="145dp"
android:background="@drawable/album_btn"
android:scaleType="fitXY" />
<TextView
android:id="@+id/tv_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="60dp"
android:layout_marginRight="30dp"
android:textColor="@color/colorText"
android:textSize="@dimen/small_font_size" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/top_bar_height"
android:layout_alignParentTop="true"
android:background="@color/colorTopBar">
<ImageButton
android:id="@+id/btn_settings"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:background="@null"
android:scaleType="fitXY"
android:src="@drawable/btn_settings" />
</RelativeLayout>
<LinearLayout
android:id="@+id/contral"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/colorBottomBar"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_bar_top_margin"
android:orientation="vertical"></LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/large_button_height">
<ImageButton
android:id="@+id/btn_switch"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="60dp"
android:background="#00000000"
android:scaleType="fitXY"
android:src="@drawable/switch_side_btn" />
<ImageButton
android:id="@+id/btn_shutter"
android:layout_width="@dimen/large_button_width"
android:layout_height="@dimen/large_button_height"
android:layout_centerInParent="true"
android:background="@null"
android:scaleType="fitXY"
android:src="@drawable/take_picture_btn" />
<ImageView
android:id="@+id/realtime_toggle_btn"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="60dp"
android:scaleType="fitXY"
android:src="@drawable/realtime_stop_btn" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_bar_bottom_margin"
android:orientation="vertical"></LinearLayout>
</LinearLayout>
</RelativeLayout>
</android.support.constraint.ConstraintLayout>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/ocr_camera_page"
android:id="@+id/camera_page"></include>
<include
layout="@layout/ocr_result_page"
android:id="@+id/result_page"
android:visibility="gone"></include>
</FrameLayout>

View File

@@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
tools:context=".MainActivity">
tools:context=".ocr.OcrMainActivity">
<RelativeLayout
android:layout_width="match_parent"

View File

@@ -0,0 +1,160 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical">
<com.baidu.paddle.fastdeploy.app.ui.layout.ActionBarLayout
android:id="@+id/action_bar_result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/back_in_result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cropToPadding="true"
android:paddingLeft="40px"
android:paddingTop="60px"
android:paddingRight="60px"
android:paddingBottom="40px"
android:src="@drawable/back_btn" />
<TextView
android:id="@+id/model_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="50px"
android:textColor="@color/textColor"
android:textSize="@dimen/action_btn_text_size" />
</com.baidu.paddle.fastdeploy.app.ui.layout.ActionBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="700px">
<ImageView
android:id="@+id/result_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bk_result_image_padding" />
</FrameLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40px"
android:layout_marginTop="26px"
android:layout_marginBottom="20px"
android:text="@string/result_label"
android:textColor="@color/bk_black"
android:textSize="56px"
android:visibility="visible" />
<LinearLayout
android:id="@+id/result_seekbar_section"
android:layout_width="match_parent"
android:layout_height="130px"
android:layout_marginLeft="@dimen/result_list_padding_lr"
android:layout_marginRight="@dimen/result_list_padding_lr"
android:layout_marginBottom="@dimen/result_list_gap_width"
android:background="@drawable/result_page_border_section_bk"
android:visibility="visible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:paddingLeft="30px"
android:text="@string/result_table_header_confidence"
android:textColor="@color/table_result_tableheader_text_color"
android:textSize="@dimen/result_list_view_text_size" />
<SeekBar
android:id="@+id/confidence_seekbar"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="6"
android:focusable="false"
android:maxHeight="8px"
android:progressDrawable="@drawable/seekbar_progress_result"
android:splitTrack="false"
android:thumb="@drawable/seekbar_handle" />
<TextView
android:id="@+id/seekbar_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:paddingRight="30px"
android:textSize="@dimen/result_list_view_text_size"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/result_list_padding_lr"
android:layout_marginRight="@dimen/result_list_padding_lr"
android:layout_marginBottom="@dimen/result_list_gap_width"
android:background="@drawable/result_page_border_section_bk"
android:visibility="visible">
<TextView
style="@style/list_result_view_tablehead_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/result_table_header_index"
android:textColor="@color/table_result_tableheader_text_color" />
<TextView
style="@style/list_result_view_tablehead_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/result_table_header_name"
android:textColor="@color/table_result_tableheader_text_color" />
<TextView
style="@style/list_result_view_tablehead_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:gravity="right"
android:text="@string/result_table_header_confidence"
android:textColor="@color/table_result_tableheader_text_color" />
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15px"
android:paddingLeft="@dimen/result_list_padding_lr"
android:paddingRight="@dimen/result_list_padding_lr">
<com.baidu.paddle.fastdeploy.app.ui.view.ResultListView
android:id="@+id/result_list_view"
android:layout_width="match_parent"
android:layout_height="700px"
android:divider="#FFFFFF"
android:dividerHeight="@dimen/result_list_gap_width"></com.baidu.paddle.fastdeploy.app.ui.view.ResultListView>
</ScrollView>
</FrameLayout>
</LinearLayout>
</FrameLayout>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/result_page_border_section_bk">
<TextView
android:id="@+id/index"
style="@style/list_result_view_item_style"
android:layout_width="wrap_content"
android:layout_weight="0.2" />
<TextView
android:id="@+id/name"
style="@style/list_result_view_item_style"
android:layout_width="wrap_content"
android:layout_weight="0.6"
android:maxWidth="300px" />
<TextView
android:id="@+id/confidence"
style="@style/list_result_view_item_style"
android:layout_weight="0.2"
android:layout_width="wrap_content" />
</LinearLayout>