Documentation

Acquire Images from iOS Camera

Set Up iOS Device

Install and set up MATLAB® Mobile™ on your iOS device. Then, sign in to the MathWorks® Cloud from the MATLAB Mobile Settings. For more information about these steps, see Connect to the MathWorks Cloud (MATLAB Mobile for iOS).

Start MATLAB Mobile on your iOS device.

Create a Connection to Your iOS Camera

On the Commands screen, 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

The AvailableCameras property indicates that this device has 'back' and 'front' cameras. Create a connection to the 'back' camera.

cam = camera(m,'back')
cam = 
  Camera with properties:

                    Name: 'back'
    AvailableResolutions: {'640x480'  '1280x720'}
              Resolution: '1280x720'
                   Flash: 'on'
               Autofocus: 'off'

The camera properties provide information about the image resolution, autofocus, and flash settings.

Acquire an Image Frame Using Immediate Shutter Mode

On the Commands screen, acquire a single image from the camera using snapshot. The camera preview opens on your device and immediately captures an image.

img = snapshot(cam,'immediate');

Display the acquired image in MATLAB Mobile using image.

image(img)

Set Camera Properties

The acquired image uses default camera settings. You can set the camera properties to customize the image quality.

The current resolution is '640x480'. Change the resolution to '1280x720'.

cam.Resolution = '1280x720';

This camera supports both Autofocus and Flash. Set Autofocus to 'on'.

cam.Autofocus = 'on';

Set Flash to 'off'.

cam.Flash = 'off';

The camera object reflects the updated camera properties.

cam
cam = 
  Camera with properties:

                    Name: 'back'
    AvailableResolutions: {'640x480'  '1280x720'}
              Resolution: '1280x720'
                   Flash: 'off'
               Autofocus: 'on'

Acquire an Image Frame Using Manual Shutter Mode

Use the updated camera properties and manual shutter mode to capture a higher quality image.

On the Commands screen, acquire a single image from the camera and specify the shutter mode as 'manual' using snapshot. After the camera preview opens, move your mobile device to capture the desired field of view. When you are ready, press the shutter button to acquire the image.

img = snapshot(cam,'manual');

Display the acquired image in MATLAB Mobile using image.

image(img)

See Also

| |