java.lang.Object | |
↳ | com.hvt.horizonSDK.CameraHelper |
A helper class that provides with useful information about the device's cameras and their capabilities.
The class has many methods to return compatible photo and video resolutions. The easiest
to use is getDefaultVideoAndPhotoSize(int, boolean)
.
Note: All methods may return null
or an empty List.
The methods that return compatible video sizes may return sizes that are smaller than the
ones returned by getSupportedVideoSizes()
. This is because
HVTCamera
uses the preview frames to process them at real time. CameraHelper reads the
supported preview sizes
instead.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CameraHelper()
Creates a CameraHelper instance that can be used to get information about the device cameras.
| |||||||||||
CameraHelper(File cacheFile)
This constructor is deprecated.
Use
CameraHelper() instead |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Camera.Parameters |
getCameraParameters(int cameraFacing)
Returns the camera parameters of the camera having the provided
cameraFacing . | ||||||||||
Size[] |
getDefaultVideoAndPhotoSize(int cameraFacing)
Returns the highest supported video and photo size for the camera having the provided
cameraFacing . | ||||||||||
static Size[] |
getDefaultVideoAndPhotoSize(Camera.Parameters params, boolean priorityPhoto)
Returns the highest supported video and photo size.
| ||||||||||
Size[] |
getDefaultVideoAndPhotoSize(int cameraFacing, boolean priorityPhoto)
Returns the highest supported video and photo size for the camera having the provided
cameraFacing . | ||||||||||
int |
getNumberOfCameras()
Returns the number of physical cameras available on this device.
| ||||||||||
static List<Size> |
getPhotoSizesForVideoSize(Camera.Parameters params, Size videoSize)
Returns a list of the supported photo sizes having the same aspect ratio as the provided
videoSize . | ||||||||||
List<Size> |
getPhotoSizesForVideoSize(int cameraFacing, Size videoSize)
Returns a list of the supported photo sizes having the same aspect ratio as the provided
video size , for the camera having the provided cameraFacing . | ||||||||||
List<String> |
getSupportedFlashModes(int cameraFacing)
Returns the supported flash modes for the camera having the provided
cameraFacing . | ||||||||||
static List<String> |
getSupportedFlashModes(Camera.Parameters params)
Returns the supported flash modes.
| ||||||||||
List<Size> |
getSupportedPhotoSizes(int cameraFacing)
Returns a list with the supported photo sizes of the camera having the provided
cameraFacing . | ||||||||||
static List<Size> |
getSupportedPhotoSizes(Camera.Parameters params)
Returns a list with the supported photo sizes.
| ||||||||||
List<Size> |
getSupportedVideoSize(int cameraFacing)
Returns a list with the supported video sizes of the camera having the provided
cameraFacing . | ||||||||||
static List<Size> |
getSupportedVideoSizes(Camera.Parameters params)
Returns a list with the supported video sizes.
| ||||||||||
List<Size> |
getVideoSizesForPhotoSize(int cameraFacing, Size photoSize)
Returns a list of the supported video sizes having the same aspect ratio as the provided
photoSize , for the camera having the provided cameraFacing . | ||||||||||
static List<Size> |
getVideoSizesForPhotoSize(Camera.Parameters params, Size photoSize)
Returns a list of the supported video sizes having the same aspect ratio as the provided
photoSize . | ||||||||||
boolean |
hasCamera(int cameraFacing)
Returns if the device has a camera with the provided
cameraFacing . | ||||||||||
void |
printCameraParameters()
Prints the details of all cameras in the device.
| ||||||||||
void |
printCameraParameters(int facing)
Prints the details of the camera having the specified
facing . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Creates a CameraHelper instance that can be used to get information about the device cameras.
By default, the instance opens the device cameras to retrieve the camera information. If it fails to access the cameras, an IOException is thrown.
Note:If targetSdkVersion
is 23 or above, you need to request
permission at runtime, before calling this method.
IOException | an exception is thrown if the instance needs to access the device cameras but fails to do so |
---|
This constructor is deprecated.
Use CameraHelper()
instead
Creates a CameraHelper instance that can be used to get information about the device cameras.
By default, the instance opens the device cameras to retrieve the camera information. If
it fails to access the cameras, an IOException
is thrown.
Note:If targetSdkVersion
is 23 or above, you need to request
permission at runtime, before calling this method.
cacheFile | a file to write or read the camera information. If the file does not exist, the instance will create it and populate it with camera information. |
---|
IOException | an exception is thrown if the instance needs to access the device cameras but fails to do so |
---|
Returns the camera parameters of the camera having the provided cameraFacing
.
cameraFacing | the facing of the camera. Can be CAMERA_FACING_BACK
or CAMERA_FACING_FRONT |
---|
Returns the highest supported video and photo size for the camera having the provided
cameraFacing
.
Both sizes will have the same aspect ratio.
Priority will be given to video.
cameraFacing | the facing of the camera. Can be CAMERA_FACING_BACK
or CAMERA_FACING_FRONT |
---|
Returns the highest supported video and photo size.
Both sizes will have the same aspect ratio.
If priorityPhoto
is true
, the highest photo size will be selected and the
highest compatible video size will be found. If false
, the highest video size will be
selected and the highest compatible photo size will be found.
params | the camera's parameters |
---|---|
priorityPhoto | true for photo priority, false for video priority |
Returns the highest supported video and photo size for the camera having the provided
cameraFacing
.
Both sizes will have the same aspect ratio.
If priorityPhoto
is true
, the highest photo size will be selected and the
highest compatible video size will be found. If false
, the highest video size will be
selected and the highest compatible photo size will be found.
cameraFacing | the facing of the camera. Can be CAMERA_FACING_BACK
or CAMERA_FACING_FRONT |
---|---|
priorityPhoto | true for photo priority, false for video priority |
Returns the number of physical cameras available on this device.
Returns a list of the supported photo sizes having the same aspect ratio as the provided videoSize
.
params | the camera's parameters |
---|---|
videoSize | the video size |
Returns a list of the supported photo sizes having the same aspect ratio as the provided
video size
, for the camera having the provided cameraFacing
.
cameraFacing | the facing of the camera. Can be CAMERA_FACING_BACK
or CAMERA_FACING_FRONT |
---|---|
videoSize | the video size |
Returns the supported flash modes for the camera having the provided
cameraFacing
.
cameraFacing | the facing of the camera. Can be CAMERA_FACING_BACK
or CAMERA_FACING_FRONT |
---|
getFlashMode()
Returns the supported flash modes.
params | the camera's parameters |
---|
getFlashMode()
Returns a list with the supported photo sizes of the camera having the provided
cameraFacing
.
cameraFacing | the facing of the camera. Can be CAMERA_FACING_BACK
or CAMERA_FACING_FRONT |
---|
Returns a list with the supported photo sizes.
params | the camera's parameters |
---|
Returns a list with the supported video sizes of the camera having the provided
cameraFacing
.
cameraFacing | the facing of the camera. Can be CAMERA_FACING_BACK
or CAMERA_FACING_FRONT |
---|
Returns a list with the supported video sizes.
params | the camera's parameters |
---|
Returns a list of the supported video sizes having the same aspect ratio as the provided
photoSize
, for the camera having the provided cameraFacing
.
cameraFacing | the facing of the camera. Can be CAMERA_FACING_BACK
or CAMERA_FACING_FRONT |
---|---|
photoSize | the photo size |
Returns a list of the supported video sizes having the same aspect ratio as the provided photoSize
.
params | the camera's parameters |
---|---|
photoSize | the photo size |
Returns if the device has a camera with the provided cameraFacing
.
cameraFacing | the facing of the camera. Can be CAMERA_FACING_BACK
or CAMERA_FACING_FRONT
|
---|
Prints the details of all cameras in the device.
Prints the details of the camera having the specified facing
.
Note: The facing of the camera is required, not the camera id.
facing | the facing of the camera. Can be CAMERA_FACING_BACK
or CAMERA_FACING_FRONT
|
---|