diff --git a/src/rm_hardware_driver/ros2_hik_camera/src/hik_camera_node.cpp b/src/rm_hardware_driver/ros2_hik_camera/src/hik_camera_node.cpp index d7c92ff..15e6435 100644 --- a/src/rm_hardware_driver/ros2_hik_camera/src/hik_camera_node.cpp +++ b/src/rm_hardware_driver/ros2_hik_camera/src/hik_camera_node.cpp @@ -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(exposure_time_)); (void)MV_CC_SetFloatValue(camera_handle_, "Gain", static_cast(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(out_frame.stFrameInfo.nWidth) * out_frame.stFrameInfo.nHeight * 3;