From 7bf543ec0acea20b013d2c5fe7844711bb6adfef Mon Sep 17 00:00:00 2001 From: Ben <987807597@qq.com> Date: Wed, 26 Aug 2026 11:23:59 +0800 Subject: [PATCH] fix: accept raw full-frame image dimensions --- src/VizumCamera.cpp | 32 ++++++++++---------------------- src/VizumCamera.h | 4 ++-- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/VizumCamera.cpp b/src/VizumCamera.cpp index 4676f06..b821186 100755 --- a/src/VizumCamera.cpp +++ b/src/VizumCamera.cpp @@ -1055,17 +1055,6 @@ bool VizumCamera::CaptureFullFrameLeftImage(SLImage& image, std::string& frameId 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); if (!outputModeGuard.IsReady()) return false; @@ -1091,16 +1080,15 @@ bool VizumCamera::CaptureFullFrameLeftImage(SLImage& image, std::string& frameId const bool rightReleased = rightImageGuard.ReleaseNow(); const bool imagesReleased = leftReleased && rightReleased; - const bool exactFullFrame = converted - && image.originX == 0 && image.originY == 0 - && image.width == resolution.nFrameWidth - && image.height == resolution.nFrameHeight; - if (converted && !exactFullFrame) { - LOG_ERROR("[VizumCamera] SDK output-mode switch did not return an exact full frame; " - "capture rejected without zero-padding: image={}x{} origin=({}, {}), " - "device={}x{}", - image.width, image.height, image.originX, image.originY, - resolution.nFrameWidth, resolution.nFrameHeight); + // CalibROI=false returns the raw eye frame (for example 1216x1920), while + // VzNL_GetResolution may report the calibrated output canvas (for example + // 1336x2115). They are different coordinate spaces and must not be compared. + const bool validFullFrame = converted && !image.empty() + && image.originX == 0 && image.originY == 0; + if (converted && !validFullFrame) { + LOG_ERROR("[VizumCamera] Raw full-frame image has an invalid origin or empty payload: " + "image={}x{} origin=({}, {})", + image.width, image.height, image.originX, image.originY); } const bool imageModesRestored = outputModeGuard.RestoreNow(); @@ -1135,7 +1123,7 @@ bool VizumCamera::CaptureFullFrameLeftImage(SLImage& image, std::string& frameId currentRightROI.top, currentRightROI.bottom); } - if (!exactFullFrame || !imagesReleased || !imageModesRestored || !roiUnchanged) { + if (!validFullFrame || !imagesReleased || !imageModesRestored || !roiUnchanged) { image.clear(); return false; } diff --git a/src/VizumCamera.h b/src/VizumCamera.h index e36eecc..4f40bfd 100755 --- a/src/VizumCamera.h +++ b/src/VizumCamera.h @@ -129,9 +129,9 @@ public: /** * @brief 不修改检测 ROI,临时关闭 CalibROI/ROI输出并采集真实全幅左目图像 - * @param[out] image SDK 原始返回的设备全分辨率图像(原点必须为(0,0)) + * @param[out] image SDK 原始返回的全幅眼图(CalibROI=false 坐标系,原点必须为(0,0)) * @param[out] frameId 本次采集帧编号 - * @return 采集、SDK 图像释放、精确全幅校验、模式恢复及检测 ROI 未变化校验是否全部成功 + * @return 采集、SDK 图像释放、全幅原点校验、模式恢复及检测 ROI 未变化校验是否全部成功 * @note 检测 ROI 始终只读;任何失败路径都会恢复原 CalibROI 和 ROI 图输出模式 */ bool CaptureFullFrameLeftImage(SLImage& image, std::string& frameId);