Contenuto principale

addImageOverlay

R2026b

Add image overlay to RoadRunner Viewer viewport

Since R2026b

    Description

    img = addImageOverlay(rrViewer) adds an empty image overlay to the viewport of the specified RoadRunner Viewer object rrViewer, and returns an ImageOverlay object, img. Use the ImageOverlay object to specify the image file, image size, and image position in the viewport. For example, img = addImageOverlay(rrViewer); adds an image overlay, img, to the viewport of the specified RoadRunner Viewer object rrViewer. Then, img.ImagePath = "CustomFolder/myImage.png"; adds the image file myImage.png to the image overlay img, and img.Size = [0.12 0.12]; specifies the size of the image overlay.

    example

    Examples

    collapse all

    Use addImageOverlay to add an image overlay to the RoadRunner Viewer viewport. This example assumes you have already added the folder containing the RoadRunner API to your MATLAB® path and created a project folder. For information on getting started with RoadRunner Viewer, see Get Started with RoadRunner Viewer (RoadRunner Scenario).

    Specify the path to a project folder. RoadRunner Viewer uses the 3D mesh, material, and image files in the Assets folder of the specified project.

    If you do not have a project folder and want to create one that already contains an Assets folder with sample files, create a RoadRunner project. By default, RoadRunner projects contain an Assets folder prepopulated with sample assets, such as a Sedan.fbx file, that you can use in RoadRunner Viewer. For information on creating a RoadRunner project, see RoadRunner Project and Scene System (RoadRunner).

    myProject="C:\users\MyProject"

    Open RoadRunner Viewer and specify your project folder.

    rrViewer = roadrunnerViewer(ProjectFolder=myProject);
    

    To add an image overlay, img, to the RoadRunner Viewer viewport, use addImageOverlay.

    img = addImageOverlay(rrViewer);

    To specify the image file to display, set the ImagePath property of img to the location of an image in your project. The path you specify must be relative to the Assets folder in your project.

    img.ImagePath = "CustomFolder/myImage.png";
    

    To specify the position and size of the overlay img, modify the Position and Size properties, respectively. The position and size values of the image overlay are relative to the size of the RoadRunner Viewer viewport, measured from the top-left corner.

    img.Position = [0.85 0.02];
    img.Size = [0.12 0.12];

    To update RoadRunner Viewer and view the changes to the overlay, use the drawnow function.

    drawnow(rrViewer)

    Input Arguments

    collapse all

    RoadRunner Viewer in which to add an image overlay, specified as a roadrunnerViewer object.

    Output Arguments

    collapse all

    Image overlay, returned as an ImageOverlay object. You can use image overlays to annotate your scenarios and display warning or error icons.

    Version History

    Introduced in R2026b