Documentation

snapshot

Acquire single image frame from iOS device camera

Description

example

[img,timestamp] = snapshot(cam,shutterMode); acquires a single image and its timestamp from an iOS mobile device camera 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

collapse all

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 Install MATLAB Mobile on Your Apple iOS Device (MATLAB Mobile for iOS) and Sign In to the Cloud (MATLAB Mobile for iOS).

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 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 Install MATLAB Mobile on Your Apple iOS Device (MATLAB Mobile for iOS) and Sign In to the Cloud (MATLAB Mobile for iOS).

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

collapse all

iOS mobile device camera connection, specified as a camera object.

Shutter mode, specified as 'immediate' or 'manual'.

  • 'immediate' — The specified camera opens on the device and captures an image when you call snapshot.

  • 'manual' — The specified camera opens on the device and captures an image when you tap the shutter button.

Data Types: char | string

Output Arguments

collapse all

RGB image data, returned as an n-by-n-by-3 matrix of values.

Data Types: uint8

Timestamp for image data, returned as a datetime array.

Data Types: datetime

See Also

|

Introduced in R2019a