From 1a29daee6040f22b0e141e2c5632c10b4cda410b Mon Sep 17 00:00:00 2001 From: alopez <alopez@iri.upc.edu> Date: Wed, 15 Sep 2021 17:05:30 +0200 Subject: [PATCH] Added a piece of code to handle smaller than expected image frames. The frame is lost, but at least the node does not crash. --- libuvc_camera/src/camera_driver.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libuvc_camera/src/camera_driver.cpp b/libuvc_camera/src/camera_driver.cpp index aa4abce..4878060 100644 --- a/libuvc_camera/src/camera_driver.cpp +++ b/libuvc_camera/src/camera_driver.cpp @@ -167,6 +167,12 @@ void CameraDriver::ImageCallback(uvc_frame_t *frame) { timestamp = ros::Time::now(); } + if(frame->data_bytes<frame->step*frame->height) + { + std::cout << "short frame" << std::endl; + return; + } + boost::recursive_mutex::scoped_lock lock(mutex_); assert(state_ == kRunning); -- GitLab