Matlab encounteres an internal problem when l access to a specific variables in a ".mat" file that contains data from "RealSense Depth D435" camera

3 views (last 30 days)
I am using "RealSense Depth D435" camera - and I am running the code "depth_example.m" that I found here https://github.com/IntelRealSense/librealsense/tree/master/wrappers/matlab
I added a line to the code in order to save the the variable "fs" in a ".mat" file. The line that I added is :
save('fs');
When I am loading 'fs.mat' and trying to access specific variables in struct "fs", such as "get_depth_frame" - Matlab stop working and I get this error:
"Matlab has encountered an Internal problem and needs to close.".
This is the code that I am running when I get an error:
x = load('fs.mat');
x.fs.get_depth_frame;
This is the code that I am running in order to save "fs":
function depth_example()
% Make Pipeline object to manage streaming
pipe = realsense.pipeline();
% Make Colorizer object to prettify depth output
colorizer = realsense.colorizer();
% Start streaming on an arbitrary camera with default settings
profile = pipe.start();
% Get streaming device's name
dev = profile.get_device();
name = dev.get_info(realsense.camera_info.name);
% Get frames. We discard the first couple to allow
% the camera time to settle
for i = 1:5
fs = pipe.wait_for_frames();
% Select depth frame
depth = fs.get_depth_frame();
% Colorize depth frame
color = colorizer.colorize(depth);
% Get actual data and convert into a format imshow can use
% (Color data arrives as [R, G, B, R, G, B, ...] vector)
data = color.get_data();
img = permute(reshape(data',[3,color.get_width(),color.get_height()]),[3 2 1]);
% Display image
imshow(img);
title(sprintf("Colorized depth frame from %s", name));
save('fs');
end
pipe.stop();
end

Answers (0)

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!