mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-05 17:47:49 +08:00
CameraOrbbecSDK: harden capture path against crashes
- Fix a format-string crash: the "unexpected frame count" warning used %s with a uint32_t, dereferencing the integer as a char*. - Wrap captureImage() in try/catch(ob::Error) so a transient frame/USB error logs and skips the frame (empty SensorData) instead of aborting. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
8d55ce44f6
commit
e646b1cd79
@@ -612,13 +612,19 @@ SensorData CameraOrbbecSDK::captureImage(SensorCaptureInfo * info)
|
||||
UERROR("Camera is not initialized!");
|
||||
return data;
|
||||
}
|
||||
|
||||
// The streaming calls below can throw ob::Error (transient frame/USB
|
||||
// errors, filter or profile failures). Catch them so a bad frame is logged
|
||||
// and skipped (empty SensorData) instead of aborting the whole process.
|
||||
try {
|
||||
|
||||
auto frameset = pipeline_->waitForFrameset();
|
||||
if(frameset == nullptr || frameset->getCount() == 0) {
|
||||
UWARN("No frame received!");
|
||||
return data;
|
||||
}
|
||||
if(frameset->getCount() != 2) {
|
||||
UWARN("Received %s frames, expecting 2!", frameset->getCount());
|
||||
UWARN("Received %u frames, expecting 2!", frameset->getCount());
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -747,6 +753,13 @@ SensorData CameraOrbbecSDK::captureImage(SensorCaptureInfo * info)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch(const ob::Error & e)
|
||||
{
|
||||
UERROR("Error capturing Orbbec camera frame: %s", e.what());
|
||||
return data;
|
||||
}
|
||||
|
||||
#else
|
||||
UERROR("CameraOrbbecSDK: RTAB-Map is not built with Orbbec SDK support!");
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user