Show estimated visitor age groups on the dashboard
This commit is contained in:
parent
60e2db9212
commit
fb656519a3
|
|
@ -1,5 +1,5 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.it_screen.edgevision" android:versionCode="21" android:versionName="0.3.16">
|
||||
package="com.it_screen.edgevision" android:versionCode="22" android:versionName="0.3.17">
|
||||
<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"/>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# EVAx10 Video analitics v0.3.16
|
||||
# EVAx10 Video analitics v0.3.17
|
||||
|
||||
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.16.apk`.
|
||||
creation. The signed test build is `build/EVAx10-Video-analitics-0.3.17.apk`.
|
||||
|
||||
```text
|
||||
adb install --no-incremental -r EVAx10-Video-analitics-0.3.16.apk
|
||||
adb install --no-incremental -r EVAx10-Video-analitics-0.3.17.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.16-Face-ReID-PoC.apk` as the separate package
|
||||
`build/EVAx10-Video-analitics-0.3.17-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.
|
||||
|
|
|
|||
4
build.sh
4
build.sh
|
|
@ -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.16.apk
|
||||
apk=build/EVAx10-Video-analitics-0.3.17.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.16-Face-ReID-PoC.apk
|
||||
apk=build/EVAx10-Video-analitics-0.3.17-Face-ReID-PoC.apk
|
||||
fi
|
||||
rm -rf build/classes build/dex
|
||||
mkdir -p build/classes build/dex
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ final class AudienceAggregator {
|
|||
Arrays.fill(ages, 0);
|
||||
}
|
||||
|
||||
private int ageGroup(Integer age) {
|
||||
static int ageGroup(Integer age) {
|
||||
if (age == null || age < 18 || age > 80) return 6;
|
||||
if (age < 25) return 1;
|
||||
if (age < 35) return 2;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public final class MainActivity extends Activity {
|
|||
private Preview preview;
|
||||
private Button start, stop, test;
|
||||
private TextView trackingSettingsSummary;
|
||||
private final TextView[] ageValues = new TextView[AudienceAggregator.AGES.length];
|
||||
private Spinner resolution, detection, classification, provider, threadCount, faceModel, ageModel;
|
||||
private boolean running;
|
||||
|
||||
|
|
@ -226,6 +227,7 @@ public final class MainActivity extends Activity {
|
|||
right.addView(note);
|
||||
} else right.addView(text("Уникальные посетители — пока не считаются", 14));
|
||||
|
||||
addAgeBreakdown(right);
|
||||
TextView journalTitle = text("Журнал трекинга", 16);
|
||||
journalTitle.setPadding(0, 16, 0, 6);
|
||||
right.addView(journalTitle);
|
||||
|
|
@ -252,6 +254,35 @@ public final class MainActivity extends Activity {
|
|||
test.setEnabled(false);
|
||||
}
|
||||
|
||||
private void addAgeBreakdown(LinearLayout parent) {
|
||||
TextView heading = text(FaceReId.CONTROLLED_POC ? "Возраст посетителей · оценка" :
|
||||
"Возраст по подтверждённым трекам · оценка", 14);
|
||||
heading.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
heading.setPadding(0, 10, 0, 4);
|
||||
parent.addView(heading);
|
||||
LinearLayout row = null;
|
||||
for (int i = 1; i < ageValues.length; i++) {
|
||||
if ((i - 1) % 3 == 0) {
|
||||
row = new LinearLayout(this);
|
||||
parent.addView(row);
|
||||
}
|
||||
LinearLayout cell = column();
|
||||
TextView label = text(i == ageValues.length - 1 ? "Не определён" : AudienceAggregator.AGES[i], 12);
|
||||
label.setTextColor(0xffaebfd1);
|
||||
cell.addView(label);
|
||||
TextView value = text("0", 16);
|
||||
value.setTextColor(0xff9ce8c2);
|
||||
value.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
cell.addView(value);
|
||||
ageValues[i] = value;
|
||||
row.addView(cell, new LinearLayout.LayoutParams(0, -2, 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAgeBreakdown(int[] counts) {
|
||||
for (int i = 1; i < counts.length; i++) updateCounter(ageValues[i], counts[i]);
|
||||
}
|
||||
|
||||
private TextView counter(LinearLayout parent, String name) {
|
||||
LinearLayout row = new LinearLayout(this);
|
||||
TextView label = text(name, 15);
|
||||
|
|
@ -489,6 +520,7 @@ public final class MainActivity extends Activity {
|
|||
final long run = ++generation;
|
||||
if (FaceReId.CONTROLLED_POC) {
|
||||
updatePocStats(0, 0, 0);
|
||||
updateAgeBreakdown(new int[ageValues.length]);
|
||||
ui.postDelayed(expirePocSessions, 1000);
|
||||
}
|
||||
nextFrame = 0;
|
||||
|
|
@ -643,6 +675,7 @@ public final class MainActivity extends Activity {
|
|||
} finally {
|
||||
if (sample != null) Arrays.fill(sample, 0);
|
||||
}
|
||||
if (FaceReId.CONTROLLED_POC) visitorSessions.updateAge(track.id, track.analytics.averageAge());
|
||||
switch (assignment.kind) {
|
||||
case RECONNECTED:
|
||||
addVisitEvent("#" + track.id + " · Повторное обнаружение. Сессия V" +
|
||||
|
|
@ -682,6 +715,7 @@ public final class MainActivity extends Activity {
|
|||
int[] genders = totals.genders.clone(), ages = totals.ages.clone();
|
||||
long unique = visitorSessions.totalCreated(), repeated = visitorSessions.repeatedCount();
|
||||
int openSessions = visitorSessions.openCount();
|
||||
int[] visitorAges = FaceReId.CONTROLLED_POC ? visitorSessions.ageCounts() : null;
|
||||
final String tracking = visitEvents.isEmpty() ? "Ожидание посетителей" : String.join("\n\n", visitEvents);
|
||||
final JSONObject detail;
|
||||
if (sampled) {
|
||||
|
|
@ -698,6 +732,7 @@ public final class MainActivity extends Activity {
|
|||
preview.invalidate();
|
||||
updateStats(activeTracks, visits, genders, ages);
|
||||
updatePocStats(unique, repeated, openSessions);
|
||||
if (visitorAges != null) updateAgeBreakdown(visitorAges);
|
||||
if (detail != null) {
|
||||
diagnostics.update(detail);
|
||||
if (source instanceof InternalCamera) {
|
||||
|
|
@ -779,6 +814,7 @@ public final class MainActivity extends Activity {
|
|||
String value = Integer.toString(current);
|
||||
if (!value.contentEquals(currentVisitorValue.getText())) currentVisitorValue.setText(value);
|
||||
diagnostics.updateConfirmedTracks(visits, genders, ages);
|
||||
if (!FaceReId.CONTROLLED_POC) updateAgeBreakdown(ages);
|
||||
}
|
||||
|
||||
private void failed(long run, String reason) {
|
||||
|
|
@ -812,6 +848,7 @@ public final class MainActivity extends Activity {
|
|||
trackingLog.setText("Журнал очищен");
|
||||
updateStats(0, 0, new int[3], new int[7]);
|
||||
updatePocStats(0, 0, 0);
|
||||
if (FaceReId.CONTROLLED_POC) updateAgeBreakdown(new int[ageValues.length]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.it_screen.edgevision;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
|
@ -16,6 +17,7 @@ final class VisitorSessions<Observation> {
|
|||
private final Map<Long, Session> open = new HashMap<>();
|
||||
private final Map<Integer, Session> byTrack = new HashMap<>();
|
||||
private final Set<Integer> unresolved = new HashSet<>();
|
||||
private final int[] ageCounts = new int[AudienceAggregator.AGES.length];
|
||||
private long nextId = 1;
|
||||
private long totalCreated, repeated, uncertain;
|
||||
|
||||
|
|
@ -43,6 +45,7 @@ final class VisitorSessions<Observation> {
|
|||
long lastSeen;
|
||||
Integer track;
|
||||
boolean visible;
|
||||
int ageGroup = AudienceAggregator.ageGroup(null);
|
||||
Session(long id, long now) { this.id = id; lastSeen = now; }
|
||||
}
|
||||
|
||||
|
|
@ -107,6 +110,7 @@ final class VisitorSessions<Observation> {
|
|||
session = new Session(nextId++, now);
|
||||
open.put(session.id, session);
|
||||
totalCreated++;
|
||||
ageCounts[session.ageGroup]++;
|
||||
}
|
||||
session.track = trackId;
|
||||
byTrack.put(trackId, session);
|
||||
|
|
@ -117,6 +121,18 @@ final class VisitorSessions<Observation> {
|
|||
return new Assignment(session.id, kind);
|
||||
}
|
||||
|
||||
void updateAge(int trackId, Integer age) {
|
||||
Session session = byTrack.get(trackId);
|
||||
int unknown = AudienceAggregator.ageGroup(null);
|
||||
int group = AudienceAggregator.ageGroup(age);
|
||||
if (session == null || session.ageGroup != unknown || group == unknown) return;
|
||||
ageCounts[unknown]--;
|
||||
ageCounts[group]++;
|
||||
session.ageGroup = group;
|
||||
}
|
||||
|
||||
int[] ageCounts() { return ageCounts.clone(); }
|
||||
|
||||
void reserveObservedTrack(int trackId) {
|
||||
Session session = byTrack.get(trackId);
|
||||
if (session != null) session.visible = true;
|
||||
|
|
@ -141,6 +157,7 @@ final class VisitorSessions<Observation> {
|
|||
void clear() {
|
||||
closeSessions();
|
||||
totalCreated = 0;
|
||||
Arrays.fill(ageCounts, 0);
|
||||
repeated = 0;
|
||||
uncertain = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ public final class FaceReIdTest {
|
|||
|
||||
long first = sessions.observe(1, 0, vector(1, 0)).visitorId;
|
||||
sessions.observe(1, 1000, vector(.8f, .6f));
|
||||
check(sessions.ageCounts()[AudienceAggregator.ageGroup(null)] == 1,
|
||||
"new session starts without an age estimate");
|
||||
sessions.updateAge(1, 34);
|
||||
sessions.trackClosed(1);
|
||||
check(sessions.observe(2, 120000, vector(0, -1), true).kind == VisitorSessions.Kind.DEFERRED &&
|
||||
sessions.totalCreated() == 1, "first low-quality comparison does not create a duplicate");
|
||||
|
|
@ -17,6 +20,10 @@ public final class FaceReIdTest {
|
|||
check(returned.kind == VisitorSessions.Kind.RECONNECTED && returned.visitorId == first,
|
||||
"return with a different track and moderately changed vector");
|
||||
check(sessions.totalCreated() == 1 && sessions.repeatedCount() == 1, "deduplicated counters");
|
||||
sessions.updateAge(2, 41);
|
||||
check(sessions.ageCounts()[AudienceAggregator.ageGroup(34)] == 1 &&
|
||||
sessions.ageCounts()[AudienceAggregator.ageGroup(41)] == 0,
|
||||
"reconnected tracks retain the existing visitor age group");
|
||||
sessions.trackClosed(2);
|
||||
|
||||
VisitorSessions.Assignment unknown = sessions.observe(3, 122000, null);
|
||||
|
|
@ -38,6 +45,8 @@ public final class FaceReIdTest {
|
|||
sessions.expire(183000, 60000);
|
||||
check(sessions.openCount() == 0 && provider.match(vector(1, 0), pair.subList(0, 1)) == ReIdProvider.UNCERTAIN, "timeout removes the embedding");
|
||||
|
||||
check(sessions.ageCounts()[AudienceAggregator.ageGroup(34)] == 1,
|
||||
"expired sessions still count in this run's age breakdown");
|
||||
sessions.observe(4, 183000, vector(1, 0));
|
||||
sessions.closeSessions();
|
||||
check(sessions.openCount() == 0 && sessions.totalCreated() == 2, "stop closes sessions, retaining count");
|
||||
|
|
|
|||
Loading…
Reference in New Issue