-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.h
192 lines (164 loc) · 4.46 KB
/
types.h
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
// File: types.h
// Author: Seongdo Kim
// Contact: [email protected]
//
// Copyright (c) 2017, Seongdo Kim <[email protected]>
// All rights reserved.
// The copyright to the computer program(s) herein is
// the property of Seongdo Kim. The program(s) may be
// used and/or copied only with the written permission
// of Seongdo Kim or in accordance with the terms and
// conditions stipulated in the agreement/contract under
// which the program(s) have been supplied.
//
// Written by Seongdo Kim <[email protected]>, June, 2017
#pragma once
#include <opencv2/opencv.hpp>
#include <boost/version.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/functional/hash.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
namespace seevider {
//--------------------------------
// Parking spot related constants
//--------------------------------
/**
* Parking spot status code
*/
enum PARKING_SPOT_STATUS {
PARKING_SPOT_STATUS_EMPTY, // Empty
PARKING_SPOT_STATUS_OCCUPIED, // Occupied
PARKING_SPOT_STATUS_UNAVAILABLE, // Spot is unavailble
PARKING_SPOT_STATUS_USER // User-defined status
};
/**
* Policy of each parking spot
*/
enum PARKING_SPOT_POLICY {
POLICY_FORBIDDEN, // Forbidden spot
POLICY_TIMED, // Timed spot.
POLICY_UNLIMITED, // Unlimited parkable spot
POLICY_ACCESSIBLE, // Accessible parking
POLICY_DISABLED // Distable parking spot, e.g., under construction
};
//--------------------------------
// Server communication constants
//--------------------------------
/**
* Information of a server destination for each request type.
*/
struct ServerDestinations_t {
/**
* HTTP request type
*/
int RequestType;
/**
* Target pathes on the host side
*/
std::string TargetPath;
/**
* HTTP request method
*/
std::string HTTPRequestMethod; // Either POST or PUT
};
/**
* HTTP request types
*/
enum HTTP_REQ_TYPE {
HTTP_REQ_SYNC_GENERAL, // Synchronization request from a sensor to the server
HTTP_REQ_UPDATE_ENTER, // A vehicle entered to a parking spot
HTTP_REQ_UPDATE_EXIT, // A vehicle exited from a parking spot
HTTP_REQ_UPDATE_OVER // A vehicle overstayed at a parking spot
};
enum CLASSIFIER_TYPE {
CLASSIFIER_CASCADE = 0, // cascade classifier
CLASSIFIER_CNN // convolutional nueral network
};
//--------------------------
// Arrays
//--------------------------
static const std::string CLASSIFIER_TYPE_STRING[] = { "cascade", "cnn" };
//--------------------------
// Structures
//--------------------------
/**
* Structure to suspend the receiving thread
*/
struct MutualConditionVariable {
/**
* Abling and disabling the management mode.
* While this value is true, the system will not detect the vehicle and
* wait for receiving the update from the manager.
*/
bool ManagementMode = false;
/**
* Conditional variable for the requesting thread
*/
boost::condition_variable SenderCV;
/**
* Conditional variable for the thread to be suspended
*/
boost::condition_variable ReceiverCV;
/**
* Mutex to ensure atomic operations at the entrance of the management mode
*/
boost::mutex MutexEntrace;
/**
* Mutex to wait the update
*/
boost::mutex MutexExit;
};
/**
ROI Callback data to communicate with the preview window
*/
struct ROISettingCallbackData {
cv::Mat image;
cv::String window_name;
int roi_x0 = 0;
int roi_y0 = 0;
int roi_x1 = 0;
int roi_y1 = 0;
bool start_draw = false;
bool roi_set = false;
};
/**
* Defines custom hash functions for the use of unordered_map
*/
struct CustomHash {
std::size_t operator()(const boost::posix_time::ptime& lhs) const {
std::size_t seed = 0;
boost::hash_combine(seed, lhs.date().day().as_number());
boost::hash_combine(seed, lhs.time_of_day().total_seconds());
return seed;
}
};
/**
* Structure for saving parameters of parking sensor
*/
struct ParkingParams {
int sensitivity;
int enterCount;
int exitCount;
};
/**
* Folder name containing the core data
*/
const std::string SYSTEM_FOLDER_CORE = "./core/";
/**
* Folder name containing
*/
const std::string SYSTEM_FOLDER_LOG = "./log/";
/**
* Filename to save parking spots
*/
const std::string SYSTEM_FILE_PARKINGSPOTS = "parkingspots.json";
/**
* Boost major version
*/
#define BOOST_VERSION_MAJOR BOOST_VERSION / 100000
/**
* Boost minor version
*/
#define BOOST_VERSION_MINOR BOOST_VERSION / 100 % 1000
}