How do display visuals of one player on multiple monitors, while using Unreal Engine and MATLAB Simulink to start the program?

7 次查看(过去 30 天)
I am using MATLAB R2021b and Unreal Engine. How can I split the visuals of a single person driving in a driving simulator, which operates on Unreal Engine, and display them on two screens?
  3 个评论
Kaitlyn Woolf
Kaitlyn Woolf 2023-8-31
Hi Nishan,
I wish to show some parts of the scene in one window and other parts on a different window.
I want to take the real-time scenes of a single driver and display them across multiple (two) monitor screens.
The purpose of this is that eventually I want to use multiple projectors to project the scene on a curved projection screen, and this seems like it is a good initial step, considering it does not involve edgeblending and etc.

请先登录,再进行评论。

采纳的回答

MathWorks Support Team
To display visuals of a single person driving on multiple monitors using MATLAB R2021b and Unreal Engine you can use one of the following two workflows:
Using the Simulink 3D Animation Toolbox:
You can do this by placing two "Simulation 3D Camera" blocks in your Simulink model and adjust the parameters so that they cover the parts of the scene that you desire. To visualize the camera images that are output by the "Image" port of that block, use a "Video Viewer" or a "To Video Display" block. This will open the view from each camera in a separate window.
Using the Image Processing Toolbox and the Image Acquisition Toolbox:
You can do this by following the steps below:
  1. Set up the driving simulation in Unreal Engine and ensure it is working correctly with a single screen.
  2. Use the MATLAB Simulink Integration with Unreal Engine to capture the rendered frames. You can use the "From Video Device" block in the "Image Acquisition Toolbox" library to capture the frames as an input signal. 
  3. Display each stream on its respective screen using the "imshow" function. Use the "ScreenNumber" Name-Value pair to specify the monitor where you want each stream to be displayed (0 represents the primary monitor and higher numbers represent additional monitors). 
The following code will display the driving simulation visual on two screens: 
Please note that this code example assumes two screens connected to the primary computer, and that each half needs to be displayed on a separate screen.
% Capture frames from Unreal Engine using Simulink
videoInput = Simulink.Signal;
videoInput.DataType = 'uint8';
videoInput.SampleTime = -1;
videoInput.Complexity = 'real';
videoInput.Name = 'VideoInput';
% Split the frames into two halves
frameWidth = size(videoInput, 2);
halfWidth = frameWidth / 2;
leftHalf = videoInput(:, 1:halfWidth);
rightHalf = videoInput(:, halfWidth+1:end);
% Display each half on its respective screen
figure('Position', [0 0 halfWidth size(videoInput, 1)]);
imshow(leftHalf, 'InitialMagnification', 'fit', 'Border', 'tight', 'ScreenNumber', 1);
figure('Position', [halfWidth 0 halfWidth size(videoInput, 1)]);
imshow(rightHalf, 'InitialMagnification', 'fit', 'Border', 'tight', 'ScreenNumber', 2);
For a different monitor configuration or to split the visuals in a different way, the code can be modified accordingly.

更多回答(1 个)

Nishan Nekoo
Nishan Nekoo 2023-9-5
Kaitlyn, one way to do this might be to place two Simulation 3D Camera blocks in your Simulink model and adjust the parameters so that they cover the parts of the scene that you desire.
To visualize the camera images that are output by the Image port of that block, use a Video Viewer or To Video Display block. This will open the view from each camera in a separate window.

类别

Help CenterFile Exchange 中查找有关 Vehicle Scenarios 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by