-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera.cpp
More file actions
46 lines (37 loc) · 989 Bytes
/
Camera.cpp
File metadata and controls
46 lines (37 loc) · 989 Bytes
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
/*
* @author:
* @lead: Andrew Horsman
* @awesome: Mike Noseworthy
* @description: Code that controls the camera feed.
*/
#include "Headers/StateMachine.h"
#include "Headers/WPILibrary.h"
class EasyCamera {
StateMachine cameraFeedState;
// State constants.
static const int SUBMIT_FRAME = 1;
public:
EasyCamera():
cameraFeedState()
{
AxisCamera &camera = AxisCamera::GetInstance();
camera.WriteResolution(AxisCamera::kResolution_320x240);
camera.WriteCompression(0);
camera.WriteBrightness(0);
cameraFeedState.RegisterState(SUBMIT_FRAME, 1);
}
HSLImage GetImage() {
int i = cameraFeedState.GetCurrentState(SUBMIT_FRAME);
if (i == 3) {
cameraFeedState.ResetState(SUBMIT_FRAME);
AxisCamera &camera = AxisCamera::GetInstance();
if (camera.IsFreshImage()) {
HSLImage *image = camera.GetImage();
return *image;
}
} else {
cameraFeedState.ChangeState(SUBMIT_FRAME, i + 1);
}
return NULL;
}
};