Main Content

generate

Generate 3-D asset from single view camera image

Since R2025a

Description

[assetAttributes,info] = generate(assetGenerator,I) generates a 3-D asset from a single view camera image, I, using an imageAssetGenerator object, assetGenerator. The function returns the 3-D asset attributes, assetAttributes. Additionally, the function returns the debugging information, info, which also contains the preprocessed image.

example

[___] = generate(___,Name=Value) specifies options using one or more name-value arguments in addition to the arguments from the previous syntax. For example, ExecutionEnvironment="cpu" uses the CPU as the hardware resource to execute the function.

Note

This function requires the Scenario Builder for Automated Driving Toolbox™ support package and a Deep Learning Toolbox™ license. You can install the Scenario Builder for Automated Driving Toolbox support package from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

Examples

collapse all

Read a single view camera RGB image into the workspace.

I = imread("ObjaverseAssetImage.jpeg");
imshow(I)

Initialize the image asset generator object.

assetGenerator = imageAssetGenerator;

Generate an asset from the image by using the generate object function of the imageAssetGenerator object.

assetAttributes = generate(assetGenerator,I);

Create a surface mesh from the obtained asset attributes.

assetMesh = surfaceMesh(assetAttributes.vertices,assetAttributes.faces,VertexColors=assetAttributes.vertexColors);

Display the created surface mesh.

surfaceMeshShow(assetMesh,BackgroundColor="White")

Input Arguments

collapse all

3-D asset generator, specified as an imageAssetGenerator object.

Input RGB image, specified as an M-by-N-by-3 numeric array.

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: generate(assetGenerator,I,ExecutionEnvironment="cpu") uses the CPU as the hardware resource to generate 3-D assets.

Resolution of the 3-D asset mesh, specified as 32, 64, 128, 256, 512, or 1024. The MeshResolution value represents the number of grids along each axis of the 3-D asset. Increase this value to generate a more detailed mesh. Increasing the value results in increased memory consumption and higher computation time.

Hardware resource, specified as "auto", "gpu", or "cpu".

  • "auto" — Use a GPU if one is available. Otherwise, use the CPU. The use of a GPU requires a Parallel Computing Toolbox™ license and a CUDA® enabled NVIDIA® GPU. For information about the supported compute capabilities, see GPU Computing Requirements (Parallel Computing Toolbox).

  • "gpu" — Use the GPU. If a suitable GPU is not available, the function returns an error message.

  • "cpu" — Use the CPU.

Output Arguments

collapse all

3-D asset attributes, returned as a structure. The structure contains these fields:

  • Vertices — Mesh vertices, returned as a P-by-3 matrix. Each row of the matrix is of the form [x y z], specifying the coordinates of a vertex. Each vertex has a vertex ID equal to its row number in the matrix. P is the total number of vertices in the mesh.

  • Faces — Mesh triangular faces, returned as a Q-by-3 matrix. Each row of the matrix is of the form [V1 V2 V3], specifying the row indices of the corresponding vertices in Vertices that define the triangular face. Q is the number of faces in the mesh.

  • VertexColors — Color values for the mesh vertices, returned as a P-by-3 matrix. Each row of the matrix is of the form [R G B], specifying the color value for a vertex. Each value must be in the range [0, 1]. P is the total number of vertices in the mesh.

Debug information, returned as a structure. The structure has a preProcessedImage field that contains the preprocessed input image. The size of the preprocessed image and the size of the input image are the same.

Version History

Introduced in R2025a