Exclude unresolved face tracks from unique visitor estimate

This commit is contained in:
EVA x10 Development 2026-11-25 10:42:20 +01:00
parent 3fbf6f4e81
commit 3b73ef6cac
7 changed files with 32 additions and 19 deletions

View File

@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.it_screen.edgevision" android:versionCode="17" android:versionName="0.3.12">
package="com.it_screen.edgevision" android:versionCode="18" android:versionName="0.3.13">
<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.12
# EVAx10 Video analitics v0.3.13
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.12.apk`.
creation. The signed test build is `build/EVAx10-Video-analitics-0.3.13.apk`.
```text
adb install --no-incremental -r EVAx10-Video-analitics-0.3.12.apk
adb install --no-incremental -r EVAx10-Video-analitics-0.3.13.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.12-Face-ReID-PoC.apk` as the separate package
`build/EVAx10-Video-analitics-0.3.13-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.
@ -113,8 +113,8 @@ The timeout defaults to 30 minutes from the last sighting. The initial cosine
threshold is 0.55 with a margin of 0.08 to distinguish close candidates. These
are PoC settings and require field calibration. A new confirmed track waits up
to five seconds for a usable face or a stronger match across multiple frames; short tracks that end in that window
may be missed. An ambiguous match or missing template creates a separate session
and may overestimate Unique Visitors. Poses, poor lighting and poor body-to-face
may be missed. An ambiguous match or missing face leaves the track unresolved. The estimate
may undercount visitors whose faces never become usable. Poses, poor lighting and poor body-to-face
association can prevent a match. There is no liveness check.
For a consented acceptance test, keep the camera active. Enter with the face

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.12.apk
apk=build/EVAx10-Video-analitics-0.3.13.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.12-Face-ReID-PoC.apk
apk=build/EVAx10-Video-analitics-0.3.13-Face-ReID-PoC.apk
fi
rm -rf build/classes build/dex
mkdir -p build/classes build/dex

View File

@ -34,7 +34,7 @@ final class DiagnosticsPanel {
{"visitor_session_timeout_minutes", "Visitor Session Timeout", " мин", "Сколько времени с последнего обнаружения сохраняется возможность восстановить сессию. Сам таймаут не подтверждает совпадение."},
{"reid_status", "Re-ID Provider", "", "Статус сопоставления сессий. Disabled означает, что приложение не сравнивает людей между разными треками."},
{"repeated_detections", "Repeated Detections", "", "Сколько новых треков сопоставилось с ранее открытой сессией по SFace."},
{"uncertain_matches", "Uncertain Matches", "", "Сколько раз совпадение оказалось неопределённым и было учтено отдельной сессией."},
{"uncertain_matches", "Uncertain Matches", "", "Сколько треков получили неопределённый результат. Такое решение само по себе не увеличивает Unique Visitors."},
{"id_switches", "ID Switches", "", "Случаи, когда одному и тому же человеку ошибочно присвоили другой ID. Для подсчёта нужна эталонная разметка. В прямом эфире — N/A."},
{"average_dwell_s", "Average Dwell Time", " с", "Среднее время от первого до последнего наблюдения подтверждённых треков в этой сессии. Учитываются текущие и закрытые треки. Ожидание закрытия после последнего кадра не прибавляется."},
{"tracking_fps", "Tracking FPS", " кадр/с", "Фактическое количество кадров в секунду, которые обработал трекер людей."},

View File

@ -211,7 +211,7 @@ public final class MainActivity extends Activity {
uniqueValue = counter(right, "Unique Visitors · оценка PoC");
repeatedValue = counter(right, "Повторные обнаружения");
sessionValue = counter(right, "Активные Visitor Sessions");
TextView note = text("За текущий запуск камеры. Неопределённое совпадение учитывается отдельно.", 13);
TextView note = text("За текущий запуск камеры. Пока лицо не сопоставлено, неопределённый трек в оценку не входит.", 13);
note.setTextColor(0xffaebfd1);
right.addView(note);
} else right.addView(text("Уникальные посетители — пока не считаются", 14));
@ -600,8 +600,7 @@ public final class MainActivity extends Activity {
assignment.visitorId + " продлена. Unique Visitors без изменений.");
break;
case UNCERTAIN:
addVisitEvent("#" + track.id + " · Сопоставление неопределённое. Отдельная сессия V" +
assignment.visitorId + " включена в оценку.");
addVisitEvent("#" + track.id + " · Сопоставление неопределённое. Unique Visitors без изменений.");
break;
case CREATED:
addVisitEvent("#" + track.id + " · Открыта сессия V" + assignment.visitorId +

View File

@ -3,6 +3,8 @@ package com.it_screen.edgevision;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -13,6 +15,7 @@ final class VisitorSessions<Observation> {
private final ReIdProvider<Observation> provider;
private final Map<Long, Session> open = new HashMap<>();
private final Map<Integer, Session> byTrack = new HashMap<>();
private final Set<Integer> unresolved = new HashSet<>();
private long nextId = 1;
private long totalCreated, repeated, uncertain;
@ -81,7 +84,8 @@ final class VisitorSessions<Observation> {
if (!candidate.visible) candidates.add(new Candidate(candidate.id, candidate.lastSeen));
}
if (awaitMoreEvidence && observation == null) return new Assignment(0, Kind.DEFERRED);
if (!candidates.isEmpty()) {
if (observation == null) match = ReIdProvider.UNCERTAIN;
else if (!candidates.isEmpty()) {
match = provider.match(observation, Collections.unmodifiableList(candidates));
Session candidate = open.get(match);
if (candidate != null && !candidate.visible) {
@ -94,9 +98,11 @@ final class VisitorSessions<Observation> {
kind = Kind.RECONNECTED;
repeated++;
} else if (match == ReIdProvider.UNCERTAIN) {
kind = Kind.UNCERTAIN;
if (!unresolved.add(trackId)) return new Assignment(0, Kind.DEFERRED);
uncertain++;
return new Assignment(0, Kind.UNCERTAIN);
} else kind = Kind.CREATED;
unresolved.remove(trackId);
if (session == null) {
session = new Session(nextId++, now);
open.put(session.id, session);
@ -122,11 +128,13 @@ final class VisitorSessions<Observation> {
}
void trackClosed(int trackId) {
unresolved.remove(trackId);
Session session = byTrack.get(trackId);
if (session != null) detach(session);
}
void releaseTracks() {
unresolved.clear();
for (Session session : open.values()) detach(session);
}
@ -138,6 +146,7 @@ final class VisitorSessions<Observation> {
}
void closeSessions() {
unresolved.clear();
for (Session session : open.values()) provider.expired(session.id);
byTrack.clear();
open.clear();

View File

@ -20,8 +20,13 @@ public final class FaceReIdTest {
sessions.trackClosed(2);
VisitorSessions.Assignment unknown = sessions.observe(3, 122000, null);
check(unknown.kind == VisitorSessions.Kind.UNCERTAIN && sessions.uncertainCount() == 1,
check(unknown.kind == VisitorSessions.Kind.UNCERTAIN && sessions.uncertainCount() == 1 &&
sessions.totalCreated() == 1,
"missing observation leaves comparison uncertain");
check(sessions.observe(3, 122500, null).kind == VisitorSessions.Kind.DEFERRED &&
sessions.uncertainCount() == 1, "uncertainty is reported once per track");
check(sessions.observe(3, 123000, vector(1, 0)).kind == VisitorSessions.Kind.RECONNECTED &&
sessions.totalCreated() == 1, "an unresolved track can bind later without creating a duplicate");
sessions.trackClosed(3);
List<VisitorSessions.Candidate> pair = List.of(new VisitorSessions.Candidate(first, 0),
@ -30,12 +35,12 @@ public final class FaceReIdTest {
check(provider.match(vector(1, 0), pair) == ReIdProvider.UNCERTAIN, "tied candidates stay uncertain");
provider.expired(20);
check(provider.match(vector(0, -1), pair.subList(0, 1)) == 0, "distinct embedding");
sessions.expire(182000, 60000);
sessions.expire(183000, 60000);
check(sessions.openCount() == 0 && provider.match(vector(1, 0), pair.subList(0, 1)) == ReIdProvider.UNCERTAIN, "timeout removes the embedding");
sessions.observe(4, 182000, vector(1, 0));
sessions.observe(4, 183000, vector(1, 0));
sessions.closeSessions();
check(sessions.openCount() == 0 && sessions.totalCreated() == 3, "stop closes sessions, retaining count");
check(sessions.openCount() == 0 && sessions.totalCreated() == 2, "stop closes sessions, retaining count");
System.out.println("Face Re-ID tests passed");
}