mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
This is a major restructuring of the WPILib repository to simply build procedures and remove the remnants of Maven from everything except the eclipse plugins. Gradle files have been largely simplified or rewritten, taking advantage of splitting up parts of the build into separate build files for ease of reading. The eclipse plugins are now in a separate project, as is ntcore. All dependencies are resolved via Maven dependencies, with the Jenkins-maintained WPILib repo. Project structures have also been simplified: we no longer have separate subprojects inside wpilibc and wpilibj. Where possible, these changes hav been done with git renames, to make sure we still have full history for all repositories. Other unrelated subprojects have also been broken out: OutlineViewer is now a separate project. Change-Id: Ib4e2a6e1a2f66427a14f16612b0e0d69ed661878
123 lines
3.2 KiB
C++
123 lines
3.2 KiB
C++
/*----------------------------------------------------------------------------*/
|
|
/* Copyright (c) FIRST 2014. All Rights Reserved. */
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
#pragma once
|
|
|
|
#include <thread>
|
|
#include <string>
|
|
#include "HAL/cpp/priority_mutex.h"
|
|
|
|
#include "ErrorBase.h"
|
|
#include "Vision/ColorImage.h"
|
|
#include "Vision/HSLImage.h"
|
|
#include "nivision.h"
|
|
|
|
/**
|
|
* Axis M1011 network camera
|
|
*/
|
|
class AxisCamera : public ErrorBase {
|
|
public:
|
|
enum WhiteBalance {
|
|
kWhiteBalance_Automatic,
|
|
kWhiteBalance_Hold,
|
|
kWhiteBalance_FixedOutdoor1,
|
|
kWhiteBalance_FixedOutdoor2,
|
|
kWhiteBalance_FixedIndoor,
|
|
kWhiteBalance_FixedFluorescent1,
|
|
kWhiteBalance_FixedFluorescent2
|
|
};
|
|
|
|
enum ExposureControl {
|
|
kExposureControl_Automatic,
|
|
kExposureControl_Hold,
|
|
kExposureControl_FlickerFree50Hz,
|
|
kExposureControl_FlickerFree60Hz
|
|
};
|
|
|
|
enum Resolution {
|
|
kResolution_640x480,
|
|
kResolution_480x360,
|
|
kResolution_320x240,
|
|
kResolution_240x180,
|
|
kResolution_176x144,
|
|
kResolution_160x120,
|
|
};
|
|
|
|
enum Rotation { kRotation_0, kRotation_180 };
|
|
|
|
explicit AxisCamera(std::string const &cameraHost);
|
|
virtual ~AxisCamera();
|
|
|
|
AxisCamera(const AxisCamera&) = delete;
|
|
AxisCamera& operator=(const AxisCamera&) = delete;
|
|
|
|
bool IsFreshImage() const;
|
|
|
|
int GetImage(Image *image);
|
|
int GetImage(ColorImage *image);
|
|
HSLImage *GetImage();
|
|
int CopyJPEG(char **destImage, unsigned int &destImageSize,
|
|
unsigned int &destImageBufferSize);
|
|
|
|
void WriteBrightness(int brightness);
|
|
int GetBrightness();
|
|
|
|
void WriteWhiteBalance(WhiteBalance whiteBalance);
|
|
WhiteBalance GetWhiteBalance();
|
|
|
|
void WriteColorLevel(int colorLevel);
|
|
int GetColorLevel();
|
|
|
|
void WriteExposureControl(ExposureControl exposureControl);
|
|
ExposureControl GetExposureControl();
|
|
|
|
void WriteExposurePriority(int exposurePriority);
|
|
int GetExposurePriority();
|
|
|
|
void WriteMaxFPS(int maxFPS);
|
|
int GetMaxFPS();
|
|
|
|
void WriteResolution(Resolution resolution);
|
|
Resolution GetResolution();
|
|
|
|
void WriteCompression(int compression);
|
|
int GetCompression();
|
|
|
|
void WriteRotation(Rotation rotation);
|
|
Rotation GetRotation();
|
|
|
|
private:
|
|
std::thread m_captureThread;
|
|
std::string m_cameraHost;
|
|
int m_cameraSocket = -1;
|
|
priority_mutex m_captureMutex;
|
|
|
|
priority_mutex m_imageDataMutex;
|
|
std::vector<uint8_t> m_imageData;
|
|
bool m_freshImage = false;
|
|
|
|
int m_brightness = 50;
|
|
WhiteBalance m_whiteBalance = kWhiteBalance_Automatic;
|
|
int m_colorLevel = 50;
|
|
ExposureControl m_exposureControl = kExposureControl_Automatic;
|
|
int m_exposurePriority = 50;
|
|
int m_maxFPS = 0;
|
|
Resolution m_resolution = kResolution_640x480;
|
|
int m_compression = 50;
|
|
Rotation m_rotation = kRotation_0;
|
|
bool m_parametersDirty = true;
|
|
bool m_streamDirty = true;
|
|
priority_mutex m_parametersMutex;
|
|
|
|
bool m_done = false;
|
|
|
|
void Capture();
|
|
void ReadImagesFromCamera();
|
|
bool WriteParameters();
|
|
|
|
int CreateCameraSocket(std::string const &requestString, bool setError);
|
|
};
|