mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 00:57:33 +08:00
[Android] Add CxxBuffer to native and Java PaddleSegModel (#677)
[Android] Add CxxBuffer to native PaddleSegModel
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import java.security.MessageDigest
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
@@ -90,8 +88,6 @@ task downloadAndExtractModels(type: DefaultTask) {
|
||||
mkdir "${cachePath}"
|
||||
}
|
||||
FD_MODEL.eachWithIndex { model, index ->
|
||||
MessageDigest messageDigest = MessageDigest.getInstance('MD5')
|
||||
messageDigest.update(model.src.bytes)
|
||||
String[] modelPaths = model.src.split("/")
|
||||
String modelName = modelPaths[modelPaths.length - 1]
|
||||
// Download the target model if not exists
|
||||
|
@@ -19,6 +19,7 @@ import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
@@ -251,12 +252,18 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
boolean modified = false;
|
||||
|
||||
long tc = System.currentTimeMillis();
|
||||
SegmentationResult result = predictor.predict(ARGB8888ImageBitmap);
|
||||
|
||||
SegmentationResult result = new SegmentationResult();
|
||||
result.setCxxBufferFlag(true);
|
||||
|
||||
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));
|
||||
@@ -304,7 +311,8 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
// should mean 'width' if the camera display orientation is 90 | 270 degree
|
||||
// (Hold the phone upright to record video)
|
||||
// (2) Smaller resolution is more suitable for Lite Portrait HumanSeg.
|
||||
// So, we set this preview size (480,480) here.
|
||||
// So, we set this preview size (480,480) here. Reference:
|
||||
// https://github.com/PaddlePaddle/PaddleSeg/blob/release/2.6/contrib/PP-HumanSeg/README_cn.md
|
||||
CameraSurfaceView.EXPECTED_PREVIEW_WIDTH = 480;
|
||||
CameraSurfaceView.EXPECTED_PREVIEW_HEIGHT = 480;
|
||||
svPreview = (CameraSurfaceView) findViewById(R.id.sv_preview);
|
||||
@@ -360,6 +368,7 @@ public class SegmentationMainActivity extends Activity implements View.OnClickLi
|
||||
if (Boolean.parseBoolean(SegmentationSettingsActivity.enableLiteFp16)) {
|
||||
option.enableLiteFp16();
|
||||
}
|
||||
predictor.setVerticalScreenFlag(true);
|
||||
predictor.init(modelFile, paramsFile, configFile, option);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user