try again

This commit is contained in:
cyy_mac
2026-03-28 05:15:13 +08:00
parent ce707d2993
commit b2507afea9

View File

@@ -275,6 +275,15 @@ private:
// Apply ROI/offset before querying image info
applyRoiLocked();
// Force set pixel format to RGB8 every time camera opens
// This ensures camera doesn't fall back to default Mono8
int set_fmt_ret = MV_CC_SetEnumValue(camera_handle_, "PixelFormat", PixelType_Gvsp_RGB8_Packed);
if (set_fmt_ret != MV_OK) {
FYT_WARN("camera_driver", "Failed to set PixelFormat to RGB8: [0x{:x}], will use SDK conversion", set_fmt_ret);
} else {
FYT_INFO("camera_driver", "PixelFormat forced to RGB8");
}
// Set exposure / gain
(void)MV_CC_SetFloatValue(camera_handle_, "ExposureTime", static_cast<float>(exposure_time_));
(void)MV_CC_SetFloatValue(camera_handle_, "Gain", static_cast<float>(gain_));
@@ -369,6 +378,16 @@ private:
continue;
}
// Debug: log pixel format periodically (every 60 frames)
static int frame_count = 0;
frame_count++;
if (frame_count % 60 == 0) {
FYT_INFO("camera_driver", "Frame pixel_type=0x{:x}, size={}x{}",
out_frame.stFrameInfo.enPixelType,
out_frame.stFrameInfo.nWidth,
out_frame.stFrameInfo.nHeight);
}
// Ensure output buffer
const size_t need_size =
static_cast<size_t>(out_frame.stFrameInfo.nWidth) * out_frame.stFrameInfo.nHeight * 3;