forked from januhlenberg/Signa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BoundingBox.m
45 lines (45 loc) · 1.13 KB
/
BoundingBox.m
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
classdef BoundingBox < handle
properties
ID
Untouched
X
Y
Width
Height
Center
identified
history = [];
end
methods
function obj = BoundingBox(bbox)
obj.Untouched = 0;
obj.X = bbox(1);
obj.Y = bbox(2);
obj.Width = bbox(3);
obj.Height = bbox(4);
obj.Center = [obj.X + obj.Width/2, obj.Y + obj.Height/2];
obj.identified = false;
end
function AddNext(obj,bbox)
obj.history = [obj.history, bbox];
end
function lc = GetLastCenter(obj)
lc = obj.Center;
if length(obj.history) > 0
lc = obj.history(length(obj.history)).Center;
end
end
function [x y w h] = GetLastRect(obj)
x = obj.X;
y = obj.Y;
w = obj.Width;
h = obj.Height;
if length(obj.history) > 0
x = obj.history(length(obj.history)).X;
y = obj.history(length(obj.history)).Y;
w = obj.history(length(obj.history)).Width;
h = obj.history(length(obj.history)).Height;
end
end
end
end