Reduce camera conversion and idle inference CPU work
This commit is contained in:
parent
bf7ce1ecc3
commit
3a97fc397b
|
|
@ -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="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-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"/>
|
||||||
|
|
|
||||||
|
|
@ -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.
|
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.14.apk`.
|
creation. The signed test build is `build/EVAx10-Video-analitics-0.3.15.apk`.
|
||||||
|
|
||||||
```text
|
```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 shell am start -W -n com.it_screen.edgevision/.MainActivity
|
||||||
adb logcat -s EdgeVision EdgeVisionBench
|
adb logcat -s EdgeVision EdgeVisionBench
|
||||||
```
|
```
|
||||||
|
|
@ -96,7 +96,7 @@ or an Android low-memory signal is red.
|
||||||
### Controlled Face Re-ID PoC
|
### Controlled Face Re-ID PoC
|
||||||
|
|
||||||
Build with `./build.sh --face-reid-poc`. Install
|
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
|
`com.it_screen.edgevision.facereidpoc`. Start requires on-device confirmation
|
||||||
that all adult test participants consent. Keep other people out of the camera view.
|
that all adult test participants consent. Keep other people out of the camera view.
|
||||||
The default build excludes the SFace weights and implementation.
|
The default build excludes the SFace weights and implementation.
|
||||||
|
|
|
||||||
4
build.sh
4
build.sh
|
|
@ -20,7 +20,7 @@ if [[ ! -f build/ort.aar ]]; then
|
||||||
fi
|
fi
|
||||||
python3 tools/check-production-assets.py
|
python3 tools/check-production-assets.py
|
||||||
manifest=AndroidManifest.xml
|
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
|
if [[ $variant == poc ]]; then
|
||||||
python3 tools/check-poc-assets.py
|
python3 tools/check-poc-assets.py
|
||||||
manifest=build/AndroidManifest-face-reid-poc.xml
|
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: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"/' \
|
-e 's/android:label="EVAx10 Video analitics"/android:label="EVAx10 Video analitics · Face Re-ID PoC"/' \
|
||||||
AndroidManifest.xml > "$manifest"
|
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
|
fi
|
||||||
rm -rf build/classes build/dex
|
rm -rf build/classes build/dex
|
||||||
mkdir -p build/classes build/dex
|
mkdir -p build/classes build/dex
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import java.util.Comparator;
|
||||||
final class InternalCamera implements VideoSource {
|
final class InternalCamera implements VideoSource {
|
||||||
private final CameraManager manager;
|
private final CameraManager manager;
|
||||||
private final int targetWidth, targetHeight;
|
private final int targetWidth, targetHeight;
|
||||||
|
private final long frameIntervalMs;
|
||||||
private final HandlerThread thread = new HandlerThread("EdgeVision-Camera");
|
private final HandlerThread thread = new HandlerThread("EdgeVision-Camera");
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
private volatile boolean closed;
|
private volatile boolean closed;
|
||||||
|
|
@ -32,10 +33,13 @@ final class InternalCamera implements VideoSource {
|
||||||
private int frameCount;
|
private int frameCount;
|
||||||
private double fps;
|
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);
|
manager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
|
||||||
targetWidth = width;
|
targetWidth = width;
|
||||||
targetHeight = height;
|
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 {
|
static String id(CameraManager manager) throws CameraAccessException {
|
||||||
|
|
@ -112,7 +116,7 @@ final class InternalCamera implements VideoSource {
|
||||||
frameCount = 0;
|
frameCount = 0;
|
||||||
epoch = now;
|
epoch = now;
|
||||||
}
|
}
|
||||||
if (now - lastFrame < 75) { dropped++; return; }
|
if (lastFrame != 0 && now - lastFrame < frameIntervalMs) { dropped++; return; }
|
||||||
lastFrame = now;
|
lastFrame = now;
|
||||||
listener.frame(convert(image), image.getWidth() + "×" + image.getHeight(), fps, dropped);
|
listener.frame(convert(image), image.getWidth() + "×" + image.getHeight(), fps, dropped);
|
||||||
} catch (Exception error) { if (!closed) fail(error.toString()); }
|
} catch (Exception error) { if (!closed) fail(error.toString()); }
|
||||||
|
|
|
||||||
|
|
@ -443,7 +443,8 @@ public final class MainActivity extends Activity {
|
||||||
if (running) return;
|
if (running) return;
|
||||||
Settings selection = readSettings();
|
Settings selection = readSettings();
|
||||||
String[] dimensions = selection.resolution.split("×");
|
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) {
|
private void begin(Settings selection, VideoSource input) {
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ final class OrtEngine implements InferenceEngine {
|
||||||
try (OrtSession.SessionOptions options = new OrtSession.SessionOptions()) {
|
try (OrtSession.SessionOptions options = new OrtSession.SessionOptions()) {
|
||||||
options.setIntraOpNumThreads(provider.equals("XNNPACK") ? 1 : threads);
|
options.setIntraOpNumThreads(provider.equals("XNNPACK") ? 1 : threads);
|
||||||
options.setInterOpNumThreads(1);
|
options.setInterOpNumThreads(1);
|
||||||
|
options.addConfigEntry("session.intra_op.allow_spinning", "0");
|
||||||
if ("XNNPACK".equals(provider)) {
|
if ("XNNPACK".equals(provider)) {
|
||||||
options.addConfigEntry("session.intra_op.allow_spinning", "0");
|
|
||||||
options.addXnnpack(Map.of("intra_op_num_threads", Integer.toString(threads)));
|
options.addXnnpack(Map.of("intra_op_num_threads", Integer.toString(threads)));
|
||||||
} else if ("NNAPI".equals(provider)) {
|
} else if ("NNAPI".equals(provider)) {
|
||||||
options.addNnapi(EnumSet.of(ai.onnxruntime.providers.NNAPIFlags.CPU_DISABLED));
|
options.addNnapi(EnumSet.of(ai.onnxruntime.providers.NNAPIFlags.CPU_DISABLED));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue