MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / PersonDetector

Class PersonDetector

src/main/java/trace/util/PersonDetector.kt:8–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6import java.nio.file.Files
7
8class PersonDetector(val fn: String, val w: Int, val h: Int) {
9
10 inner class RectWithName(var name: String, x: Double, y: Double, w: Double, h: Double) : Rect(x, y, w, h) {
11 var track: Track? = null
12 }
13
14 inner class Frame(val index: Int) {
15 val r = mutableListOf<RectWithName>()
16
17 }
18
19 inner class Track {
20 val x0 = TCB3()
21 val y0 = TCB3()
22 val x1 = TCB3()
23 val y1 = TCB3()
24
25 val frames = mutableListOf<Frame>()
26
27 var lostFor = 0;
28 var seen = false;
29
30 var name = "";
31
32 fun startTime(): Double {
33 return x0.n[0].x / duration()
34 }
35
36 fun endTime(): Double {
37 return x0.n.last().x / duration()
38 }
39
40 fun rectAtTime(t: Double): Rect {
41 val ax0 = x0.evaluate(t * duration(), Vec3()).x
42 val ax1 = x1.evaluate(t * duration(), Vec3()).x
43 val ay0 = y0.evaluate(t * duration(), Vec3()).x
44 val ay1 = y1.evaluate(t * duration(), Vec3()).x
45
46 return Rect(100 * Math.min(ax0, ax1),
47 100 * Math.min(ay0, ay1),
48 100 * (Math.max(ax0, ax1) - Math.min(ax0, ax1)),
49 100 * (Math.max(ay0, ay1) - Math.min(ay0, ay1)))
50 }
51 }
52
53 val frames = mutableListOf<Frame>()
54 val tracks = mutableListOf<Track>()
55 val allTracks = mutableListOf<Track>()
56
57 init {
58
59 val all = Files.readAllLines(File(fn).toPath())
60 var currentFrame = Frame(-1)
61
62 all.forEach {
63 //Enter Image Path: /Users/marc/Desktop/zachAndXander/test1/src/o_000903.jpg: Predicted in 8.763337 seconds.
64
65 if (it.startsWith("Enter Image Path:")) {

Callers

nothing calls this directly

Calls 9

FileFunction · 0.85
RectWithNameClass · 0.85
tcbAllMethod · 0.80
FrameClass · 0.70
TrackClass · 0.70
forEachMethod · 0.45
addMethod · 0.45
splitMethod · 0.45
removeIfMethod · 0.45

Tested by

no test coverage detected