-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoloredobject.hpp
More file actions
59 lines (47 loc) · 1.24 KB
/
coloredobject.hpp
File metadata and controls
59 lines (47 loc) · 1.24 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
55
56
57
58
59
#pragma once
#include <iostream>
#include <fstream>
#include <array>
#include <opencv2/imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
class ColoredObject
{
public:
ColoredObject(int ID, int x, int y, Mat* frameHSV, int hTol=10, int sTol=20, int vTol=20); // Construct object from coordinates. Optionally specify HSV tolerances
bool tick(void); // Call once per frame to update location. Returns whether the object was found in the image
Point getLocation(void);
Rect getBoundingRect(void);
void print(void);
void terminate(void);
private:
int ID;
Mat* frame;
string directory;
array<int,2> lastLoc;
array<int,2> loc;
string locFile;
array<int,2> lastSpeed;
array<int,2> speed;
string speedFile;
array<int,2> lastAccel;
array<int,2> accel;
string accelFile;
array<int,2> deltaAccel;
array<int,2> predictedLoc;
Rect br; // Bounding rectangle
array<int,3> color;
array<int,3> hsvTol;
array<int,3> lower0;
array<int,3> upper0;
int lowerh1;
int upperh1;
void calcTolerances(void);
vector<vector<Point>> getContours(void);
int chooseContour(vector<vector<Point>>* contours);
void updateLoc(void);
void updateSpeed(void);
void updateAccel(void);
void updateDeltaAccel(void);
void predictNextLocation(void);
};