How to stream video from a d435 camera in matlab?
Thank you
-
By doing some searching on the net to get around the broken links, I managed to access some possibly useful information from that old RealSense forum.
The Intel support team member who provided the now broken link pointed to the article in the link below for getting live 2D video with the acquisition toolbox.
https://uk.mathworks.com/matlabcentral/answers/7202-processing-on-a-live-webcam-streaming-video
A RealSense community member also offered their own script for getting a 3D RGB point cloud in MATLAB. I have pasted the script below.
***********************************
% Make Pipeline object to manage streaming
pipe = realsense.pipeline();
% Make Colorizer object to prettify depth output
colorizer = realsense.colorizer();
% define point cloud object
pcl_obj = realsense.pointcloud();
% Start streaming with default settings
profile = pipe.start();
align_to = realsense.stream.color;
alignedFs = realsense.align(align_to);
% 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();
end
%create a point cloud player
player1 = pcplayer([-1 1],[-1 1],[-1 1]);
frameCount =0;
while isOpen(player1) && frameCount < 2000
frameCount = frameCount+1;
fs = pipe.wait_for_frames();
%align the depth frames to the color stream
aligned_frames = alignedFs.process(fs);
depth = aligned_frames.get_depth_frame();
color = fs.get_color_frame();
%get the points cloud based on the aligned depth stream
pnts = pcl_obj.calculate(depth);
pcl_obj.map_to(color);
colordata = color.get_data();
colordatavector = [colordata(1:3:end)',colordata(2:3:end)',colordata(3:3:end)'];
vertices = pnts.get_vertices();
view(player1,vertices,colordatavector)
end
% Stop streaming
pipe.stop();
*********************************
If you get this error
alignedFs = realsense.align (align_to);
(Error using realsense.align Error: File: align.m Line: 9 Column: 20 A constructor call to superclass realsense.filter appears after the object is used, or after a return)
The script author suggests commenting out line 17 of align.m
-
All of the above information was sourced from here:
https://forums.intel.com/s/question/0D50P0000490XiJSAU/matlab-rgb-point-cloud
Please sign in to leave a comment.
Comments
2 comments