fix: accept raw full-frame image dimensions

This commit is contained in:
Ben 2026-08-26 11:23:59 +08:00
parent 3cae03037b
commit 7bf543ec0a
2 changed files with 12 additions and 24 deletions

View File

@ -1055,17 +1055,6 @@ bool VizumCamera::CaptureFullFrameLeftImage(SLImage& image, std::string& frameId
return false; return false;
} }
SVzVideoResolution resolution{};
ret = VzNL_GetResolution(m_deviceHandle, &resolution);
if (ret != 0 || resolution.nFrameWidth == 0 || resolution.nFrameHeight == 0) {
char errorMsg[256] = {0};
VzNL_GetErrorInfo(ret, errorMsg);
LOG_ERROR("[VizumCamera] Full-frame capture cannot read device resolution: {} "
"(error code: {}, size={}x{})", errorMsg, ret,
resolution.nFrameWidth, resolution.nFrameHeight);
return false;
}
OutputRoiModeRestoreGuard outputModeGuard(m_deviceHandle); OutputRoiModeRestoreGuard outputModeGuard(m_deviceHandle);
if (!outputModeGuard.IsReady()) if (!outputModeGuard.IsReady())
return false; return false;
@ -1091,16 +1080,15 @@ bool VizumCamera::CaptureFullFrameLeftImage(SLImage& image, std::string& frameId
const bool rightReleased = rightImageGuard.ReleaseNow(); const bool rightReleased = rightImageGuard.ReleaseNow();
const bool imagesReleased = leftReleased && rightReleased; const bool imagesReleased = leftReleased && rightReleased;
const bool exactFullFrame = converted // CalibROI=false returns the raw eye frame (for example 1216x1920), while
&& image.originX == 0 && image.originY == 0 // VzNL_GetResolution may report the calibrated output canvas (for example
&& image.width == resolution.nFrameWidth // 1336x2115). They are different coordinate spaces and must not be compared.
&& image.height == resolution.nFrameHeight; const bool validFullFrame = converted && !image.empty()
if (converted && !exactFullFrame) { && image.originX == 0 && image.originY == 0;
LOG_ERROR("[VizumCamera] SDK output-mode switch did not return an exact full frame; " if (converted && !validFullFrame) {
"capture rejected without zero-padding: image={}x{} origin=({}, {}), " LOG_ERROR("[VizumCamera] Raw full-frame image has an invalid origin or empty payload: "
"device={}x{}", "image={}x{} origin=({}, {})",
image.width, image.height, image.originX, image.originY, image.width, image.height, image.originX, image.originY);
resolution.nFrameWidth, resolution.nFrameHeight);
} }
const bool imageModesRestored = outputModeGuard.RestoreNow(); const bool imageModesRestored = outputModeGuard.RestoreNow();
@ -1135,7 +1123,7 @@ bool VizumCamera::CaptureFullFrameLeftImage(SLImage& image, std::string& frameId
currentRightROI.top, currentRightROI.bottom); currentRightROI.top, currentRightROI.bottom);
} }
if (!exactFullFrame || !imagesReleased || !imageModesRestored || !roiUnchanged) { if (!validFullFrame || !imagesReleased || !imageModesRestored || !roiUnchanged) {
image.clear(); image.clear();
return false; return false;
} }

View File

@ -129,9 +129,9 @@ public:
/** /**
* @brief 不修改检测 ROI,临时关闭 CalibROI/ROI输出并采集真实全幅左目图像 * @brief 不修改检测 ROI,临时关闭 CalibROI/ROI输出并采集真实全幅左目图像
* @param[out] image SDK 原始返回的设备全分辨率图像(原点必须为(0,0)) * @param[out] image SDK 原始返回的全幅眼图(CalibROI=false 坐标系,原点必须为(0,0))
* @param[out] frameId 本次采集帧编号 * @param[out] frameId 本次采集帧编号
* @return 采集、SDK 图像释放、精确全幅校验、模式恢复及检测 ROI 未变化校验是否全部成功 * @return 采集、SDK 图像释放、全幅原点校验、模式恢复及检测 ROI 未变化校验是否全部成功
* @note 检测 ROI 始终只读;任何失败路径都会恢复原 CalibROI 和 ROI 图输出模式 * @note 检测 ROI 始终只读;任何失败路径都会恢复原 CalibROI 和 ROI 图输出模式
*/ */
bool CaptureFullFrameLeftImage(SLImage& image, std::string& frameId); bool CaptureFullFrameLeftImage(SLImage& image, std::string& frameId);