forked from jeffshih/countSimulator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetectionParser.py
More file actions
54 lines (43 loc) · 1.59 KB
/
detectionParser.py
File metadata and controls
54 lines (43 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import numpy as np
from detection import detectionResult
from Point import Point
import string
from Util import *
from config import *
from Generator import detGenerator
class detectionParser(object):
def __init__(self):
self.frame = []
self.detectionSequence = {}
self.frameNum = 0
def stringToDet(self, inputString):
strSplit = inputString.split(",")
TimeStamp = int(strSplit[0])
currentFrame = int(strSplit[1])
catagory = int(strSplit[2])
confidence = float(strSplit[3])
cx = float(strSplit[4])
cy = float(strSplit[5])
w = float(strSplit[6])
h = float(strSplit[7])
center = Point(cx,cy)
wh = Point(w,h)
Center = ratioToAbs(resolution, center)
WH = ratioToAbs(resolution, wh)
det = detectionResult(TimeStamp, catagory, currentFrame, WH\
,Center, resolution, confidence=confidence)
return det
def getDetSequence(self, detDict:dict):
for frameNum, detList in detDict.items():
self.detectionSequence[frameNum] = list()
for detLines in detList:
self.detectionSequence[frameNum].append(self.stringToDet(detLines))
return self.detectionSequence
if __name__ == "__main__":
detGen = detGenerator(minObj=5,maxObj=10)
res = detGen.getDetectionRes()
transformedData = transform(res)
detParser = detectionParser()
detectionSequence = detParser.getDetSequence(transformedData)
for frameNum, dets in detectionSequence.items():
print(frameNum, len(dets))