-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRobotCamera.cpp
99 lines (89 loc) · 1.82 KB
/
RobotCamera.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
#include "RobotCamera.h"
#include "vxWorks.h"
#include "Vision/AxisCamera.h"
#include "Timer.h"
#include <cstdlib>
RoboCam::RoboCam()
: cam(NULL)
{
//Stuff
}
void RoboCam::Initialize()
{
/*
//wait_timer = new Timer();
//wait_timer->Start();
//Initializing camera operations
cam = &AxisCamera::GetInstance();
//printf("Setting camera parameters\n");
//sets the camera image compression
cam->WriteCompression(0); // valid values 0 – 100
//Sets the camera resolution
//original resolution k320X240
//cam->WriteResolution(AxisCamera::kResolution_160x120);
//cam->WriteResolution(AxisCamera::kResolution_640x480);
cam->WriteResolution(AxisCamera::kResolution_320x240);
cam->WriteBrightness(0);*/
}
void RoboCam::Track()
{
//Camera Tracking
// RefreshCamera();
}
void RoboCam::SetTrackPeriod(double p)
{
/*
if (p < 0.01 || p >= 1)
return;
per = p;
*/
}
void RoboCam::Process()
{
/*
if (wait_timer->HasPeriodPassed(per))
{
//Makes the cameraclass do stuff
Track();
wait_timer->Reset();
}
*/
}
std::vector<Target> RoboCam::GetTargets()
{
return Target::FindCircularTargets(cam->GetImage());
}
void RoboCam::RefreshCamera()
{
if (cam->IsFreshImage())
{
ColorImage *image = cam->GetImage();
if (image == NULL)
{
// don't do anything
// Something wrong with the camera
}
else
{
targets = Target::FindCircularTargets(image);
//Be sure to clean up your mess after you are done...
delete image;
}
}
}
float RoboCam::GetDistance()
{
//Gets the distance of the target from the camera
return 0;
}
float RoboCam::GetLocation()
{
//Gets the location of the target in the image
/* if (targets.size() != 0)
{
return targets[0].GetHorizontalAngle();
} else {
return 0;
}*/
return 0.0;
}