Reduce camera conversion and idle inference CPU work

This commit is contained in:
EVA x10 Development 2026-11-25 10:50:36 +01:00
parent bf7ce1ecc3
commit 3a97fc397b
6 changed files with 16 additions and 11 deletions

View File

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

View File

@ -1,4 +1,4 @@
# EVAx10 Video analitics v0.3.14
# EVAx10 Video analitics v0.3.15
A separate native Android experiment for consenting adult volunteers.
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
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
creation. The signed test build is `build/EVAx10-Video-analitics-0.3.14.apk`.
creation. The signed test build is `build/EVAx10-Video-analitics-0.3.15.apk`.
```text
adb install --no-incremental -r EVAx10-Video-analitics-0.3.14.apk
adb install --no-incremental -r EVAx10-Video-analitics-0.3.15.apk
adb shell am start -W -n com.it_screen.edgevision/.MainActivity
adb logcat -s EdgeVision EdgeVisionBench
```
@ -96,7 +96,7 @@ or an Android low-memory signal is red.
### Controlled Face Re-ID PoC
Build with `./build.sh --face-reid-poc`. Install
`build/EVAx10-Video-analitics-0.3.14-Face-ReID-PoC.apk` as the separate package
`build/EVAx10-Video-analitics-0.3.15-Face-ReID-PoC.apk` as the separate package
`com.it_screen.edgevision.facereidpoc`. Start requires on-device confirmation
that all adult test participants consent. Keep other people out of the camera view.
The default build excludes the SFace weights and implementation.

View File

@ -20,7 +20,7 @@ if [[ ! -f build/ort.aar ]]; then
fi
python3 tools/check-production-assets.py
manifest=AndroidManifest.xml
apk=build/EVAx10-Video-analitics-0.3.14.apk
apk=build/EVAx10-Video-analitics-0.3.15.apk
if [[ $variant == poc ]]; then
python3 tools/check-poc-assets.py
manifest=build/AndroidManifest-face-reid-poc.xml
@ -28,7 +28,7 @@ if [[ $variant == poc ]]; then
-e 's/android:name=".MainActivity"/android:name="com.it_screen.edgevision.MainActivity"/' \
-e 's/android:label="EVAx10 Video analitics"/android:label="EVAx10 Video analitics · Face Re-ID PoC"/' \
AndroidManifest.xml > "$manifest"
apk=build/EVAx10-Video-analitics-0.3.14-Face-ReID-PoC.apk
apk=build/EVAx10-Video-analitics-0.3.15-Face-ReID-PoC.apk
fi
rm -rf build/classes build/dex
mkdir -p build/classes build/dex

View File

@ -19,6 +19,7 @@ import java.util.Comparator;
final class InternalCamera implements VideoSource {
private final CameraManager manager;
private final int targetWidth, targetHeight;
private final long frameIntervalMs;
private final HandlerThread thread = new HandlerThread("EdgeVision-Camera");
private Handler handler;
private volatile boolean closed;
@ -32,10 +33,13 @@ final class InternalCamera implements VideoSource {
private int frameCount;
private double fps;
InternalCamera(Context context, int width, int height) {
InternalCamera(Context context, int width, int height, int trackingFps) {
manager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
targetWidth = width;
targetHeight = height;
// Leave spare preview frames for the analysis scheduler without processing the full camera stream.
int previewFps = Math.max(6, trackingFps * 2);
frameIntervalMs = Math.max(75, (1000 + previewFps - 1) / previewFps);
}
static String id(CameraManager manager) throws CameraAccessException {
@ -112,7 +116,7 @@ final class InternalCamera implements VideoSource {
frameCount = 0;
epoch = now;
}
if (now - lastFrame < 75) { dropped++; return; }
if (lastFrame != 0 && now - lastFrame < frameIntervalMs) { dropped++; return; }
lastFrame = now;
listener.frame(convert(image), image.getWidth() + "×" + image.getHeight(), fps, dropped);
} catch (Exception error) { if (!closed) fail(error.toString()); }

View File

@ -443,7 +443,8 @@ public final class MainActivity extends Activity {
if (running) return;
Settings selection = readSettings();
String[] dimensions = selection.resolution.split("×");
begin(selection, new InternalCamera(this, Integer.parseInt(dimensions[0]), Integer.parseInt(dimensions[1])));
begin(selection, new InternalCamera(this, Integer.parseInt(dimensions[0]),
Integer.parseInt(dimensions[1]), selection.trackingFps));
}
private void begin(Settings selection, VideoSource input) {

View File

@ -37,8 +37,8 @@ final class OrtEngine implements InferenceEngine {
try (OrtSession.SessionOptions options = new OrtSession.SessionOptions()) {
options.setIntraOpNumThreads(provider.equals("XNNPACK") ? 1 : threads);
options.setInterOpNumThreads(1);
options.addConfigEntry("session.intra_op.allow_spinning", "0");
if ("XNNPACK".equals(provider)) {
options.addConfigEntry("session.intra_op.allow_spinning", "0");
options.addXnnpack(Map.of("intra_op_num_threads", Integer.toString(threads)));
} else if ("NNAPI".equals(provider)) {
options.addNnapi(EnumSet.of(ai.onnxruntime.providers.NNAPIFlags.CPU_DISABLED));