-
Notifications
You must be signed in to change notification settings - Fork 19
/
Object.cpp
120 lines (98 loc) · 2.92 KB
/
Object.cpp
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//--------------------------------------------------------------------------------------------------
// Implementation of the papers "Exact Acceleration of Linear Object Detectors", 12th European
// Conference on Computer Vision, 2012 and "Deformable Part Models with Individual Part Scaling",
// 24th British Machine Vision Conference, 2013.
//
// Copyright (c) 2013 Idiap Research Institute, <http://www.idiap.ch/>
// Written by Charles Dubout <[email protected]>
//
// This file is part of FFLDv2 (the Fast Fourier Linear Detector version 2)
//
// FFLDv2 is free software: you can redistribute it and/or modify it under the terms of the GNU
// Affero General Public License version 3 as published by the Free Software Foundation.
//
// FFLDv2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
// General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License along with FFLDv2. If
// not, see <http://www.gnu.org/licenses/>.
//--------------------------------------------------------------------------------------------------
#include "Object.h"
#include <iostream>
using namespace FFLD;
using namespace std;
Object::Object() : name_(UNKNOWN), pose_(UNSPECIFIED), truncated_(false), difficult_(false)
{
}
Object::Object(Name name, Pose pose, bool truncated, bool difficult, Rectangle bndbox) :
name_(name), pose_(pose), truncated_(truncated), difficult_(difficult), bndbox_(bndbox)
{
}
bool Object::empty() const
{
return (name() == UNKNOWN) && (pose() == UNSPECIFIED) && !truncated() && !difficult() &&
bndbox().empty();
}
Object::Name Object::name() const
{
return name_;
}
void Object::setName(Name name)
{
name_ = name;
}
Object::Pose Object::pose() const
{
return pose_;
}
void Object::setPose(Pose pose)
{
pose_ = pose;
}
bool Object::truncated() const
{
return truncated_;
}
void Object::setTruncated(bool truncated)
{
truncated_ = truncated;
}
bool Object::difficult() const
{
return difficult_;
}
void Object::setDifficult(bool difficult)
{
difficult_ = difficult;
}
Rectangle Object::bndbox() const
{
return bndbox_;
}
void Object::setBndbox(Rectangle bndbox)
{
bndbox_ = bndbox;
}
ostream & FFLD::operator<<(ostream & os, const Object & obj)
{
return os << static_cast<int>(obj.name()) << ' ' << static_cast<int>(obj.pose()) << ' '
<< obj.truncated() << ' ' << obj.difficult() << ' ' << obj.bndbox();
}
istream & FFLD::operator>>(istream & is, Object & obj)
{
int name, pose;
bool truncated, difficult;
Rectangle bndbox;
is >> name >> pose >> truncated >> difficult >> bndbox;
if (!is) {
obj = Object();
return is;
}
obj.setName(static_cast<Object::Name>(name));
obj.setPose(static_cast<Object::Pose>(pose));
obj.setTruncated(truncated);
obj.setDifficult(difficult);
obj.setBndbox(bndbox);
return is;
}