View my account

Align-advanced example for MATLAB.

Comments

3 comments

  • Eliza Davidov

    Hello Maqahad1993,

     

    Thank you for your interest in the Intel RealSense Technology. 

     

    At this moment, we can only provide you this example for using the align function.

    Please feel free to use it as a template and modify it accordingly in order achieve your desired results. 

     

    % Make Pipeline object to manage streaming

     
    pipe = realsense.pipeline();
     

    % Make Colorizer object to prettify depth output

    colorize = realsense.colorizer();

    % define point cloud object

    pcl_obj = realsense.pointcloud();

    % Start streaming with default settings

    profile = pipe.start();

    alignto = realsense.stream.color;

    alignedFs = realsense.align(alignto);

     

    % 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();

    Best regards,

    Eliza

    0
    Comment actions Permalink
  • H Hewawasam

    Hi,

     

    Thanks for the example. However, I get an error after a couple of iterations. Error message was,

    ----------------------------------------------------------------------------------------------------------------------------------

    Error using pointclouds.internal.pcui.validateAndParseInputsXYZC (line 80)
    'C' must be a single color or its dimensions must correspond to the number of input points.

    Error in pcplayer/parseInputs (line 501)
    [X, Y, Z, C, map, ptCloud] =
    pointclouds.internal.pcui.validateAndParseInputsXYZC(mfilename, varargin{:});

    Error in pcplayer/view (line 196)
    [X,Y,Z,C,map, ptCloud] = pcplayer.parseInputs(varargin{:});

    Error in align_example_original (line 89)
    view(player1,vertices,colordatavector)

    --------------------------------------------------------------------------------------------------------------------------------------------

    Could you please advice me on this issue?

     

    Thanks

     

     

     

    0
    Comment actions Permalink
  • MartyG

    If you are using the script above, it is not meant for use directly in MATLAB.  Eliza was suggesting to modify it for MATLAB.

    If you are aiming to use a RealSense 400 Series camera with MATLAB, the RealSense SDK has a compatibility 'wrapper' for MATLAB users with Windows 10.

    https://github.com/IntelRealSense/librealsense/tree/master/wrappers/matlab 

    Scripts for the MATLAB wrapper are almost 1:1 the same as C++ scripting for the RealSense SDK, though you may still have to make some modifications.

    0
    Comment actions Permalink

Please sign in to leave a comment.