feat: add AE/AWB lock test functionality and related services

This commit is contained in:
ob-yalian
2026-07-29 16:14:53 +08:00
parent e9bd942c1d
commit 84c1d4178d
12 changed files with 552 additions and 2 deletions
+90
View File
@@ -298,6 +298,27 @@ void OBCameraNode::setupCameraCtrlServices() {
std::shared_ptr<SetBool::Response> response) {
setAutoWhiteBalanceCallback(request, response);
});
if (isPropertyReadable(device_, OB_PROP_COLOR_AE_AWB_STAT_INT)) {
get_ae_awb_status_srv_ = node_->create_service<GetInt32>(
"get_color_ae_awb_status", [this](const std::shared_ptr<GetInt32::Request> request,
std::shared_ptr<GetInt32::Response> response) {
getAeAwbStatusCallback(request, response);
});
}
if (isPropertyReadable(device_, OB_STRUCT_COLOR_AWB_GAIN)) {
get_awb_gain_srv_ = node_->create_service<GetAwbGain>(
"get_color_awb_gain", [this](const std::shared_ptr<GetAwbGain::Request> request,
std::shared_ptr<GetAwbGain::Response> response) {
getAwbGainCallback(request, response);
});
}
if (isPropertyWritable(device_, OB_STRUCT_COLOR_AWB_GAIN)) {
set_awb_gain_srv_ = node_->create_service<SetAwbGain>(
"set_color_awb_gain", [this](const std::shared_ptr<SetAwbGain::Request> request,
std::shared_ptr<SetAwbGain::Response> response) {
setAwbGainCallback(request, response);
});
}
get_device_srv_ = node_->create_service<GetDeviceInfo>(
"get_device_info", [this](const std::shared_ptr<GetDeviceInfo::Request> request,
std::shared_ptr<GetDeviceInfo::Response> response) {
@@ -1198,6 +1219,75 @@ void OBCameraNode::setAutoWhiteBalanceCallback(const std::shared_ptr<SetBool::Re
}
}
void OBCameraNode::getAeAwbStatusCallback(const std::shared_ptr<GetInt32::Request>& request,
std::shared_ptr<GetInt32::Response>& response) {
(void)request;
try {
response->data = device_->getIntProperty(OB_PROP_COLOR_AE_AWB_STAT_INT);
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
} catch (...) {
response->success = false;
response->message = "unknown error";
}
}
void OBCameraNode::getAwbGainCallback(const std::shared_ptr<GetAwbGain::Request>& request,
std::shared_ptr<GetAwbGain::Response>& response) {
(void)request;
try {
OBAwbGainParams gain{};
uint32_t size = sizeof(gain);
device_->getStructuredData(OB_STRUCT_COLOR_AWB_GAIN, reinterpret_cast<uint8_t*>(&gain), &size);
response->r_gain = gain.rGain;
response->b_gain = gain.bGain;
response->g_gain = gain.gGain;
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
} catch (...) {
response->success = false;
response->message = "unknown error";
}
}
void OBCameraNode::setAwbGainCallback(const std::shared_ptr<SetAwbGain::Request>& request,
std::shared_ptr<SetAwbGain::Response>& response) {
try {
if (device_->getBoolProperty(OB_PROP_COLOR_AUTO_WHITE_BALANCE_BOOL)) {
response->success = false;
response->message = "auto white balance is enabled";
return;
}
OBAwbGainParams gain{};
gain.rGain = request->r_gain;
gain.bGain = request->b_gain;
gain.gGain = request->g_gain;
device_->setStructuredData(OB_STRUCT_COLOR_AWB_GAIN, reinterpret_cast<const uint8_t*>(&gain),
sizeof(gain));
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
} catch (...) {
response->success = false;
response->message = "unknown error";
}
}
void OBCameraNode::setAutoExposureCallback(
const std::shared_ptr<std_srvs::srv::SetBool::Request>& request,
std::shared_ptr<std_srvs::srv::SetBool::Response>& response,