Skip to content

Commit

Permalink
validating empty camera images
Browse files Browse the repository at this point in the history
  • Loading branch information
klaxalk committed Jul 23, 2024
1 parent 818e9db commit 7a1692f
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/unreal_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,12 @@ void UnrealSimulator::timerRgb([[maybe_unused]] const ros::TimerEvent& event) {
last_rgb_ue_stamp_.at(i) = stamp;

if (!res) {
ROS_ERROR("[UnrealSimulator]: failed to obtain rgb camera from uav%lu", i + 1);
ROS_WARN("[UnrealSimulator]: failed to obtain rgb camera from uav%lu", i + 1);
continue;
}

if (cameraData.empty()) {
ROS_WARN("[UnrealSimulator]: rgb camera from uav%lu is empty!", i + 1);
continue;
}

Expand Down Expand Up @@ -1138,7 +1143,12 @@ void UnrealSimulator::timerStereo([[maybe_unused]] const ros::TimerEvent& event)
last_stereo_ue_stamp_.at(i) = stamp;

if (!res) {
ROS_ERROR("[UnrealSimulator]: failed to obtain stereo camera from uav%lu", i + 1);
ROS_WARN("[UnrealSimulator]: failed to obtain stereo camera from uav%lu", i + 1);
continue;
}

if (image_left.empty() || image_right.empty()) {
ROS_WARN("[UnrealSimulator]: stereo camera data from uav%lu is empty!", i + 1);
continue;
}

Expand Down Expand Up @@ -1219,6 +1229,16 @@ void UnrealSimulator::timerRgbSegmented([[maybe_unused]] const ros::TimerEvent&

last_rgb_seg_ue_stamp_.at(i) = stamp;

if (!res) {
ROS_WARN("[UnrealSimulator]: failed to obtain rgb camera from uav%lu", i + 1);
continue;
}

if (cameraData.empty()) {
ROS_WARN("[UnrealSimulator]: rgb segmented camera from uav%lu is empty!", i + 1);
continue;
}

cv::Mat image = cv::imdecode(cameraData, cv::IMREAD_COLOR);

sensor_msgs::ImagePtr msg = cv_bridge::CvImage(std_msgs::Header(), "bgr8", image).toImageMsg();
Expand Down

0 comments on commit 7a1692f

Please sign in to comment.