image - Display image - MATLAB (original) (raw)
Main Content
Syntax
Description
image([imDispObj](#mw%5Fc1af99fd-cd1c-4192-8d8a-72020ab11339),[img](#mw%5F7f1e0291-8e5e-483d-8128-7d692d9f4276))
displays the image img
on the NVIDIA DRIVE® or Jetson™ target desktop. This functionality requires the Simple DirectMedia Layer (SDL) library to be installed on the target platform. For more information, see Prerequisites for Generating Code for NVIDIA Boards
When the image
function is used during simulation within the MATLAB® environment, it displays the images on your host computer by using theimshow (Image Processing Toolbox) function.
Examples
This example shows how to use imageDisplay to display images 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('jetson-board-name','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,[1280 800]); 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
.
cfg = coder.gpuConfig('exe'); cfg.GenerateReport = true; cfg.Hardware = coder.hardware('NVIDIA Jetson'); cfg.GenerateExampleMain = 'GenerateCodeAndCompile';
The main.cu
file is generated as part of code generation process. For this example, you can use this file without modification.
To generate CUDA code, use the codegen command and pass the GPU code configuration object along with theliveCapture
entry-point function. After the code generation takes place on the host, the generated files are copied over and built on the target.
codegen -config cfg liveCapture
Use the runApplication
function to launch the executable on the TX2 board.
runApplication(hwobj,'liveCapture');
Input Arguments
System object™ to display images on the target desktop. To display the images, use theimage function of the imDispObj
object.
Input image, specified as a _m_-by-n or_m_-by-_n_-by-3 numeric array. When the images is a 2-D matrix _m_-by-n, the image is displayed in grayscale.
Data Types: uint8
Extended Capabilities
Version History
Introduced in R2018b
See Also
Functions
- jetson | drive | snapshot | imageDisplay | webcam
Objects
- jetson | drive | webcam | imageDisplay
Topics
- Sobel Edge Detection on NVIDIA Jetson Nano Using Raspberry Pi Camera Module V2
- Getting Started with the MATLAB Coder Support Package for NVIDIA Jetson and NVIDIA DRIVE Platforms
- Deploy and Run Sobel Edge Detection with I/O on NVIDIA Jetson Nano
- Build and Run an Executable on NVIDIA Hardware
- Stop or Restart an Executable Running on NVIDIA Hardware
- Run Linux Commands on NVIDIA Hardware