mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Create VideoCamera base class and move camera settings functions to it.
This makes them available for both UsbCamera and HttpCamera / AxisCamera. To avoid virtual functions in the public-facing interface, move the implementation of the camera settings functions to the core library.
This commit is contained in:
@@ -42,6 +42,12 @@
|
||||
|
||||
using namespace cs;
|
||||
|
||||
static constexpr char const* kPropWbAuto = "white_balance_temperature_auto";
|
||||
static constexpr char const* kPropWbValue = "white_balance_temperature";
|
||||
static constexpr char const* kPropExAuto = "exposure_auto";
|
||||
static constexpr char const* kPropExValue = "exposure_absolute";
|
||||
static constexpr char const* kPropBrValue = "brightness";
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
// Conversions v4l2_fract time per frame from/to frames per second (fps)
|
||||
@@ -1139,6 +1145,51 @@ void UsbCameraImpl::SetStringProperty(int property, llvm::StringRef value,
|
||||
*status = SendAndWait(std::move(msg));
|
||||
}
|
||||
|
||||
void UsbCameraImpl::SetBrightness(int brightness, CS_Status* status) {
|
||||
if (brightness > 100) {
|
||||
brightness = 100;
|
||||
} else if (brightness < 0) {
|
||||
brightness = 0;
|
||||
}
|
||||
SetProperty(GetPropertyIndex(kPropBrValue), brightness, status);
|
||||
}
|
||||
|
||||
int UsbCameraImpl::GetBrightness(CS_Status* status) const {
|
||||
return GetProperty(GetPropertyIndex(kPropBrValue), status);
|
||||
}
|
||||
|
||||
void UsbCameraImpl::SetWhiteBalanceAuto(CS_Status* status) {
|
||||
SetProperty(GetPropertyIndex(kPropWbAuto), 1, status); // auto
|
||||
}
|
||||
|
||||
void UsbCameraImpl::SetWhiteBalanceHoldCurrent(CS_Status* status) {
|
||||
SetProperty(GetPropertyIndex(kPropWbAuto), 0, status); // manual
|
||||
}
|
||||
|
||||
void UsbCameraImpl::SetWhiteBalanceManual(int value, CS_Status* status) {
|
||||
SetProperty(GetPropertyIndex(kPropWbAuto), 0, status); // manual
|
||||
SetProperty(GetPropertyIndex(kPropWbValue), value, status);
|
||||
}
|
||||
|
||||
void UsbCameraImpl::SetExposureAuto(CS_Status* status) {
|
||||
// auto; yes, this is opposite of WB
|
||||
SetProperty(GetPropertyIndex(kPropExAuto), 0, status);
|
||||
}
|
||||
|
||||
void UsbCameraImpl::SetExposureHoldCurrent(CS_Status* status) {
|
||||
SetProperty(GetPropertyIndex(kPropExAuto), 1, status); // manual
|
||||
}
|
||||
|
||||
void UsbCameraImpl::SetExposureManual(int value, CS_Status* status) {
|
||||
SetProperty(GetPropertyIndex(kPropExAuto), 1, status); // manual
|
||||
if (value > 100) {
|
||||
value = 100;
|
||||
} else if (value < 0) {
|
||||
value = 0;
|
||||
}
|
||||
SetProperty(GetPropertyIndex(kPropExValue), value, status);
|
||||
}
|
||||
|
||||
bool UsbCameraImpl::SetVideoMode(const VideoMode& mode, CS_Status* status) {
|
||||
Message msg{Message::kCmdSetMode};
|
||||
msg.data[0] = mode.pixelFormat;
|
||||
|
||||
Reference in New Issue
Block a user