mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 08:37:06 +08:00
Merge branch 'develop' into add_batch_size_for_uie
This commit is contained in:
@@ -22,8 +22,7 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".segmentation.SegmentationMainActivity"
|
||||
android:label="Settings">
|
||||
android:name=".segmentation.SegmentationMainActivity">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".segmentation.SegmentationSettingsActivity"
|
||||
|
@@ -0,0 +1,400 @@
|
||||
package com.baidu.paddle.fastdeploy.app.examples.facealign;
|
||||
|
||||
import static com.baidu.paddle.fastdeploy.ui.Utils.decodeBitmap;
|
||||
import static com.baidu.paddle.fastdeploy.ui.Utils.getRealPathFromURI;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
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.TextView;
|
||||
|
||||
import com.baidu.paddle.fastdeploy.RuntimeOption;
|
||||
import com.baidu.paddle.fastdeploy.app.examples.R;
|
||||
import com.baidu.paddle.fastdeploy.ui.Utils;
|
||||
import com.baidu.paddle.fastdeploy.ui.view.CameraSurfaceView;
|
||||
import com.baidu.paddle.fastdeploy.ui.view.ResultListView;
|
||||
import com.baidu.paddle.fastdeploy.ui.view.model.BaseResultModel;
|
||||
import com.baidu.paddle.fastdeploy.vision.Visualize;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FaceAlignMainActivity extends Activity implements View.OnClickListener, CameraSurfaceView.OnTextureChangedListener {
|
||||
private static final String TAG = FaceAlignMainActivity.class.getSimpleName();
|
||||
|
||||
CameraSurfaceView svPreview;
|
||||
TextView tvStatus;
|
||||
ImageButton btnSwitch;
|
||||
ImageButton btnShutter;
|
||||
ImageButton btnSettings;
|
||||
ImageView realtimeToggleButton;
|
||||
boolean isRealtimeStatusRunning = false;
|
||||
ImageView backInPreview;
|
||||
private ImageView albumSelectButton;
|
||||
private View cameraPageView;
|
||||
private ViewGroup resultPageView;
|
||||
private ImageView resultImage;
|
||||
private ImageView backInResult;
|
||||
private ResultListView resultView;
|
||||
private Bitmap shutterBitmap;
|
||||
private Bitmap picBitmap;
|
||||
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;
|
||||
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;
|
||||
|
||||
// todo Call 'init' and 'release' manually later
|
||||
//PaddleSegModel predictor = new PaddleSegModel();
|
||||
private List<BaseResultModel> results = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Fullscreen
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
|
||||
setContentView(R.layout.face_align_activity_main);
|
||||
|
||||
// Clear all setting items to avoid app crashing due to the incorrect settings
|
||||
initSettings();
|
||||
|
||||
// Check and request CAMERA and WRITE_EXTERNAL_STORAGE permissions
|
||||
if (!checkAllPermissions()) {
|
||||
requestAllPermissions();
|
||||
}
|
||||
|
||||
// Init the camera preview and UI components
|
||||
initView();
|
||||
}
|
||||
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.btn_switch:
|
||||
svPreview.switchCamera();
|
||||
break;
|
||||
case R.id.btn_shutter:
|
||||
TYPE = BTN_SHUTTER;
|
||||
shutterAndPauseCamera();
|
||||
resultView.setAdapter(null);
|
||||
break;
|
||||
case R.id.btn_settings:
|
||||
startActivity(new Intent(FaceAlignMainActivity.this, FaceAlignSettingsActivity.class));
|
||||
break;
|
||||
case R.id.realtime_toggle_btn:
|
||||
toggleRealtimeStyle();
|
||||
break;
|
||||
case R.id.back_in_preview:
|
||||
finish();
|
||||
break;
|
||||
case R.id.album_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();
|
||||
}
|
||||
|
||||
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 codes will run in main thread.
|
||||
svPreview.onPause();
|
||||
cameraPageView.setVisibility(View.GONE);
|
||||
resultPageView.setVisibility(View.VISIBLE);
|
||||
if (shutterBitmap != null && !shutterBitmap.isRecycled()) {
|
||||
detail(shutterBitmap);
|
||||
} else {
|
||||
new AlertDialog.Builder(FaceAlignMainActivity.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);
|
||||
Uri uri = data.getData();
|
||||
String path = getRealPathFromURI(this, uri);
|
||||
Bitmap bitmap = decodeBitmap(path, 720, 1280);
|
||||
picBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL * 10); // 500ms
|
||||
detail(picBitmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleRealtimeStyle() {
|
||||
if (isRealtimeStatusRunning) {
|
||||
isRealtimeStatusRunning = false;
|
||||
realtimeToggleButton.setImageResource(R.drawable.realtime_stop_btn);
|
||||
svPreview.setOnTextureChangedListener(this);
|
||||
tvStatus.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
isRealtimeStatusRunning = true;
|
||||
realtimeToggleButton.setImageResource(R.drawable.realtime_start_btn);
|
||||
tvStatus.setVisibility(View.GONE);
|
||||
isShutterBitmapCopied = false;
|
||||
// Camera is still working but detecting loop is on pause.
|
||||
svPreview.setOnTextureChangedListener(new CameraSurfaceView.OnTextureChangedListener() {
|
||||
@Override
|
||||
public boolean onTextureChanged(Bitmap ARGB8888ImageBitmap) {
|
||||
if (TYPE == BTN_SHUTTER) {
|
||||
copyBitmapFromCamera(ARGB8888ImageBitmap);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTextureChanged(Bitmap ARGB8888ImageBitmap) {
|
||||
if (TYPE == BTN_SHUTTER) {
|
||||
copyBitmapFromCamera(ARGB8888ImageBitmap);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
// TODO: 2022/12/20
|
||||
// SegmentationResult result = new SegmentationResult();
|
||||
// result.setCxxBufferFlag(true);
|
||||
//
|
||||
//long tc = System.currentTimeMillis();
|
||||
// predictor.predict(ARGB8888ImageBitmap, result);
|
||||
//timeElapsed += (System.currentTimeMillis() - tc);
|
||||
//
|
||||
// Visualize.visSegmentation(ARGB8888ImageBitmap, result);
|
||||
// modified = result.initialized();
|
||||
//
|
||||
// result.releaseCxxBuffer();
|
||||
|
||||
// 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");
|
||||
// }
|
||||
// });
|
||||
// frameCounter = 0;
|
||||
// timeElapsed = 0;
|
||||
// }
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
// Reload settings and re-initialize the predictor
|
||||
checkAndUpdateSettings();
|
||||
// Open camera until the permissions have been granted
|
||||
if (!checkAllPermissions()) {
|
||||
svPreview.disableCamera();
|
||||
} else {
|
||||
svPreview.enableCamera();
|
||||
}
|
||||
svPreview.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
svPreview.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
// TODO: 2022/12/20
|
||||
// if (predictor != null) {
|
||||
// predictor.release();
|
||||
// }
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public void initView() {
|
||||
TYPE = REALTIME_DETECT;
|
||||
CameraSurfaceView.EXPECTED_PREVIEW_WIDTH = 480;
|
||||
CameraSurfaceView.EXPECTED_PREVIEW_HEIGHT = 480;
|
||||
svPreview = (CameraSurfaceView) findViewById(R.id.sv_preview);
|
||||
svPreview.setOnTextureChangedListener(this);
|
||||
svPreview.switchCamera();
|
||||
|
||||
tvStatus = (TextView) findViewById(R.id.tv_status);
|
||||
btnSwitch = (ImageButton) findViewById(R.id.btn_switch);
|
||||
btnSwitch.setOnClickListener(this);
|
||||
btnShutter = (ImageButton) findViewById(R.id.btn_shutter);
|
||||
btnShutter.setOnClickListener(this);
|
||||
btnSettings = (ImageButton) findViewById(R.id.btn_settings);
|
||||
btnSettings.setOnClickListener(this);
|
||||
realtimeToggleButton = findViewById(R.id.realtime_toggle_btn);
|
||||
realtimeToggleButton.setOnClickListener(this);
|
||||
backInPreview = findViewById(R.id.back_in_preview);
|
||||
backInPreview.setOnClickListener(this);
|
||||
albumSelectButton = findViewById(R.id.album_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);
|
||||
resultView = findViewById(R.id.result_list_view);
|
||||
}
|
||||
|
||||
private void detail(Bitmap bitmap) {
|
||||
// TODO: 2022/12/20
|
||||
//predictor.predict(bitmap, true, 0.7f);
|
||||
resultImage.setImageBitmap(bitmap);
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public void initSettings() {
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.clear();
|
||||
editor.commit();
|
||||
FaceAlignSettingsActivity.resetSettings();
|
||||
}
|
||||
|
||||
public void checkAndUpdateSettings() {
|
||||
if (FaceAlignSettingsActivity.checkAndUpdateSettings(this)) {
|
||||
String realModelDir = getCacheDir() + "/" + FaceAlignSettingsActivity.modelDir;
|
||||
Utils.copyDirectoryFromAssets(this, FaceAlignSettingsActivity.modelDir, realModelDir);
|
||||
|
||||
String modelFile = realModelDir + "/" + "model.pdmodel";
|
||||
String paramsFile = realModelDir + "/" + "model.pdiparams";
|
||||
String configFile = realModelDir + "/" + "deploy.yaml";
|
||||
RuntimeOption option = new RuntimeOption();
|
||||
option.setCpuThreadNum(FaceAlignSettingsActivity.cpuThreadNum);
|
||||
option.setLitePowerMode(FaceAlignSettingsActivity.cpuPowerMode);
|
||||
if (Boolean.parseBoolean(FaceAlignSettingsActivity.enableLiteFp16)) {
|
||||
option.enableLiteFp16();
|
||||
}
|
||||
// TODO: 2022/12/20
|
||||
//predictor.setIsVerticalScreen(true);
|
||||
//predictor.init(modelFile, paramsFile, configFile, option);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (grantResults[0] != PackageManager.PERMISSION_GRANTED || grantResults[1] != PackageManager.PERMISSION_GRANTED) {
|
||||
new AlertDialog.Builder(FaceAlignMainActivity.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.")
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("Exit", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
FaceAlignMainActivity.this.finish();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void requestAllPermissions() {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.CAMERA}, 0);
|
||||
}
|
||||
|
||||
private boolean checkAllPermissions() {
|
||||
return ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
|
||||
&& ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,164 @@
|
||||
package com.baidu.paddle.fastdeploy.app.examples.facealign;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.ActionBar;
|
||||
|
||||
import com.baidu.paddle.fastdeploy.app.examples.R;
|
||||
import com.baidu.paddle.fastdeploy.ui.Utils;
|
||||
import com.baidu.paddle.fastdeploy.ui.view.AppCompatPreferenceActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FaceAlignSettingsActivity extends AppCompatPreferenceActivity implements
|
||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private static final String TAG = FaceAlignSettingsActivity.class.getSimpleName();
|
||||
|
||||
static public int selectedModelIdx = -1;
|
||||
static public String modelDir = "";
|
||||
static public int cpuThreadNum = 2;
|
||||
static public String cpuPowerMode = "";
|
||||
static public String enableLiteFp16 = "true";
|
||||
|
||||
ListPreference lpChoosePreInstalledModel = null;
|
||||
EditTextPreference etModelDir = null;
|
||||
ListPreference lpCPUThreadNum = null;
|
||||
ListPreference lpCPUPowerMode = null;
|
||||
ListPreference lpEnableLiteFp16 = null;
|
||||
|
||||
List<String> preInstalledModelDirs = null;
|
||||
List<String> preInstalledCPUThreadNums = null;
|
||||
List<String> preInstalledCPUPowerModes = null;
|
||||
List<String> preInstalledEnableLiteFp16s = null;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.face_align_settings);
|
||||
ActionBar supportActionBar = getSupportActionBar();
|
||||
if (supportActionBar != null) {
|
||||
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
// Initialize pre-installed models
|
||||
preInstalledModelDirs = new ArrayList<String>();
|
||||
preInstalledCPUThreadNums = new ArrayList<String>();
|
||||
preInstalledCPUPowerModes = new ArrayList<String>();
|
||||
preInstalledEnableLiteFp16s = new ArrayList<String>();
|
||||
preInstalledModelDirs.add(getString(R.string.FACE_ALIGN_MODEL_DIR_DEFAULT));
|
||||
preInstalledCPUThreadNums.add(getString(R.string.CPU_THREAD_NUM_DEFAULT));
|
||||
preInstalledCPUPowerModes.add(getString(R.string.CPU_POWER_MODE_DEFAULT));
|
||||
preInstalledEnableLiteFp16s.add(getString(R.string.ENABLE_LITE_FP16_MODE_DEFAULT));
|
||||
|
||||
// Setup UI components
|
||||
lpChoosePreInstalledModel =
|
||||
(ListPreference) findPreference(getString(R.string.CHOOSE_PRE_INSTALLED_MODEL_KEY));
|
||||
String[] preInstalledModelNames = new String[preInstalledModelDirs.size()];
|
||||
for (int i = 0; i < preInstalledModelDirs.size(); i++) {
|
||||
preInstalledModelNames[i] = preInstalledModelDirs.get(i).substring(preInstalledModelDirs.get(i).lastIndexOf("/") + 1);
|
||||
}
|
||||
lpChoosePreInstalledModel.setEntries(preInstalledModelNames);
|
||||
lpChoosePreInstalledModel.setEntryValues(preInstalledModelDirs.toArray(new String[preInstalledModelDirs.size()]));
|
||||
lpCPUThreadNum = (ListPreference) findPreference(getString(R.string.CPU_THREAD_NUM_KEY));
|
||||
lpCPUPowerMode = (ListPreference) findPreference(getString(R.string.CPU_POWER_MODE_KEY));
|
||||
etModelDir = (EditTextPreference) findPreference(getString(R.string.MODEL_DIR_KEY));
|
||||
etModelDir.setTitle("Model dir (SDCard: " + Utils.getSDCardDirectory() + ")");
|
||||
lpEnableLiteFp16 = (ListPreference) findPreference(getString(R.string.ENABLE_LITE_FP16_MODE_KEY));
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
private void reloadSettingsAndUpdateUI() {
|
||||
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
|
||||
|
||||
String selected_model_dir = sharedPreferences.getString(getString(R.string.CHOOSE_PRE_INSTALLED_MODEL_KEY),
|
||||
getString(R.string.FACE_ALIGN_MODEL_DIR_DEFAULT));
|
||||
int selected_model_idx = lpChoosePreInstalledModel.findIndexOfValue(selected_model_dir);
|
||||
if (selected_model_idx >= 0 && selected_model_idx < preInstalledModelDirs.size() && selected_model_idx != selectedModelIdx) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(getString(R.string.MODEL_DIR_KEY), preInstalledModelDirs.get(selected_model_idx));
|
||||
editor.putString(getString(R.string.CPU_THREAD_NUM_KEY), preInstalledCPUThreadNums.get(selected_model_idx));
|
||||
editor.putString(getString(R.string.CPU_POWER_MODE_KEY), preInstalledCPUPowerModes.get(selected_model_idx));
|
||||
editor.putString(getString(R.string.ENABLE_LITE_FP16_MODE_DEFAULT), preInstalledEnableLiteFp16s.get(selected_model_idx));
|
||||
editor.commit();
|
||||
lpChoosePreInstalledModel.setSummary(selected_model_dir);
|
||||
selectedModelIdx = selected_model_idx;
|
||||
}
|
||||
|
||||
String model_dir = sharedPreferences.getString(getString(R.string.MODEL_DIR_KEY),
|
||||
getString(R.string.FACE_ALIGN_MODEL_DIR_DEFAULT));
|
||||
String cpu_thread_num = sharedPreferences.getString(getString(R.string.CPU_THREAD_NUM_KEY),
|
||||
getString(R.string.CPU_THREAD_NUM_DEFAULT));
|
||||
String cpu_power_mode = sharedPreferences.getString(getString(R.string.CPU_POWER_MODE_KEY),
|
||||
getString(R.string.CPU_POWER_MODE_DEFAULT));
|
||||
String enable_lite_fp16 = sharedPreferences.getString(getString(R.string.ENABLE_LITE_FP16_MODE_KEY),
|
||||
getString(R.string.ENABLE_LITE_FP16_MODE_DEFAULT));
|
||||
|
||||
etModelDir.setSummary(model_dir);
|
||||
lpCPUThreadNum.setValue(cpu_thread_num);
|
||||
lpCPUThreadNum.setSummary(cpu_thread_num);
|
||||
lpCPUPowerMode.setValue(cpu_power_mode);
|
||||
lpCPUPowerMode.setSummary(cpu_power_mode);
|
||||
lpEnableLiteFp16.setValue(enable_lite_fp16);
|
||||
lpEnableLiteFp16.setSummary(enable_lite_fp16);
|
||||
|
||||
}
|
||||
|
||||
static boolean checkAndUpdateSettings(Context ctx) {
|
||||
boolean settingsChanged = false;
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||
|
||||
String model_dir = sharedPreferences.getString(ctx.getString(R.string.MODEL_DIR_KEY),
|
||||
ctx.getString(R.string.FACE_ALIGN_MODEL_DIR_DEFAULT));
|
||||
settingsChanged |= !modelDir.equalsIgnoreCase(model_dir);
|
||||
modelDir = model_dir;
|
||||
|
||||
String cpu_thread_num = sharedPreferences.getString(ctx.getString(R.string.CPU_THREAD_NUM_KEY),
|
||||
ctx.getString(R.string.CPU_THREAD_NUM_DEFAULT));
|
||||
settingsChanged |= cpuThreadNum != Integer.parseInt(cpu_thread_num);
|
||||
cpuThreadNum = Integer.parseInt(cpu_thread_num);
|
||||
|
||||
String cpu_power_mode = sharedPreferences.getString(ctx.getString(R.string.CPU_POWER_MODE_KEY),
|
||||
ctx.getString(R.string.CPU_POWER_MODE_DEFAULT));
|
||||
settingsChanged |= !cpuPowerMode.equalsIgnoreCase(cpu_power_mode);
|
||||
cpuPowerMode = cpu_power_mode;
|
||||
|
||||
String enable_lite_fp16 = sharedPreferences.getString(ctx.getString(R.string.ENABLE_LITE_FP16_MODE_KEY),
|
||||
ctx.getString(R.string.ENABLE_LITE_FP16_MODE_DEFAULT));
|
||||
settingsChanged |= !enableLiteFp16.equalsIgnoreCase(enable_lite_fp16);
|
||||
enableLiteFp16 = enable_lite_fp16;
|
||||
|
||||
return settingsChanged;
|
||||
}
|
||||
|
||||
static void resetSettings() {
|
||||
selectedModelIdx = -1;
|
||||
modelDir = "";
|
||||
cpuThreadNum = 2;
|
||||
cpuPowerMode = "";
|
||||
enableLiteFp16 = "true";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||
reloadSettingsAndUpdateUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
reloadSettingsAndUpdateUI();
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
package com.baidu.paddle.fastdeploy.app.examples.facealign;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
|
||||
import com.baidu.paddle.fastdeploy.app.examples.R;
|
||||
import com.baidu.paddle.fastdeploy.app.examples.segmentation.SegmentationMainActivity;
|
||||
|
||||
public class FaceAlignWelcomeActivity extends Activity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
);
|
||||
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||
}
|
||||
setContentView(R.layout.face_align_welcome);
|
||||
}
|
||||
|
||||
public void startActivity(View view) {
|
||||
Intent intent = new Intent(FaceAlignWelcomeActivity.this, FaceAlignMainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
@@ -0,0 +1,400 @@
|
||||
package com.baidu.paddle.fastdeploy.app.examples.matting;
|
||||
|
||||
import static com.baidu.paddle.fastdeploy.ui.Utils.decodeBitmap;
|
||||
import static com.baidu.paddle.fastdeploy.ui.Utils.getRealPathFromURI;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
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.TextView;
|
||||
|
||||
import com.baidu.paddle.fastdeploy.RuntimeOption;
|
||||
import com.baidu.paddle.fastdeploy.app.examples.R;
|
||||
import com.baidu.paddle.fastdeploy.ui.Utils;
|
||||
import com.baidu.paddle.fastdeploy.ui.view.CameraSurfaceView;
|
||||
import com.baidu.paddle.fastdeploy.ui.view.ResultListView;
|
||||
import com.baidu.paddle.fastdeploy.ui.view.model.BaseResultModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MattingMainActivity extends Activity implements View.OnClickListener, CameraSurfaceView.OnTextureChangedListener {
|
||||
private static final String TAG = MattingMainActivity.class.getSimpleName();
|
||||
|
||||
|
||||
CameraSurfaceView svPreview;
|
||||
TextView tvStatus;
|
||||
ImageButton btnSwitch;
|
||||
ImageButton btnShutter;
|
||||
ImageButton btnSettings;
|
||||
ImageView realtimeToggleButton;
|
||||
boolean isRealtimeStatusRunning = false;
|
||||
ImageView backInPreview;
|
||||
private ImageView albumSelectButton;
|
||||
private View cameraPageView;
|
||||
private ViewGroup resultPageView;
|
||||
private ImageView resultImage;
|
||||
private ImageView backInResult;
|
||||
private ResultListView resultView;
|
||||
private Bitmap shutterBitmap;
|
||||
private Bitmap picBitmap;
|
||||
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;
|
||||
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;
|
||||
|
||||
// todo Call 'init' and 'release' manually later
|
||||
//PaddleSegModel predictor = new PaddleSegModel();
|
||||
private List<BaseResultModel> results = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Fullscreen
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
|
||||
setContentView(R.layout.matting_activity_main);
|
||||
|
||||
// Clear all setting items to avoid app crashing due to the incorrect settings
|
||||
initSettings();
|
||||
|
||||
// Check and request CAMERA and WRITE_EXTERNAL_STORAGE permissions
|
||||
if (!checkAllPermissions()) {
|
||||
requestAllPermissions();
|
||||
}
|
||||
|
||||
// Init the camera preview and UI components
|
||||
initView();
|
||||
}
|
||||
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.btn_switch:
|
||||
svPreview.switchCamera();
|
||||
break;
|
||||
case R.id.btn_shutter:
|
||||
TYPE = BTN_SHUTTER;
|
||||
shutterAndPauseCamera();
|
||||
resultView.setAdapter(null);
|
||||
break;
|
||||
case R.id.btn_settings:
|
||||
startActivity(new Intent(MattingMainActivity.this, MattingSettingsActivity.class));
|
||||
break;
|
||||
case R.id.realtime_toggle_btn:
|
||||
toggleRealtimeStyle();
|
||||
break;
|
||||
case R.id.back_in_preview:
|
||||
finish();
|
||||
break;
|
||||
case R.id.album_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();
|
||||
}
|
||||
|
||||
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 codes will run in main thread.
|
||||
svPreview.onPause();
|
||||
cameraPageView.setVisibility(View.GONE);
|
||||
resultPageView.setVisibility(View.VISIBLE);
|
||||
if (shutterBitmap != null && !shutterBitmap.isRecycled()) {
|
||||
detail(shutterBitmap);
|
||||
} else {
|
||||
new AlertDialog.Builder(MattingMainActivity.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);
|
||||
Uri uri = data.getData();
|
||||
String path = getRealPathFromURI(this, uri);
|
||||
Bitmap bitmap = decodeBitmap(path, 720, 1280);
|
||||
picBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||
SystemClock.sleep(TIME_SLEEP_INTERVAL * 10); // 500ms
|
||||
detail(picBitmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleRealtimeStyle() {
|
||||
if (isRealtimeStatusRunning) {
|
||||
isRealtimeStatusRunning = false;
|
||||
realtimeToggleButton.setImageResource(R.drawable.realtime_stop_btn);
|
||||
svPreview.setOnTextureChangedListener(this);
|
||||
tvStatus.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
isRealtimeStatusRunning = true;
|
||||
realtimeToggleButton.setImageResource(R.drawable.realtime_start_btn);
|
||||
tvStatus.setVisibility(View.GONE);
|
||||
isShutterBitmapCopied = false;
|
||||
// Camera is still working but detecting loop is on pause.
|
||||
svPreview.setOnTextureChangedListener(new CameraSurfaceView.OnTextureChangedListener() {
|
||||
@Override
|
||||
public boolean onTextureChanged(Bitmap ARGB8888ImageBitmap) {
|
||||
if (TYPE == BTN_SHUTTER) {
|
||||
copyBitmapFromCamera(ARGB8888ImageBitmap);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTextureChanged(Bitmap ARGB8888ImageBitmap) {
|
||||
if (TYPE == BTN_SHUTTER) {
|
||||
copyBitmapFromCamera(ARGB8888ImageBitmap);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean modified = false;
|
||||
// TODO: 2022/12/20
|
||||
// SegmentationResult result = new SegmentationResult();
|
||||
// result.setCxxBufferFlag(true);
|
||||
//
|
||||
//long tc = System.currentTimeMillis();
|
||||
// predictor.predict(ARGB8888ImageBitmap, result);
|
||||
//timeElapsed += (System.currentTimeMillis() - tc);
|
||||
//
|
||||
// Visualize.visSegmentation(ARGB8888ImageBitmap, result);
|
||||
// modified = result.initialized();
|
||||
//
|
||||
// result.releaseCxxBuffer();
|
||||
|
||||
// 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");
|
||||
// }
|
||||
// });
|
||||
// frameCounter = 0;
|
||||
// timeElapsed = 0;
|
||||
// }
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
// Reload settings and re-initialize the predictor
|
||||
checkAndUpdateSettings();
|
||||
// Open camera until the permissions have been granted
|
||||
if (!checkAllPermissions()) {
|
||||
svPreview.disableCamera();
|
||||
} else {
|
||||
svPreview.enableCamera();
|
||||
}
|
||||
svPreview.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
svPreview.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
// TODO: 2022/12/20
|
||||
// if (predictor != null) {
|
||||
// predictor.release();
|
||||
// }
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public void initView() {
|
||||
TYPE = REALTIME_DETECT;
|
||||
CameraSurfaceView.EXPECTED_PREVIEW_WIDTH = 480;
|
||||
CameraSurfaceView.EXPECTED_PREVIEW_HEIGHT = 480;
|
||||
svPreview = (CameraSurfaceView) findViewById(R.id.sv_preview);
|
||||
svPreview.setOnTextureChangedListener(this);
|
||||
svPreview.switchCamera();
|
||||
|
||||
tvStatus = (TextView) findViewById(R.id.tv_status);
|
||||
btnSwitch = (ImageButton) findViewById(R.id.btn_switch);
|
||||
btnSwitch.setOnClickListener(this);
|
||||
btnShutter = (ImageButton) findViewById(R.id.btn_shutter);
|
||||
btnShutter.setOnClickListener(this);
|
||||
btnSettings = (ImageButton) findViewById(R.id.btn_settings);
|
||||
btnSettings.setOnClickListener(this);
|
||||
realtimeToggleButton = findViewById(R.id.realtime_toggle_btn);
|
||||
realtimeToggleButton.setOnClickListener(this);
|
||||
backInPreview = findViewById(R.id.back_in_preview);
|
||||
backInPreview.setOnClickListener(this);
|
||||
albumSelectButton = findViewById(R.id.album_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);
|
||||
resultView = findViewById(R.id.result_list_view);
|
||||
}
|
||||
|
||||
private void detail(Bitmap bitmap) {
|
||||
// TODO: 2022/12/20
|
||||
//predictor.predict(bitmap, true, 0.7f);
|
||||
resultImage.setImageBitmap(bitmap);
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public void initSettings() {
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.clear();
|
||||
editor.commit();
|
||||
MattingSettingsActivity.resetSettings();
|
||||
}
|
||||
|
||||
public void checkAndUpdateSettings() {
|
||||
if (MattingSettingsActivity.checkAndUpdateSettings(this)) {
|
||||
String realModelDir = getCacheDir() + "/" + MattingSettingsActivity.modelDir;
|
||||
Utils.copyDirectoryFromAssets(this, MattingSettingsActivity.modelDir, realModelDir);
|
||||
|
||||
String modelFile = realModelDir + "/" + "model.pdmodel";
|
||||
String paramsFile = realModelDir + "/" + "model.pdiparams";
|
||||
String configFile = realModelDir + "/" + "deploy.yaml";
|
||||
RuntimeOption option = new RuntimeOption();
|
||||
option.setCpuThreadNum(MattingSettingsActivity.cpuThreadNum);
|
||||
option.setLitePowerMode(MattingSettingsActivity.cpuPowerMode);
|
||||
if (Boolean.parseBoolean(MattingSettingsActivity.enableLiteFp16)) {
|
||||
option.enableLiteFp16();
|
||||
}
|
||||
// TODO: 2022/12/20
|
||||
//predictor.setIsVerticalScreen(true);
|
||||
//predictor.init(modelFile, paramsFile, configFile, option);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (grantResults[0] != PackageManager.PERMISSION_GRANTED || grantResults[1] != PackageManager.PERMISSION_GRANTED) {
|
||||
new AlertDialog.Builder(MattingMainActivity.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.")
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("Exit", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
MattingMainActivity.this.finish();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void requestAllPermissions() {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.CAMERA}, 0);
|
||||
}
|
||||
|
||||
private boolean checkAllPermissions() {
|
||||
return ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
|
||||
&& ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,164 @@
|
||||
package com.baidu.paddle.fastdeploy.app.examples.matting;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.ActionBar;
|
||||
|
||||
import com.baidu.paddle.fastdeploy.app.examples.R;
|
||||
import com.baidu.paddle.fastdeploy.ui.Utils;
|
||||
import com.baidu.paddle.fastdeploy.ui.view.AppCompatPreferenceActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MattingSettingsActivity extends AppCompatPreferenceActivity implements
|
||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private static final String TAG = MattingSettingsActivity.class.getSimpleName();
|
||||
|
||||
static public int selectedModelIdx = -1;
|
||||
static public String modelDir = "";
|
||||
static public int cpuThreadNum = 2;
|
||||
static public String cpuPowerMode = "";
|
||||
static public String enableLiteFp16 = "true";
|
||||
|
||||
ListPreference lpChoosePreInstalledModel = null;
|
||||
EditTextPreference etModelDir = null;
|
||||
ListPreference lpCPUThreadNum = null;
|
||||
ListPreference lpCPUPowerMode = null;
|
||||
ListPreference lpEnableLiteFp16 = null;
|
||||
|
||||
List<String> preInstalledModelDirs = null;
|
||||
List<String> preInstalledCPUThreadNums = null;
|
||||
List<String> preInstalledCPUPowerModes = null;
|
||||
List<String> preInstalledEnableLiteFp16s = null;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.matting_settings);
|
||||
ActionBar supportActionBar = getSupportActionBar();
|
||||
if (supportActionBar != null) {
|
||||
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
// Initialize pre-installed models
|
||||
preInstalledModelDirs = new ArrayList<String>();
|
||||
preInstalledCPUThreadNums = new ArrayList<String>();
|
||||
preInstalledCPUPowerModes = new ArrayList<String>();
|
||||
preInstalledEnableLiteFp16s = new ArrayList<String>();
|
||||
preInstalledModelDirs.add(getString(R.string.MATTING_MODEL_DIR_DEFAULT));
|
||||
preInstalledCPUThreadNums.add(getString(R.string.CPU_THREAD_NUM_DEFAULT));
|
||||
preInstalledCPUPowerModes.add(getString(R.string.CPU_POWER_MODE_DEFAULT));
|
||||
preInstalledEnableLiteFp16s.add(getString(R.string.ENABLE_LITE_FP16_MODE_DEFAULT));
|
||||
|
||||
// Setup UI components
|
||||
lpChoosePreInstalledModel =
|
||||
(ListPreference) findPreference(getString(R.string.CHOOSE_PRE_INSTALLED_MODEL_KEY));
|
||||
String[] preInstalledModelNames = new String[preInstalledModelDirs.size()];
|
||||
for (int i = 0; i < preInstalledModelDirs.size(); i++) {
|
||||
preInstalledModelNames[i] = preInstalledModelDirs.get(i).substring(preInstalledModelDirs.get(i).lastIndexOf("/") + 1);
|
||||
}
|
||||
lpChoosePreInstalledModel.setEntries(preInstalledModelNames);
|
||||
lpChoosePreInstalledModel.setEntryValues(preInstalledModelDirs.toArray(new String[preInstalledModelDirs.size()]));
|
||||
lpCPUThreadNum = (ListPreference) findPreference(getString(R.string.CPU_THREAD_NUM_KEY));
|
||||
lpCPUPowerMode = (ListPreference) findPreference(getString(R.string.CPU_POWER_MODE_KEY));
|
||||
etModelDir = (EditTextPreference) findPreference(getString(R.string.MODEL_DIR_KEY));
|
||||
etModelDir.setTitle("Model dir (SDCard: " + Utils.getSDCardDirectory() + ")");
|
||||
lpEnableLiteFp16 = (ListPreference) findPreference(getString(R.string.ENABLE_LITE_FP16_MODE_KEY));
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
private void reloadSettingsAndUpdateUI() {
|
||||
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
|
||||
|
||||
String selected_model_dir = sharedPreferences.getString(getString(R.string.CHOOSE_PRE_INSTALLED_MODEL_KEY),
|
||||
getString(R.string.MATTING_MODEL_DIR_DEFAULT));
|
||||
int selected_model_idx = lpChoosePreInstalledModel.findIndexOfValue(selected_model_dir);
|
||||
if (selected_model_idx >= 0 && selected_model_idx < preInstalledModelDirs.size() && selected_model_idx != selectedModelIdx) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(getString(R.string.MODEL_DIR_KEY), preInstalledModelDirs.get(selected_model_idx));
|
||||
editor.putString(getString(R.string.CPU_THREAD_NUM_KEY), preInstalledCPUThreadNums.get(selected_model_idx));
|
||||
editor.putString(getString(R.string.CPU_POWER_MODE_KEY), preInstalledCPUPowerModes.get(selected_model_idx));
|
||||
editor.putString(getString(R.string.ENABLE_LITE_FP16_MODE_DEFAULT), preInstalledEnableLiteFp16s.get(selected_model_idx));
|
||||
editor.commit();
|
||||
lpChoosePreInstalledModel.setSummary(selected_model_dir);
|
||||
selectedModelIdx = selected_model_idx;
|
||||
}
|
||||
|
||||
String model_dir = sharedPreferences.getString(getString(R.string.MODEL_DIR_KEY),
|
||||
getString(R.string.MATTING_MODEL_DIR_DEFAULT));
|
||||
String cpu_thread_num = sharedPreferences.getString(getString(R.string.CPU_THREAD_NUM_KEY),
|
||||
getString(R.string.CPU_THREAD_NUM_DEFAULT));
|
||||
String cpu_power_mode = sharedPreferences.getString(getString(R.string.CPU_POWER_MODE_KEY),
|
||||
getString(R.string.CPU_POWER_MODE_DEFAULT));
|
||||
String enable_lite_fp16 = sharedPreferences.getString(getString(R.string.ENABLE_LITE_FP16_MODE_KEY),
|
||||
getString(R.string.ENABLE_LITE_FP16_MODE_DEFAULT));
|
||||
|
||||
etModelDir.setSummary(model_dir);
|
||||
lpCPUThreadNum.setValue(cpu_thread_num);
|
||||
lpCPUThreadNum.setSummary(cpu_thread_num);
|
||||
lpCPUPowerMode.setValue(cpu_power_mode);
|
||||
lpCPUPowerMode.setSummary(cpu_power_mode);
|
||||
lpEnableLiteFp16.setValue(enable_lite_fp16);
|
||||
lpEnableLiteFp16.setSummary(enable_lite_fp16);
|
||||
|
||||
}
|
||||
|
||||
static boolean checkAndUpdateSettings(Context ctx) {
|
||||
boolean settingsChanged = false;
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||
|
||||
String model_dir = sharedPreferences.getString(ctx.getString(R.string.MODEL_DIR_KEY),
|
||||
ctx.getString(R.string.MATTING_MODEL_DIR_DEFAULT));
|
||||
settingsChanged |= !modelDir.equalsIgnoreCase(model_dir);
|
||||
modelDir = model_dir;
|
||||
|
||||
String cpu_thread_num = sharedPreferences.getString(ctx.getString(R.string.CPU_THREAD_NUM_KEY),
|
||||
ctx.getString(R.string.CPU_THREAD_NUM_DEFAULT));
|
||||
settingsChanged |= cpuThreadNum != Integer.parseInt(cpu_thread_num);
|
||||
cpuThreadNum = Integer.parseInt(cpu_thread_num);
|
||||
|
||||
String cpu_power_mode = sharedPreferences.getString(ctx.getString(R.string.CPU_POWER_MODE_KEY),
|
||||
ctx.getString(R.string.CPU_POWER_MODE_DEFAULT));
|
||||
settingsChanged |= !cpuPowerMode.equalsIgnoreCase(cpu_power_mode);
|
||||
cpuPowerMode = cpu_power_mode;
|
||||
|
||||
String enable_lite_fp16 = sharedPreferences.getString(ctx.getString(R.string.ENABLE_LITE_FP16_MODE_KEY),
|
||||
ctx.getString(R.string.ENABLE_LITE_FP16_MODE_DEFAULT));
|
||||
settingsChanged |= !enableLiteFp16.equalsIgnoreCase(enable_lite_fp16);
|
||||
enableLiteFp16 = enable_lite_fp16;
|
||||
|
||||
return settingsChanged;
|
||||
}
|
||||
|
||||
static void resetSettings() {
|
||||
selectedModelIdx = -1;
|
||||
modelDir = "";
|
||||
cpuThreadNum = 2;
|
||||
cpuPowerMode = "";
|
||||
enableLiteFp16 = "true";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||
reloadSettingsAndUpdateUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
reloadSettingsAndUpdateUI();
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package com.baidu.paddle.fastdeploy.app.examples.matting;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
|
||||
import com.baidu.paddle.fastdeploy.app.examples.R;
|
||||
|
||||
public class MattingWelcomeActivity extends Activity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
);
|
||||
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||
}
|
||||
setContentView(R.layout.matting_welcome);
|
||||
}
|
||||
|
||||
public void startActivity(View view) {
|
||||
Intent intent = new Intent(MattingWelcomeActivity.this, MattingMainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
@@ -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/face_align_camera_page"
|
||||
android:id="@+id/camera_page"></include>
|
||||
|
||||
<include
|
||||
layout="@layout/face_align_result_page"
|
||||
android:id="@+id/result_page"
|
||||
android:visibility="gone"></include>
|
||||
</FrameLayout>
|
159
java/android/app/src/main/res/layout/face_align_camera_page.xml
Normal file
159
java/android/app/src/main/res/layout/face_align_camera_page.xml
Normal file
@@ -0,0 +1,159 @@
|
||||
<?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=".segmentation.SegmentationMainActivity">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/colorWindow">
|
||||
|
||||
<com.baidu.paddle.fastdeploy.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="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/action_bar_realtime"
|
||||
android:textAlignment="center" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.baidu.paddle.fastdeploy.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/album_select"
|
||||
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>
|
160
java/android/app/src/main/res/layout/face_align_result_page.xml
Normal file
160
java/android/app/src/main/res/layout/face_align_result_page.xml
Normal 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.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.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="gone">
|
||||
|
||||
<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.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.ui.view.ResultListView>
|
||||
</ScrollView>
|
||||
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
79
java/android/app/src/main/res/layout/face_align_welcome.xml
Normal file
79
java/android/app/src/main/res/layout/face_align_welcome.xml
Normal file
@@ -0,0 +1,79 @@
|
||||
<?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">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:background="@drawable/main_bk"
|
||||
/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/model_text"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="120dp"
|
||||
android:background="@color/colorStartBtn"
|
||||
android:gravity="center"
|
||||
android:text="FaceAlign"
|
||||
android:textColor="@color/colorTextWrite"
|
||||
android:textSize="30sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/baidu"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/model_text"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="百度FastDeploy"
|
||||
android:textColor="@color/colorTextWrite"
|
||||
android:textSize="22sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/baidu"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="Powered by EasyEdge"
|
||||
android:textColor="@color/colorTextWrite"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<Button
|
||||
|
||||
android:id="@+id/start_ui_activity"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="70dp"
|
||||
android:background="@drawable/round_corner_btn"
|
||||
android:text="@string/start_ui_activity"
|
||||
android:textColor="@color/colorTextWrite"
|
||||
android:textSize="22sp"
|
||||
android:onClick="startActivity"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/logo"
|
||||
android:layout_width="95dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="@drawable/paddle_logo"
|
||||
android:scaleType="centerCrop" />
|
||||
</RelativeLayout>
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
|
@@ -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/matting_camera_page"
|
||||
android:id="@+id/camera_page"></include>
|
||||
|
||||
<include
|
||||
layout="@layout/matting_result_page"
|
||||
android:id="@+id/result_page"
|
||||
android:visibility="gone"></include>
|
||||
</FrameLayout>
|
159
java/android/app/src/main/res/layout/matting_camera_page.xml
Normal file
159
java/android/app/src/main/res/layout/matting_camera_page.xml
Normal file
@@ -0,0 +1,159 @@
|
||||
<?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=".segmentation.SegmentationMainActivity">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/colorWindow">
|
||||
|
||||
<com.baidu.paddle.fastdeploy.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="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/action_bar_realtime"
|
||||
android:textAlignment="center" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.baidu.paddle.fastdeploy.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/album_select"
|
||||
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>
|
160
java/android/app/src/main/res/layout/matting_result_page.xml
Normal file
160
java/android/app/src/main/res/layout/matting_result_page.xml
Normal 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.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.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="gone">
|
||||
|
||||
<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.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.ui.view.ResultListView>
|
||||
</ScrollView>
|
||||
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
76
java/android/app/src/main/res/layout/matting_welcome.xml
Normal file
76
java/android/app/src/main/res/layout/matting_welcome.xml
Normal file
@@ -0,0 +1,76 @@
|
||||
<?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">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:background="@drawable/main_bk"
|
||||
/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/model_text"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="120dp"
|
||||
android:background="@color/colorStartBtn"
|
||||
android:gravity="center"
|
||||
android:text="Matting"
|
||||
android:textColor="@color/colorTextWrite"
|
||||
android:textSize="30sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/baidu"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/model_text"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="百度FastDeploy"
|
||||
android:textColor="@color/colorTextWrite"
|
||||
android:textSize="22sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/baidu"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="Powered by EasyEdge"
|
||||
android:textColor="@color/colorTextWrite"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<Button
|
||||
|
||||
android:id="@+id/start_ui_activity"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="70dp"
|
||||
android:background="@drawable/round_corner_btn"
|
||||
android:text="@string/start_ui_activity"
|
||||
android:textColor="@color/colorTextWrite"
|
||||
android:textSize="22sp"
|
||||
android:onClick="startActivity"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/logo"
|
||||
android:layout_width="95dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="@drawable/paddle_logo"
|
||||
android:scaleType="centerCrop" />
|
||||
</RelativeLayout>
|
||||
</FrameLayout>
|
@@ -41,11 +41,15 @@
|
||||
<string name="FACEDET_MODEL_DIR_DEFAULT">models/scrfd_500m_bnkps_shape320x320_pd</string>
|
||||
<!-- segmentation values ... -->
|
||||
<string name="SEGMENTATION_MODEL_DIR_DEFAULT">models/portrait_pp_humansegv2_lite_256x144_inference_model</string>
|
||||
<!-- face align values ... -->
|
||||
<string name="FACE_ALIGN_MODEL_DIR_DEFAULT">models</string>
|
||||
<!-- keypointdetection values -->
|
||||
<string name="KEYPOINT_DETECTION_MODEL_DIR_DEFAULT">models/PP_TinyPose_128x96_infer</string>
|
||||
<string name="VOICE_ASSISTANT_MODEL_DIR_DEFAULT">models</string>
|
||||
<string name="SUPER_RESOLUTION_MODEL_DIR_DEFAULT">models</string>
|
||||
<string name="UIE_MODEL_DIR_DEFAULT">models/uie-nano</string>
|
||||
<!-- matting values ... -->
|
||||
<string name="MATTING_MODEL_DIR_DEFAULT">models</string>
|
||||
<!-- Other resources values-->
|
||||
<string name="action_bar_take_photo">拍照识别</string>
|
||||
<string name="action_bar_realtime">实时识别</string>
|
||||
|
37
java/android/app/src/main/res/xml/face_align_settings.xml
Normal file
37
java/android/app/src/main/res/xml/face_align_settings.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ListPreference
|
||||
android:defaultValue="@string/FACE_ALIGN_MODEL_DIR_DEFAULT"
|
||||
android:key="@string/CHOOSE_PRE_INSTALLED_MODEL_KEY"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="Choose Pre-Installed Models" />
|
||||
<EditTextPreference
|
||||
android:defaultValue="@string/FACE_ALIGN_MODEL_DIR_DEFAULT"
|
||||
android:key="@string/MODEL_DIR_KEY"
|
||||
android:title="Model Dir" />
|
||||
<ListPreference
|
||||
android:defaultValue="@string/CPU_THREAD_NUM_DEFAULT"
|
||||
android:entries="@array/cpu_thread_num_entries"
|
||||
android:entryValues="@array/cpu_thread_num_values"
|
||||
android:key="@string/CPU_THREAD_NUM_KEY"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="CPU Thread Num" />
|
||||
<ListPreference
|
||||
android:defaultValue="@string/CPU_POWER_MODE_DEFAULT"
|
||||
android:entries="@array/cpu_power_mode_entries"
|
||||
android:entryValues="@array/cpu_power_mode_values"
|
||||
android:key="@string/CPU_POWER_MODE_KEY"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="CPU Power Mode" />
|
||||
<ListPreference
|
||||
android:defaultValue="@string/ENABLE_LITE_FP16_MODE_DEFAULT"
|
||||
android:entries="@array/enable_lite_fp16_mode_entries"
|
||||
android:entryValues="@array/enable_lite_fp16_mode_values"
|
||||
android:key="@string/ENABLE_LITE_FP16_MODE_KEY"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="Enable Lite FP16" />
|
||||
</PreferenceScreen>
|
37
java/android/app/src/main/res/xml/matting_settings.xml
Normal file
37
java/android/app/src/main/res/xml/matting_settings.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ListPreference
|
||||
android:defaultValue="@string/MATTING_MODEL_DIR_DEFAULT"
|
||||
android:key="@string/CHOOSE_PRE_INSTALLED_MODEL_KEY"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="Choose Pre-Installed Models" />
|
||||
<EditTextPreference
|
||||
android:defaultValue="@string/MATTING_MODEL_DIR_DEFAULT"
|
||||
android:key="@string/MODEL_DIR_KEY"
|
||||
android:title="Model Dir" />
|
||||
<ListPreference
|
||||
android:defaultValue="@string/CPU_THREAD_NUM_DEFAULT"
|
||||
android:entries="@array/cpu_thread_num_entries"
|
||||
android:entryValues="@array/cpu_thread_num_values"
|
||||
android:key="@string/CPU_THREAD_NUM_KEY"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="CPU Thread Num" />
|
||||
<ListPreference
|
||||
android:defaultValue="@string/CPU_POWER_MODE_DEFAULT"
|
||||
android:entries="@array/cpu_power_mode_entries"
|
||||
android:entryValues="@array/cpu_power_mode_values"
|
||||
android:key="@string/CPU_POWER_MODE_KEY"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="CPU Power Mode" />
|
||||
<ListPreference
|
||||
android:defaultValue="@string/ENABLE_LITE_FP16_MODE_DEFAULT"
|
||||
android:entries="@array/enable_lite_fp16_mode_entries"
|
||||
android:entryValues="@array/enable_lite_fp16_mode_values"
|
||||
android:key="@string/ENABLE_LITE_FP16_MODE_KEY"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="Enable Lite FP16" />
|
||||
</PreferenceScreen>
|
Reference in New Issue
Block a user