snapshot - Capture RGB image from Camera - MATLAB (original) (raw)
Main Content
Capture RGB image from Camera
Syntax
Description
[img](#mw%5Fe4b05cd3-43c2-4308-8af7-5b4bfa560604) = snapshot([cam](#mw%5F5baf409e-1a43-4ff8-b5a0-79d1d43d9c84))
returns a still image in RGB format from the camera specified in thecam
object.
[[img](#mw%5Fe4b05cd3-43c2-4308-8af7-5b4bfa560604),[ts](#mw%5F7b1412f7-38f5-4cb4-98dd-510c308cf04b)] = snapshot([cam](#mw%5F5baf409e-1a43-4ff8-b5a0-79d1d43d9c84))
returns a still image in RGB format and the time stamp of the capture from the camera specified in the cam
object.
Examples
You can connect from the MATLAB® software to a USB camera connected to an NVIDIA® platform and capture images from this camera.
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');
To find the web camera name, check the webcamlist
property of thehwobj
object.
ans =
1×1 cell array
{'Microsoft® LifeCam Cinema(TM)'}
If this property is empty, then try reconnecting the USB webcam and run the following command. This command tries to scan the available webcams on the target when there is a addition or deletion.
updatePeripheralInfo(hwobj);
Create a webcam object, wcam
using the name or the index number of the webcam list. If a webcam name or the index is not specified, then it uses the default webcam. The wcam
object has the following camera properties.
wcam =
webcam with properties:
Name: 'Microsoft® LifeCam Cinema(TM)'
Resolution: '320x240'
AvailableResolutions: {1×12 cell}
To display the images captured from webcam in MATLAB, use the following commands.
img = snapshot(wcam); figure(); imagesc(img); drawnow;
To change the resolution of the image capture, use the following command.
clear wcam; wcam = webcam(hwobj,1,[1280 800])
You can use the AvailableResolutions
property of thewcam
object to get a cell array of the available resolutions for your camera.
Import and display a sequence of 50 snapshots on your host computer.
figure(); for ii = 1:50 img = snapshot(wcam); imagesc(img); drawnow; end
Output Arguments
RGB image, returned as an _m_-by-_n_-by-3 numeric array with values in the range [0,255].
Data Types: uint8
Timestamp of the snapshot, returned as a datetime object.
Extended Capabilities
Version History
Introduced in R2018b
See Also
Functions
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