snapshot
Acquire single image frame from iOS device camera
Description
[
acquires a single image and its timestamp from an iOS mobile device camera
img
,timestamp
] = snapshot(cam
,shutterMode
);cam
using the specified shutter option
shutterMode
. The snapshot
function opens a camera
preview on the device and returns the current frame in MATLAB® as an RGB image. The resolution of the image is specified by the
Resolution
property of the camera
object
cam
.
Preview the image using image
.
Examples
Acquire One Image Frame Using Immediate Shutter Mode from iOS Mobile Device Camera
Acquire an image frame using immediate shutter mode from an iOS mobile device camera. To complete this example, you must have MATLAB Mobile™ on your iOS device and you must be connected to the MathWorks® Cloud. For more information, see Sensor Data Collection with MATLAB.
Start MATLAB Mobile on your iOS device.
On the Commands screen of MATLAB
Mobile, create a mobiledev
object
m
.
m = mobiledev
m = mobiledev with properties: Connected: 1 AvailableCameras: {'back' 'front'} Logging: 0 InitialTimestamp: '' AccelerationSensorEnabled: 0 AngularVelocitySensorEnabled: 0 MagneticSensorEnabled: 0 OrientationSensorEnabled: 0 PositionSensorEnabled: 0 Supported functions
Create a connection to the 'back'
camera of the device.
cam = camera(m,'back')
cam = Camera with properties: Name: 'back' AvailableResolutions: {'640x480' '1280x720'} Resolution: '640x480' Autofocus: 'on' Flash: 'off'
Acquire a single image and timestamp from the camera. The camera preview opens on your device and immediately captures an image.
[img,t] = snapshot(cam,'immediate');
Display the acquired image in MATLAB Mobile.
image(img)
Acquire One Image Frame Using Manual Shutter Mode from iOS Mobile Device Camera
Acquire an image frame using manual shutter mode from an iOS mobile device camera. To complete this example, you must have MATLAB Mobile on your iOS device and you must be connected to the MathWorks Cloud. For more information, see Sensor Data Collection with MATLAB.
Start MATLAB Mobile on your iOS device.
On the Commands screen of MATLAB
Mobile, create a mobiledev
object
m
.
m = mobiledev
m = mobiledev with properties: Connected: 1 AvailableCameras: {'back' 'front'} Logging: 0 InitialTimestamp: '' AccelerationSensorEnabled: 0 AngularVelocitySensorEnabled: 0 MagneticSensorEnabled: 0 OrientationSensorEnabled: 0 PositionSensorEnabled: 0 Supported functions
Create a connection to the 'back'
camera of the device.
cam = camera(m,'back')
cam = Camera with properties: Name: 'back' AvailableResolutions: {'640x480' '1280x720'} Resolution: '640x480' Autofocus: 'on' Flash: 'off'
Acquire a single image and timestamp from the camera using the manual shutter mode. The camera preview opens on your device. You can move your mobile device to capture the desired image in the preview. Press the shutter button on the device to acquire the image.
[img,t] = snapshot(cam,'manual');
Display the acquired image in MATLAB Mobile.
image(img)
Input Arguments
cam
— iOS mobile device camera connection
camera object
iOS mobile device camera connection, specified as a camera
object.
shutterMode
— Shutter mode
'immediate'
| 'manual'
Shutter mode, specified as 'immediate'
or
'manual'
.
'immediate'
— The specified camera opens on the device and captures an image when you callsnapshot
.'manual'
— The specified camera opens on the device and captures an image when you tap the shutter button.
Data Types: char
| string
Output Arguments
img
— RGB image data
n-by-n-by-3 matrix
RGB image data, returned as an n-by-n-by-3 matrix of values.
Data Types: uint8
timestamp
— Timestamp
datetime
Timestamp for image data, returned as a datetime
array.
Data Types: datetime
Version History
Introduced in R2019a
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
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.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)