-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstate.lua
executable file
·73 lines (64 loc) · 1.81 KB
/
state.lua
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
-- global state (excluding ui state)
local state = {}
-- tensors holding raw and processed frames
state.rawFrame = torch.Tensor()
state.input = torch.Tensor()
state.dynamic = 0.1
-- stores the position and bounds of tracked objects
state.resultsSMR = {}
-- stores an image patch and its associated dense features (prototype)
state.lastPatch = torch.Tensor()
state.totalProb = torch.Tensor()
state.SMRProb = torch.Tensor()
-- hold the postion and class of a prototype to be added
state.learn = nil
-- flag that the end of video or dataset has been reached
state.finished = false
state.finish = function()
state.logit('you have reached the end of the video')
if state.dsoutfile then
state.dsoutfile:close()
end
end
-- options
state.classes = options.classes
state.threshold = options.recognition_lthreshold
state.autolearn = options.autolearn
state.std = options.standard_deviation
if options.nogui then
function state.begin()
while not state.finished do
profiler:start('full-loop','fps')
print('Frame:',source.current)
process()
print('')
profiler:lap('full-loop')
end
state.finish()
end
function state.logit(msg)
print(msg)
end
else
local function loop()
profiler:start('full-loop','fps')
process()
display.update()
profiler:lap('full-loop')
display.results()
end
function state.begin()
display.begin(loop)
end
-- provide log
state.log = {}
function state.logit(str,color)
-- color can be a class id (number) or a color name (string)
print(str)
if type(color) == 'number' then
color = 'blue'
end
table.insert(state.log,{str=str, color=color or 'black'})
end
end
return state