WPILib 2012
WPILibRoboticsLibraryforFRC
Vision/AxisCameraParams.h
00001 /*----------------------------------------------------------------------------*/
00002 /* Copyright (c) FIRST 2008. All Rights Reserved.                                                         */
00003 /* Open Source Software - may be modified and shared by FRC teams. The code   */
00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib.  */
00005 /*----------------------------------------------------------------------------*/
00006 
00007 #ifndef __AXIS_CAMERA_PARAMS_H__
00008 #define __AXIS_CAMERA_PARAMS_H__
00009 
00010 #include "EnumCameraParameter.h"
00011 #include "ErrorBase.h"
00012 #include "IntCameraParameter.h"
00013 #include "Task.h"
00014 #include <vector>
00015 
00023 class AxisCameraParams : public ErrorBase
00024 {
00025 public:
00026         typedef enum Exposure_t {kExposure_Automatic, kExposure_Hold, kExposure_FlickerFree50Hz, kExposure_FlickerFree60Hz};
00027         typedef enum WhiteBalance_t {kWhiteBalance_Automatic, kWhiteBalance_Hold, kWhiteBalance_FixedOutdoor1, kWhiteBalance_FixedOutdoor2, kWhiteBalance_FixedIndoor, kWhiteBalance_FixedFlourescent1, kWhiteBalance_FixedFlourescent2};
00028         typedef enum Resolution_t {kResolution_640x480, kResolution_640x360, kResolution_320x240, kResolution_160x120};
00029         typedef enum Rotation_t {kRotation_0, kRotation_180};
00030 
00031 protected:
00032         AxisCameraParams(const char* ipAddress);
00033         virtual ~AxisCameraParams();
00034 
00035 public:
00036         // Mid-stream gets & writes
00037         void WriteBrightness(int);
00038         int GetBrightness();
00039         void WriteWhiteBalance(WhiteBalance_t whiteBalance);
00040         WhiteBalance_t GetWhiteBalance();
00041         void WriteColorLevel(int);
00042         int GetColorLevel();
00043         void WriteExposureControl(Exposure_t);
00044         Exposure_t GetExposureControl();
00045         void WriteExposurePriority(int);
00046         int GetExposurePriority();
00047         void WriteMaxFPS(int);
00048         int GetMaxFPS();
00049 
00050         // New-Stream gets & writes (i.e. require restart)
00051         void WriteResolution(Resolution_t);
00052         Resolution_t GetResolution();
00053         void WriteCompression(int);
00054         int GetCompression();
00055         void WriteRotation(Rotation_t);
00056         Rotation_t GetRotation();
00057 
00058 protected:
00059         virtual void RestartCameraTask() = 0;
00060         int CreateCameraSocket(const char *requestString);
00061 
00062         static int s_ParamTaskFunction(AxisCameraParams* thisPtr);
00063         int ParamTaskFunction();
00064 
00065         int UpdateCamParam(const char *param);
00066         int ReadCamParams();
00067 
00068         Task m_paramTask;
00069         UINT32 m_ipAddress; // IPv4
00070         SEM_ID m_paramChangedSem;
00071         SEM_ID m_socketPossessionSem;
00072 
00073         //Camera Properties
00074         IntCameraParameter *m_brightnessParam;
00075         IntCameraParameter *m_compressionParam;
00076         IntCameraParameter *m_exposurePriorityParam;
00077         IntCameraParameter *m_colorLevelParam;
00078         IntCameraParameter *m_maxFPSParam;
00079         EnumCameraParameter *m_rotationParam;
00080         EnumCameraParameter *m_resolutionParam;
00081         EnumCameraParameter *m_exposureControlParam;
00082         EnumCameraParameter *m_whiteBalanceParam;
00083 
00084         // A vector to access all properties simply.
00085         typedef std::vector<IntCameraParameter*> ParameterVector_t;
00086         ParameterVector_t m_parameters;
00087 };
00088 
00089 
00090 #endif
 All Classes Functions Variables