camera
Connection to camera on mobile device
Description
A camera
object represents a connection to a camera on a mobile
device. After you create the object, you can acquire images from the device camera using Object Functions.
Add-On Required
To use this function for accessing mobile device sensors remotely from MATLAB® installed on a desktop or laptop computer, you must also install either MATLAB Support Package for Apple iOS Sensors or MATLAB Support Package for Android® Sensors. For more information, see Get and Manage Add-Ons.
Creation
Syntax
Description
Input Arguments
m
— mobile device connection
mobiledev object
mobile device connection, specified as a mobiledev
object.
name
— Camera name
'back'
| 'front'
Camera name, specified as 'back'
or 'front'
.
Valid camera names are listed in the AvailableCameras
property of
the mobiledev
object.
Example: cam = camera(m,'front')
creates a connection to the
front-facing camera of the mobile device represented by the
mobiledev
object m
.
Properties
Name
— Camera name
'back'
| 'front'
This property is read-only.
Camera name, returned as 'back'
or 'front'
.
The 'back'
camera is the rear-facing camera on the back of the phone.
The 'front'
camera is the front-facing camera on the display side of
the device. For devices that have additional supported cameras, other values are
possible. For example, an additional camera on the back might be named
'back-1'
.
Data Types: char
| string
AvailableResolutions
— Available resolutions
cell array
This property is read-only.
Available resolutions of the camera, returned as a cell array of strings. Possible
resolutions are '640x480'
and '1280x720'
. If the
device camera does not support one of these resolutions, the closest supported
resolution is selected.
Data Types: cell
Resolution
— Camera resolution
character vector | string
Camera resolution, returned as a character vector or string scalar. Valid values are
listed in the AvailableResolutions
property. You can set the camera
resolution using dot notation.
Example: cam.Resolution = '1280x720'
sets the camera resolution to
1280-by-720.
Data Types: char
| string
ZoomRange
— Zoom range of camera
double array
This property is read-only.
Range of supported zoom values of camera, returned as a two-element array of doubles, indicating minimum and maximum supported zoom values. The values are determined by your camera.
Example: [0.5 10]
Data Types: double
Zoom
— Zoom setting of camera
double
Zoom setting of camera, specified as a double within the range defined by
ZoomRange
. The default value is 1
. You can set
the camera zoom using dot notation. This property does not reflect manual zoom changes
made on the device by a pinch-to-zoom gesture.
Example: cam.Zoom = 3
Data Types: double
Flash
— Camera flash mode
'auto'
| 'on'
| 'off'
Camera flash mode, specified as 'auto'
, 'on'
,
or 'off'
. This property is only available for cameras that support
flash. You can set the flash mode using dot notation.
Example: cam.Flash = 'off'
turns off flash.
Data Types: char
| string
Autofocus
— Camera autofocus mode
'on'
| 'off'
Camera autofocus mode, specified as 'on'
or
'off'
. This property is only available for cameras that support
autofocus. You can set the autofocus mode using dot notation.
Example: cam.Autofocus = 'off'
turns off autofocus.
Data Types: char
| string
Object Functions
snapshot | Acquire single image frame from mobile device camera |
Examples
Connect to a Camera on a Mobile Device
This example assumes that you have already installed and set up MATLAB Mobile™ on your device and connected to the MathWorks® Cloud. If you have not, see Install MATLAB Mobile on Your Device.
If you want to read the data in a different session of MATLAB, start MATLAB Online™ or MATLAB on your local computer.
Start MATLAB Mobile on your mobile device.
In your MATLAB session, 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
The AvailableCameras
property indicates that this device has both
'back'
and 'front'
cameras.
Create a connection to the 'back'
camera of the device.
cam = camera(m,'back')
cam = Camera with properties: Name: 'back' AvailableResolutions: {'640x480' '1280x720'} ZoomRange: [1 121.8750] Resolution: '640x480' Zoom: 1 Flash: 'off' Autofocus: 'on'
Creating the connection returns the camera
object and displays
its properties.
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)