read
Description
returns image data that is captured with the fisheye camera specified by
image
= read(fisheyeCamera
)fisheyeCamera
in the 3D environment.
Examples
Create a fisheye camera in the 3D environment using the sim3d.sensors.FisheyeCamera
object. You can capture images of the 3D environment and display them in MATLAB®. Use the read
function to extract image data from the 3D environment.
Create a 3D environment and set up communication with the Unreal Engine simulation environment using the output function OutputImpl
and the update function UpdateImpl
. The sim3d.World
object can send and receive data about the 3D environment to and from the Unreal Engine at each simulation step using output and update functions, respectively. Before the Unreal Engine simulates, MATLAB calls the output function and sends data to the Unreal Engine. Then, the Unreal Engine executes at each time step and sends data to MATLAB in the update function. You can use the update function to read this data or change values after each simulation step.
world = sim3d.World(Output=@outputImpl,Update=@updateImpl);
Create a box actor in the 3D environment using the sim3d.Actor
object and add the box to the world.
cube = sim3d.Actor( ... ActorName="Cube", ... Mobility=sim3d.utils.MobilityTypes.Movable, ... Translation=[0 0 0.5]); createShape(cube,"box"); add(world,cube);
Create a fisheye camera using the sim3d.sensors.FisheyeCamera
object and set the location of the fisheye camera using the Translation
property. Add the fisheyecamera
to the world.
fisheyecamera = sim3d.sensors.FisheyeCamera( ... ActorName="FisheyeCamera"); fisheyecamera.Translation = [-3 0 0]; add(world,fisheyecamera);
Run the co-simulation.
sampletime = 1/60; stoptime = 2; run(world,sampletime,stoptime);
Output Function
The output function sends data about the actor to the Unreal Engine environment at each simulation step. For this example, the function rotates the Cube
about its Z-axis by updating the Rotation
property of the Cube
at each simulation step.
function outputImpl(world) world.Actors.Cube.Rotation(3) = world.Actors.Cube.Rotation(3) ... + 0.01; end
Update Function
The update function reads data from the Unreal Engine environment at each simulation step. For this example, the update function uses the read
function of the sim3d.sensors.FisheyeCamera
object to get image data from the FisheyeCamera
in the Unreal Engine and uses the image
function to display it in MATLAB.
function updateImpl(world) sceneImage = read(world.Actors.FisheyeCamera); image(sceneImage); end
Input Arguments
Virtual camera that captures the image, specified as a sim3d.sensors.FisheyeCamera
object.
Example: fisheyeCamera =
sim3d.sensors.FisheyeCamera
Output Arguments
Image data returned by camera, returned as an m-by-n-by-3 array of RGB triplet values. m is the vertical resolution of the image. n is the horizontal resolution of the image.
Data Types: uint8
Version History
Introduced in R2024b
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)