blob: e5816eed780711587e249f9c90622103b19ef5e1 [file] [log] [blame]
jerrymf1579332013-02-07 01:56:28 +00001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
5/*----------------------------------------------------------------------------*/
6
7#ifndef __AXIS_CAMERA_PARAMS_H__
8#define __AXIS_CAMERA_PARAMS_H__
9
10#include "EnumCameraParameter.h"
11#include "ErrorBase.h"
12#include "IntCameraParameter.h"
13#include "Task.h"
14#include <vector>
15
16/**
17 * AxisCameraParams class.
18 * This class handles parameter configuration the Axis 206 Ethernet Camera.
19 * It starts up a tasks with an independent connection to the camera that monitors
20 * for changes to parameters and updates the camera.
21 * It is only separate from AxisCamera to isolate the parameter code from the image streaming code.
22 */
23class AxisCameraParams : public ErrorBase
24{
25public:
26 typedef enum Exposure_t {kExposure_Automatic, kExposure_Hold, kExposure_FlickerFree50Hz, kExposure_FlickerFree60Hz};
27 typedef enum WhiteBalance_t {kWhiteBalance_Automatic, kWhiteBalance_Hold, kWhiteBalance_FixedOutdoor1, kWhiteBalance_FixedOutdoor2, kWhiteBalance_FixedIndoor, kWhiteBalance_FixedFlourescent1, kWhiteBalance_FixedFlourescent2};
28 typedef enum Resolution_t {kResolution_640x480, kResolution_640x360, kResolution_320x240, kResolution_160x120};
29 typedef enum Rotation_t {kRotation_0, kRotation_180};
30
31protected:
32 AxisCameraParams(const char* ipAddress);
33 virtual ~AxisCameraParams();
34
35public:
36 // Mid-stream gets & writes
37 void WriteBrightness(int);
38 int GetBrightness();
39 void WriteWhiteBalance(WhiteBalance_t whiteBalance);
40 WhiteBalance_t GetWhiteBalance();
41 void WriteColorLevel(int);
42 int GetColorLevel();
43 void WriteExposureControl(Exposure_t);
44 Exposure_t GetExposureControl();
45 void WriteExposurePriority(int);
46 int GetExposurePriority();
47 void WriteMaxFPS(int);
48 int GetMaxFPS();
49
50 // New-Stream gets & writes (i.e. require restart)
51 void WriteResolution(Resolution_t);
52 Resolution_t GetResolution();
53 void WriteCompression(int);
54 int GetCompression();
55 void WriteRotation(Rotation_t);
56 Rotation_t GetRotation();
57
58protected:
59 virtual void RestartCameraTask() = 0;
60 int CreateCameraSocket(const char *requestString);
61
62 static int s_ParamTaskFunction(AxisCameraParams* thisPtr);
63 int ParamTaskFunction();
64
65 int UpdateCamParam(const char *param);
66 int ReadCamParams();
67
68 Task m_paramTask;
69 UINT32 m_ipAddress; // IPv4
70 SEM_ID m_paramChangedSem;
71 SEM_ID m_socketPossessionSem;
72
73 //Camera Properties
74 IntCameraParameter *m_brightnessParam;
75 IntCameraParameter *m_compressionParam;
76 IntCameraParameter *m_exposurePriorityParam;
77 IntCameraParameter *m_colorLevelParam;
78 IntCameraParameter *m_maxFPSParam;
79 EnumCameraParameter *m_rotationParam;
80 EnumCameraParameter *m_resolutionParam;
81 EnumCameraParameter *m_exposureControlParam;
82 EnumCameraParameter *m_whiteBalanceParam;
83
84 // A vector to access all properties simply.
85 typedef std::vector<IntCameraParameter*> ParameterVector_t;
86 ParameterVector_t m_parameters;
87};
88
89
90#endif