Skip to content

Commit 5534697

Browse files
Update: Repack APK for arm64 & FPSMeter
1 parent a7de73e commit 5534697

File tree

9 files changed

+146
-20
lines changed

9 files changed

+146
-20
lines changed

SLAM_AR_Android_Demo_Repack_20200823.apk renamed to SLAM_AR_Android_Demo_Repack_20210225/app-arm64-v8a-release.apk

44.3 MB
Binary file not shown.
39.6 MB
Binary file not shown.
47.3 MB
Binary file not shown.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"version": 2,
3+
"artifactType": {
4+
"type": "APK",
5+
"kind": "Directory"
6+
},
7+
"applicationId": "com.martin.ads.slamar2",
8+
"variantName": "processReleaseResources",
9+
"elements": [
10+
{
11+
"type": "UNIVERSAL",
12+
"filters": [],
13+
"versionCode": 1,
14+
"versionName": "1.0",
15+
"outputFile": "app-universal-release.apk"
16+
},
17+
{
18+
"type": "ONE_OF_MANY",
19+
"filters": [
20+
{
21+
"filterType": "ABI",
22+
"value": "armeabi-v7a"
23+
}
24+
],
25+
"versionCode": 1,
26+
"versionName": "1.0",
27+
"outputFile": "app-armeabi-v7a-release.apk"
28+
},
29+
{
30+
"type": "ONE_OF_MANY",
31+
"filters": [
32+
{
33+
"filterType": "ABI",
34+
"value": "arm64-v8a"
35+
}
36+
],
37+
"versionCode": 1,
38+
"versionName": "1.0",
39+
"outputFile": "app-arm64-v8a-release.apk"
40+
}
41+
]
42+
}

app/build.gradle

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ android {
1313
cmake {
1414
cppFlags "-std=c++11", "-frtti", "-fexceptions"
1515
cppFlags "-std=c++11 -frtti -fexceptions"
16-
arguments "-DANDROID_ABI=armeabi-v7a"
16+
// arguments "-DANDROID_ABI=armeabi-v7a"
17+
// arguments "-DANDROID_ABI=arm64-v8a"
1718
arguments "-DANDROID_ARM_NEON=TRUE"
1819
arguments "-DANDROID_TOOLCHAIN=clang"
1920
arguments "-DCMAKE_BUILD_TYPE=Release"
@@ -22,16 +23,13 @@ android {
2223
}
2324
}
2425
ndk {
25-
abiFilters 'armeabi-v7a'/*,'x86'*/
26+
abiFilters 'armeabi-v7a','arm64-v8a'/*,'x86'*/
2627
}
2728
}
2829

2930
packagingOptions {
30-
31-
// pickFirst 'lib/armeabi-v7a/libopencv_java.so'
32-
// pickFirst 'lib/armeabi-v7a/libopencv_java3.so'
3331
pickFirst 'lib/armeabi-v7a/libopencv_java4.so'
34-
32+
pickFirst 'lib/arm64-v8a/libopencv_java4.so'
3533
}
3634

3735
buildTypes {
@@ -50,20 +48,21 @@ android {
5048
}
5149
}
5250

53-
// splits {
54-
// abi {
55-
// // Enables building multiple APKs per ABI.
56-
// enable true
57-
// // By default all ABIs are included, so use reset() and include to specify that we only
58-
// // want APKs for x86, armeabi-v7a, and mips.
59-
// // Resets the list of ABIs that Gradle should create APKs for to none.
60-
// reset()
61-
// // Specifies a list of ABIs that Gradle should create APKs for.
62-
// include "x86", "armeabi-v7a"
63-
// // Specifies that we do want to also generate a universal APK that includes all ABIs.
64-
// universalApk false
65-
// }
66-
// }
51+
splits {
52+
// Configures multiple APKs based on ABI.
53+
abi {
54+
// Enables building multiple APKs per ABI.
55+
enable true
56+
// By default all ABIs are included, so use reset() and include to specify that we only
57+
// want APKs for x86 and x86_64.
58+
// Resets the list of ABIs that Gradle should create APKs for to none.
59+
reset()
60+
// Specifies a list of ABIs that Gradle should create APKs for.
61+
include 'armeabi-v7a','arm64-v8a'
62+
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
63+
universalApk true
64+
}
65+
}
6766
}
6867

6968
dependencies {

app/src/main/java/com/martin/ads/ui/ArCamUIActivity.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import android.view.MotionEvent;
1515
import android.view.View;
1616
import android.view.WindowManager;
17+
import android.widget.TextView;
1718
import android.widget.Toast;
1819

1920
import com.martin.ads.constant.GlobalConstant;
@@ -23,6 +24,7 @@
2324
import com.martin.ads.slamar.R;
2425
import com.martin.ads.rendering.render.GLES10Demo;
2526
import com.martin.ads.rendering.gles.GLRootView;
27+
import com.martin.ads.utils.FpsMeter;
2628
import com.martin.ads.utils.TouchHelper;
2729

2830
import org.opencv.core.CvType;
@@ -95,6 +97,9 @@ public void onBackPressed() {
9597

9698
private boolean detectPlane;
9799

100+
private FpsMeter mFpsMeter = null;
101+
private TextView fpsText;
102+
98103
private void initView(){
99104
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
100105
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@@ -128,6 +133,10 @@ public void onClick(View v) {
128133
});
129134
//touchView.bringToFront();
130135
mOpenCvCameraView.init();
136+
137+
fpsText = findViewById(R.id.text_fps);
138+
mFpsMeter = new FpsMeter();
139+
mFpsMeter.setResolution(GlobalConstant.RESOLUTION_WIDTH, GlobalConstant.RESOLUTION_HEIGHT);
131140
}
132141

133142
private void initGLES10Demo() {
@@ -232,6 +241,13 @@ public Mat onCameraFrame(CameraGLViewBase.CvCameraViewFrame inputFrame) {
232241
//Log.d("JNI_", "onCameraFrame: new image finished");
233242
}
234243

244+
mFpsMeter.measure();
245+
runOnUiThread(new Runnable() {
246+
@Override
247+
public void run() {
248+
fpsText.setText(mFpsMeter.getText());
249+
}
250+
});
235251
return mRgba;
236252
}
237253
private void showHint(final String str){
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.martin.ads.utils;
2+
3+
import java.text.DecimalFormat;
4+
5+
import org.opencv.core.Core;
6+
7+
import android.util.Log;
8+
9+
public class FpsMeter {
10+
private static final String TAG = "FpsMeter";
11+
private static final int STEP = 20;
12+
private static final DecimalFormat FPS_FORMAT = new DecimalFormat("0.00");
13+
14+
private int mFramesCounter;
15+
private double mFrequency;
16+
private long mprevFrameTime;
17+
private String mStrfps;
18+
boolean mIsInitialized = false;
19+
int mWidth = 0;
20+
int mHeight = 0;
21+
22+
public void init() {
23+
mFramesCounter = 0;
24+
mFrequency = Core.getTickFrequency();
25+
mprevFrameTime = Core.getTickCount();
26+
mStrfps = "";
27+
}
28+
29+
public void measure() {
30+
if (!mIsInitialized) {
31+
init();
32+
mIsInitialized = true;
33+
} else {
34+
mFramesCounter++;
35+
if (mFramesCounter % STEP == 0) {
36+
long time = Core.getTickCount();
37+
double fps = STEP * mFrequency / (time - mprevFrameTime);
38+
mprevFrameTime = time;
39+
if (mWidth != 0 && mHeight != 0)
40+
mStrfps = FPS_FORMAT.format(fps) + " FPS@" + Integer.valueOf(mWidth) + "x" + Integer.valueOf(mHeight);
41+
else
42+
mStrfps = FPS_FORMAT.format(fps) + " FPS";
43+
Log.i(TAG, mStrfps);
44+
}
45+
}
46+
}
47+
48+
public void setResolution(int width, int height) {
49+
mWidth = width;
50+
mHeight = height;
51+
}
52+
53+
public String getText() {
54+
Log.d(TAG, mStrfps);
55+
return mStrfps;
56+
}
57+
58+
}
18.3 MB
Binary file not shown.

app/src/main/res/layout/ar_ui_content.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
android:layout_width="match_parent"
1515
android:layout_height="match_parent" />
1616

17+
18+
<TextView
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
android:layout_alignParentStart="true"
22+
android:layout_alignParentBottom="true"
23+
android:id="@+id/text_fps"
24+
android:textColor="#ff00aaff"
25+
android:paddingTop="10dp"
26+
android:paddingStart="30dp"/>
27+
1728
<!--<com.martin.ads.rendering.gles.GLRootView-->
1829
<!--android:id="@+id/ar_object_view_gles2_sphere"-->
1930
<!--android:layout_width="match_parent"-->

0 commit comments

Comments
 (0)