Show camera settings and live device load below video

This commit is contained in:
EVA x10 Development 2026-11-25 09:17:01 +01:00
parent ddc45f7416
commit 00756ec736
5 changed files with 155 additions and 8 deletions

View File

@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.it_screen.edgevision" android:versionCode="12" android:versionName="0.3.7"> package="com.it_screen.edgevision" android:versionCode="13" android:versionName="0.3.8">
<uses-sdk android:minSdkVersion="30" android:targetSdkVersion="34"/> <uses-sdk android:minSdkVersion="30" android:targetSdkVersion="34"/>
<uses-permission android:name="android.permission.CAMERA"/> <uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera.any" android:required="true"/> <uses-feature android:name="android.hardware.camera.any" android:required="true"/>

View File

@ -1,4 +1,4 @@
# EVAx10 Video analitics v0.3.7 # EVAx10 Video analitics v0.3.8
A separate native Android experiment for consenting adult volunteers. A separate native Android experiment for consenting adult volunteers.
Package `com.it_screen.edgevision`. The existing FaceAPI baseline is Package `com.it_screen.edgevision`. The existing FaceAPI baseline is
@ -10,10 +10,10 @@ installable as `com.it_screen.audiencepoc`.
`./build.sh` builds the ARM64, API 30+ APK with the Windows Android SDK 35 `./build.sh` builds the ARM64, API 30+ APK with the Windows Android SDK 35
and JDK 17 via WSL. The script pins and verifies the upstream Maven AAR. and JDK 17 via WSL. The script pins and verifies the upstream Maven AAR.
Model assets load locally and are verified before ONNX Runtime session Model assets load locally and are verified before ONNX Runtime session
creation. The signed test build is `build/EVAx10-Video-analitics-0.3.7.apk`. creation. The signed test build is `build/EVAx10-Video-analitics-0.3.8.apk`.
```text ```text
adb install --no-incremental -r EVAx10-Video-analitics-0.3.7.apk adb install --no-incremental -r EVAx10-Video-analitics-0.3.8.apk
adb shell am start -W -n com.it_screen.edgevision/.MainActivity adb shell am start -W -n com.it_screen.edgevision/.MainActivity
adb logcat -s EdgeVision EdgeVisionBench adb logcat -s EdgeVision EdgeVisionBench
``` ```
@ -76,3 +76,18 @@ Closing the body track leaves its visitor session eligible until that
timeout. The on-device Re-ID provider is disabled. See the timeout. The on-device Re-ID provider is disabled. See the
[session and Re-ID report](REID_EVALUATION.md) for the lifecycle, [session and Re-ID report](REID_EVALUATION.md) for the lifecycle,
benchmarks, licensing, and limits. benchmarks, licensing, and limits.
### Live device gauges
Below Video, the camera row shows the actual capture resolution and the observed
frame rate delivered to the app. Choose a supported resolution before pressing Start.
CPU is the smoothed process load divided by the number of available cores.
On four cores, 200% in the raw benchmark corresponds to 50% on this gauge.
Green through 40% leaves CPU headroom for playback. Amber covers over 40%
through 60%. Red starts above 60%. Android's moderate or severe thermal status
can raise the color to amber or red respectively. These are operational thresholds.
The RAM bar shows the share of memory in use according to Android. The label
shows Android's estimate of available RAM and the app's proportional set size
(PSS). Available RAM of at least 25% is green, 15–25% is amber, and below 15%
or an Android low-memory signal is red.

View File

@ -47,5 +47,5 @@ PY
if [[ ! -f build/poc-debug.p12 ]]; then if [[ ! -f build/poc-debug.p12 ]]; then
"$jdk/bin/keytool.exe" -genkeypair -keystore build/poc-debug.p12 -storepass android -alias edgevision -keyalg RSA -keysize 2048 -validity 3650 -dname CN=EdgeVision "$jdk/bin/keytool.exe" -genkeypair -keystore build/poc-debug.p12 -storepass android -alias edgevision -keyalg RSA -keysize 2048 -validity 3650 -dname CN=EdgeVision
fi fi
"$jdk/bin/java.exe" -jar "$(wslpath -w "$tools/lib/apksigner.jar")" sign --ks build/poc-debug.p12 --ks-pass pass:android --out build/EVAx10-Video-analitics-0.3.7.apk build/aligned.apk "$jdk/bin/java.exe" -jar "$(wslpath -w "$tools/lib/apksigner.jar")" sign --ks build/poc-debug.p12 --ks-pass pass:android --out build/EVAx10-Video-analitics-0.3.8.apk build/aligned.apk
"$jdk/bin/java.exe" -jar "$(wslpath -w "$tools/lib/apksigner.jar")" verify --verbose build/EVAx10-Video-analitics-0.3.7.apk "$jdk/bin/java.exe" -jar "$(wslpath -w "$tools/lib/apksigner.jar")" verify --verbose build/EVAx10-Video-analitics-0.3.8.apk

View File

@ -47,6 +47,8 @@ public final class MainActivity extends Activity {
private double loadMs; private double loadMs;
private TextView status, currentVisitorValue, trackingLog; private TextView status, currentVisitorValue, trackingLog;
private DiagnosticsPanel diagnostics; private DiagnosticsPanel diagnostics;
private ResourcePanel resources;
private TextView cameraStatus;
private final java.text.SimpleDateFormat eventClock = new java.text.SimpleDateFormat("HH:mm:ss", Locale.ROOT); private final java.text.SimpleDateFormat eventClock = new java.text.SimpleDateFormat("HH:mm:ss", Locale.ROOT);
private Preview preview; private Preview preview;
private Button start, stop, test; private Button start, stop, test;
@ -134,6 +136,14 @@ public final class MainActivity extends Activity {
left.addView(status); left.addView(status);
preview = new Preview(); preview = new Preview();
left.addView(preview, new LinearLayout.LayoutParams(-1, 0, 1)); left.addView(preview, new LinearLayout.LayoutParams(-1, 0, 1));
LinearLayout cameraRow = new LinearLayout(this);
cameraRow.setGravity(Gravity.CENTER_VERTICAL);
cameraStatus = text("Камера · остановлена", 14);
cameraRow.addView(cameraStatus, new LinearLayout.LayoutParams(0, -2, 2));
resolution = setting(cameraRow, "Разрешение до запуска", "640×480", "1280×720");
left.addView(cameraRow);
resources = new ResourcePanel(this);
left.addView(resources);
LinearLayout actions = new LinearLayout(this); LinearLayout actions = new LinearLayout(this);
left.addView(actions); left.addView(actions);
start = button(actions, "Start", () -> { start = button(actions, "Start", () -> {
@ -156,7 +166,6 @@ public final class MainActivity extends Activity {
LinearLayout row1 = new LinearLayout(this), row2 = new LinearLayout(this); LinearLayout row1 = new LinearLayout(this), row2 = new LinearLayout(this);
left.addView(row1); left.addView(row1);
left.addView(row2); left.addView(row2);
resolution = setting(row1, "Resolution", "640×480", "1280×720");
interval = setting(row1, "Face interval ms", "100", "200", "500", "1000"); interval = setting(row1, "Face interval ms", "100", "200", "500", "1000");
interval.setSelection(2); interval.setSelection(2);
detection = setting(row1, "Detection threshold", "0.5", "0.6", "0.7", "0.8", "0.9"); detection = setting(row1, "Detection threshold", "0.5", "0.6", "0.7", "0.8", "0.9");
@ -373,6 +382,7 @@ public final class MainActivity extends Activity {
private void begin(Settings selection, VideoSource input) { private void begin(Settings selection, VideoSource input) {
setRunning(true); setRunning(true);
cameraStatus.setText(input instanceof InternalCamera ? "Камера · запуск…" : "Камера · тестовое изображение");
setStatus("Loading model sessions…"); setStatus("Loading model sessions…");
final long run = ++generation; final long run = ++generation;
nextFrame = 0; nextFrame = 0;
@ -560,7 +570,15 @@ public final class MainActivity extends Activity {
preview.boxes = overlays; preview.boxes = overlays;
preview.invalidate(); preview.invalidate();
updateStats(activeTracks, visits, genders, ages); updateStats(activeTracks, visits, genders, ages);
if (detail != null) diagnostics.update(detail); if (detail != null) {
diagnostics.update(detail);
if (source instanceof InternalCamera) {
double fps = detail.optDouble("camera_fps");
String rate = Double.isNaN(fps) ? "измеряем FPS…" :
String.format(Locale.getDefault(), "%.1f FPS", fps);
cameraStatus.setText("Камера · " + size + " · " + rate);
}
}
}); });
} }
@ -677,6 +695,7 @@ public final class MainActivity extends Activity {
preview.boxes = java.util.Collections.emptyList(); preview.boxes = java.util.Collections.emptyList();
preview.invalidate(); preview.invalidate();
setRunning(false); setRunning(false);
cameraStatus.setText("Камера · остановлена");
setStatus(message); setStatus(message);
inference.execute(() -> { inference.execute(() -> {
visitorSessions.releaseTracks(); visitorSessions.releaseTracks();
@ -726,7 +745,13 @@ public final class MainActivity extends Activity {
}); });
} }
@Override protected void onStart() {
super.onStart();
resources.start();
}
@Override protected void onStop() { @Override protected void onStop() {
resources.stop();
if (running) halt("Stopped in background"); if (running) halt("Stopped in background");
super.onStop(); super.onStop();
} }

107
src/ResourcePanel.java Normal file
View File

@ -0,0 +1,107 @@
package com.it_screen.edgevision;
import android.app.ActivityManager;
import android.content.Context;
import android.content.res.ColorStateList;
import android.os.Debug;
import android.os.Handler;
import android.os.Looper;
import android.os.PowerManager;
import android.os.SystemClock;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import java.util.Locale;
final class ResourcePanel extends LinearLayout {
private static final int NORMAL = 0xff67dba0;
private static final int WARNING = 0xffffcb65;
private static final int HIGH = 0xffff7777;
private static final double MIB = 1024.0 * 1024;
private final Handler handler = new Handler(Looper.getMainLooper());
private final Runnable tick = this::sample;
private final ActivityManager activity;
private final PowerManager power;
private final ActivityManager.MemoryInfo memory = new ActivityManager.MemoryInfo();
private final Meter cpu, ram;
private long lastTime, lastCpu;
private double averageCpu = Double.NaN;
ResourcePanel(Context context) {
super(context);
activity = context.getSystemService(ActivityManager.class);
power = context.getSystemService(PowerManager.class);
cpu = new Meter("CPU приложения · измеряем…");
ram = new Meter("Память устройства · измеряем…");
}
void start() {
lastTime = SystemClock.elapsedRealtime();
lastCpu = android.os.Process.getElapsedCpuTime();
averageCpu = Double.NaN;
cpu.label.setText("CPU приложения · измеряем…");
cpu.bar.setProgress(0);
handler.postDelayed(tick, 1000);
}
void stop() {
handler.removeCallbacks(tick);
}
private void sample() {
long now = SystemClock.elapsedRealtime();
long cpuTime = android.os.Process.getElapsedCpuTime();
int cores = Runtime.getRuntime().availableProcessors();
double sample = Math.min(100, 100.0 * (cpuTime - lastCpu) / ((now - lastTime) * cores));
lastTime = now;
lastCpu = cpuTime;
averageCpu = Double.isNaN(averageCpu) ? sample : averageCpu * .75 + sample * .25;
int thermal = power.getCurrentThermalStatus();
int cpuColor = averageCpu > 60 || thermal >= PowerManager.THERMAL_STATUS_SEVERE ? HIGH :
averageCpu > 40 || thermal >= PowerManager.THERMAL_STATUS_MODERATE ? WARNING : NORMAL;
String thermalNote = thermal >= PowerManager.THERMAL_STATUS_SEVERE ? " · сильный нагрев" :
thermal >= PowerManager.THERMAL_STATUS_MODERATE ? " · нагрев" : "";
cpu.update(averageCpu, cpuColor, String.format(Locale.getDefault(),
"CPU приложения · %.0f%% · %.1f из %d ядер%s", averageCpu, averageCpu * cores / 100, cores, thermalNote));
activity.getMemoryInfo(memory);
if (memory.totalMem > 0) {
double available = 100.0 * memory.availMem / memory.totalMem;
int ramColor = memory.lowMemory || available < 15 ? HIGH : available < 25 ? WARNING : NORMAL;
ram.update(100 - available, ramColor, String.format(Locale.getDefault(),
"RAM · доступно %.0f%% (%.0f МиБ из %.0f) · приложение %.0f МиБ",
available, memory.availMem / MIB, memory.totalMem / MIB, Debug.getPss() / 1024.0));
}
handler.postDelayed(tick, 1000);
}
private final class Meter {
final TextView label;
final ProgressBar bar;
Meter(String title) {
Context context = getContext();
LinearLayout column = new LinearLayout(context);
column.setOrientation(VERTICAL);
int inset = Math.round(6 * getResources().getDisplayMetrics().density);
column.setPadding(inset, 0, inset, 0);
label = new TextView(context);
label.setText(title);
label.setTextSize(12);
column.addView(label);
bar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
bar.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
bar.setProgressBackgroundTintList(ColorStateList.valueOf(0xff334550));
column.addView(bar, new LayoutParams(-1, -2));
addView(column, new LayoutParams(0, -2, 1));
}
void update(double percent, int tint, String value) {
bar.setProgressTintList(ColorStateList.valueOf(tint));
bar.setProgress((int) Math.round(percent));
String condition = tint == NORMAL ? "норма" : tint == WARNING ? "повышенная нагрузка" : "высокая нагрузка";
label.setText(value);
label.setContentDescription(value + " · " + condition);
}
}
}