procID = runApplication(hwObj,exeName)
launches the application (executable) specified by exeName on the
NVIDIA® target board desktop.
procID = runApplication(___,exeArgs)
launches the application specified by exeName on the NVIDIA target board desktop. exeArgs is used to specify run-time
arguments to the application.
procID = runApplication(___,exePath)
launches the application specified by exeName on the NVIDIA target board desktop. exePath is used to explicitly specify
the location of the application.
This example shows how to launch an application on the NVIDIA Jetson TX2 target. This example requires a USB camera connected to the
NVIDIA target.
Create a live hardware connection from the MATLAB® software to the NVIDIA hardware by using the jetson
function. To create a live hardware connection object, provide the host name or IP
address, user name, and password of the target board. For example:
hwobj = jetson('192.168.1.15','ubuntu','ubuntu');
Create a MATLAB function liveCapture.m that connects to the webcam on a
Jetson TX2 board and displays the image on the board. This function acts as the
entry-point for code generation.
function liveCapture() %#codegen% To enable code generation for hardware interfaces
hwobj = jetson;
w = webcam(hwobj,1,'1280x800');
d = imageDisplay(hwobj);
for k = 1:2000
% Capture the image from the webcam on hardware.
img = snapshot(w);
% Display image.
image(d,img);
end
Create a GPU code configuration object for generating an executable. Use the
coder.hardware function to create a configuration object for the Jetson
platform and assign it to the Hardware property of the code
configuration object cfg.
The main.cu file is generated as part of code generation process.
For this example, this file can be used without any modification.
To generate CUDA code, use the codegen command and pass the GPU code configuration object along with the
liveCapture entry-point function. After the code generation takes
place on the host, the generated files are copied over and built on the target.
codegen -configcfgliveCapture
Use the runApplication function to launch the executable on the
TX2 board.
procID = runApplication(hwobj,'liveCapture');
### Launching the executable on the target...
Executable launched successfully with process ID 12821.
Displaying the simple runtime log for the executable...
hwObj — Connection to a specific NVIDIA hardware board jetson object | drive object
Connection to a specific NVIDIA hardware board, specified as a jetson or
drive
object.
Use the jetson or
the drive
function to create this connection.
exeName — Application name string | character array
Specify the name of the application to run on the NVIDIA target desktop.
Example: 'liveCapture.elf'
exeArgs — Application arguments string | character array
Specify the runtime arguments to the application.
Example: 'camVid.avi'
exePath — Application path string | character array
Specify the path to the application on the NVIDIA board. If no value is specified, the software uses the
workspaceDir property of the jetson or
drive object
to determine the standard location of the application.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.