Save Segmentation Image

Hello,

I’m currently trying to write my own application to save .png images received from Isaac Sim on the disk. It works well for color images. But when i try to save depth or label images i get this error:

“PANIC ./engine/alice/hooks/message_hook.hpp@199: No message available”

Here is my code :

Where rx_segmentation_image() channel receives message from type SegmentationCameraProto.

I use application navsim_training.subgraph.json to stream the different image types from Isaac Sim and i can visualize the received images in isaac sight.

Thanks in advance.

I’m having the same issue. Would appreciate an update on this.
And @markus.heumesser how did you find out that the segmenation image was an “ImageConstView1ui16”?

I solved this by putting the casting functions inside an if-statement where I first control if the message is available with rx_color_image_().available().

It makes sense to check that the receiver actually has a message using available() before processing. The common practice is to configure tick()to be invoked on new message, so accessing the message without checking happens to work. If you’re accessing multiple channels or ticking on time, then there is no such guarantee of course.

Were you able to write out the images properly after this?

Thanks for the answer.
There are SavePng(..) functions defined in the io.hpp header file that should help saving images in PNG or JPEG, I suppose. Unfortunately there is no saving function for the ImageConstView1f type. I used OpenCV to normalize the single channel float image and save it via imwrite:

void DensefusionDatasetGenerator::tick(){
        ImageConstView1f input_image_depth;
        const size_t rows = input_image_depth.rows();
        const size_t cols = input_image_depth.cols();
        cv::Mat image = cv::Mat(rows, cols, CV_32F, const_cast<void *>(static_cast<const void *>(input_image_depth.data().pointer())));
        cv::Mat image_depth;
        cv::normalize(image, image_depth, 0, 255, cv::NormTypes::NORM_MINMAX, CV_8UC1);
        cv::imwrite("~/ws/YCB_Dataset/train/depth/input_image_depth.png", image_depth);
}