Fix PS3Eye exposure setting (#1911)

This commit is contained in:
Banks T
2019-09-30 18:09:39 -04:00
committed by Peter Johnson
parent 885744d7e1
commit 2271570860
2 changed files with 33 additions and 6 deletions

View File

@@ -108,6 +108,11 @@ static bool IsPercentageProperty(wpi::StringRef name) {
static constexpr const int quirkLifeCamHd3000[] = {
5, 10, 20, 39, 78, 156, 312, 625, 1250, 2500, 5000, 10000, 20000};
static constexpr char const* quirkPS3EyePropExAuto = "auto_exposure";
static constexpr char const* quirkPS3EyePropExValue = "exposure";
static constexpr const int quirkPS3EyePropExAutoOn = 0;
static constexpr const int quirkPS3EyePropExAutoOff = 1;
int UsbCameraImpl::RawToPercentage(const UsbCameraProperty& rawProp,
int rawValue) {
// LifeCam exposure setting quirk
@@ -1149,6 +1154,7 @@ void UsbCameraImpl::SetQuirks() {
wpi::StringRef desc = GetDescription(descbuf);
m_lifecam_exposure =
desc.endswith("LifeCam HD-3000") || desc.endswith("LifeCam Cinema (TM)");
m_ps3eyecam_exposure = desc.endswith("Camera-B4.04.27.1");
}
void UsbCameraImpl::SetProperty(int property, int value, CS_Status* status) {
@@ -1194,21 +1200,41 @@ void UsbCameraImpl::SetWhiteBalanceManual(int value, CS_Status* status) {
void UsbCameraImpl::SetExposureAuto(CS_Status* status) {
// auto; this is an enum value
SetProperty(GetPropertyIndex(kPropExAuto), 3, status);
if (m_ps3eyecam_exposure) {
SetProperty(GetPropertyIndex(quirkPS3EyePropExAuto),
quirkPS3EyePropExAutoOn, status);
} else {
SetProperty(GetPropertyIndex(kPropExAuto), 3, status);
}
}
void UsbCameraImpl::SetExposureHoldCurrent(CS_Status* status) {
SetProperty(GetPropertyIndex(kPropExAuto), 1, status); // manual
if (m_ps3eyecam_exposure) {
SetProperty(GetPropertyIndex(quirkPS3EyePropExAuto),
quirkPS3EyePropExAutoOff, status); // manual
} else {
SetProperty(GetPropertyIndex(kPropExAuto), 1, status); // manual
}
}
void UsbCameraImpl::SetExposureManual(int value, CS_Status* status) {
SetProperty(GetPropertyIndex(kPropExAuto), 1, status); // manual
if (m_ps3eyecam_exposure) {
SetProperty(GetPropertyIndex(quirkPS3EyePropExAuto),
quirkPS3EyePropExAutoOff, status); // manual
} else {
SetProperty(GetPropertyIndex(kPropExAuto), 1, status); // manual
}
if (value > 100) {
value = 100;
} else if (value < 0) {
value = 0;
}
SetProperty(GetPropertyIndex(kPropExValue), value, status);
if (m_ps3eyecam_exposure) {
SetProperty(GetPropertyIndex(quirkPS3EyePropExValue), value, status);
} else {
SetProperty(GetPropertyIndex(kPropExValue), value, status);
}
}
bool UsbCameraImpl::SetVideoMode(const VideoMode& mode, CS_Status* status) {

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. 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 the root directory of */
/* the project. */
@@ -164,7 +164,8 @@ class UsbCameraImpl : public SourceImpl {
std::thread m_cameraThread;
// Quirks
bool m_lifecam_exposure{false}; // Microsoft LifeCam exposure
bool m_lifecam_exposure{false}; // Microsoft LifeCam exposure
bool m_ps3eyecam_exposure{false}; // PS3 Eyecam exposure
//
// Variables protected by m_mutex