Class Camera
- java.lang.Object
-
- totalcross.ui.media.Camera
-
public class Camera extends java.lang.ObjectThis class is used to enable the camera of the underlying device. The following platforms are supported: Windows Mobile devices, Blackberry, Palm OS, Android and iOS.For more information about the possible parameters on Windows, see: http://msdn2.microsoft.com/en-us/library/bb431794.aspx
See the CameraTest sample.
Note that you can easily rotate the image to put it in portrait mode, using the
Image.getRotatedScaledInstancemethod, after retrieving the image.To use this class with the Hand Held Dolphin barcode scanners, you must install TotalCross3/dist/vm/wince/POCKETPC/ARM/Dolphin.dll. Only 640x480 photos are supported, and you may change the following options:
- initialDir
- defaultFileName (must end with jpg)
- resolutionWidth x resolutionHeight: possible values are 640x480 and 212x160 (different values defaults to 640x480)
In Android you can set the defaultFileName, stillQuality, resolutionWidth and resolutionHeight. All other options are ignored.
You can call the getSupportedResolutions method to see the resolutions that are available at the device.
In iOS there's no way to return the supported resolutions; it will take a photo using the default camera's resolution, and then will resize to the resolution defined in resolutionWidth/resolutionHeight, keeping the camera's aspect ratio. In iOS you can specify the defaultFileName with a path or just the name, or use a system-generated name.
In Android, you can use the internal camera by setting the cameraType field.
- See Also:
getSupportedResolutions()
-
-
Field Summary
Fields Modifier and Type Field Description booleanallowRotationThis field is false by default so that the default camera orientation is still landscape.intbitrateVideo bitrate in kbps.static intCAMERA_CUSTOMThe original camera used in TotalCrossstatic intCAMERA_FROM_GALLERYTake the picture from the gallery.static intCAMERA_FULLstatic intCAMERA_NATIVEThe native camera application; a copy of the image is returned.static intCAMERA_NATIVE_NOCOPYThe native camera application; the original image is deleted and a copy of it is returned.static intCAMERA_PICTUREstatic intCAMERA_VIDEO_PLAYERStart video player for the file from defaultFileName.static intCAMERA_VIDEO_RECORDERRecord video.static intCAMERACAPTURE_MODE_STILLUsed in the cameraMode member.static intCAMERACAPTURE_MODE_VIDEOONLYUsed in the cameraMode member.static intCAMERACAPTURE_MODE_VIDEOWITHAUDIOUsed in the cameraMode member.static intCAMERACAPTURE_STILLQUALITY_DEFAULTUsed in the videoType member.static intCAMERACAPTURE_STILLQUALITY_HIGHUsed in the videoType member.static intCAMERACAPTURE_STILLQUALITY_LOWUsed in the videoType member.static intCAMERACAPTURE_STILLQUALITY_NORMALUsed in the videoType member.static intCAMERACAPTURE_VIDEOTYPE_ALLUsed in the captureMode member.static intCAMERACAPTURE_VIDEOTYPE_MESSAGINGUsed in the captureMode member.static intCAMERACAPTURE_VIDEOTYPE_STANDARDUsed in the captureMode member.intcameraTypeThe camera type; defaults to CAMERA_CUSTOM.intcaptureModeCapture mode; defaults to STILL.java.lang.StringdefaultFileNameThe default file name.static java.lang.StringfcbTitleThe default title when used in desktopjava.lang.StringinitialDirThe initial directory.intresolutionHeightThe height for the resolutionintresolutionWidthThe width for the resolutionintstillQualityThe still quality.inttargetFpsExpected FPS for the output file created with CAMERA_VIDEO_RECORDER.java.lang.StringtitleThe title to display in the window.intvideoTimeLimitMaximum time limit for recording a video.intvideoTypeVideo type; defaults to ALL.
-
Constructor Summary
Constructors Constructor Description Camera()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringclick()Takes a photo based on the members set.protected voidfinalize()static java.lang.String[]getSupportedResolutions()Returns the resolutions that are supported by the device.static java.lang.String[]getVideoResolutions()Returns the resolutions supported by the device for video recording using the back camera.
-
-
-
Field Detail
-
initialDir
public java.lang.String initialDir
The initial directory.
-
defaultFileName
public java.lang.String defaultFileName
The default file name.
-
title
public java.lang.String title
The title to display in the window.
-
stillQuality
public int stillQuality
The still quality.
-
videoType
public int videoType
Video type; defaults to ALL.
-
resolutionWidth
public int resolutionWidth
The width for the resolution
-
resolutionHeight
public int resolutionHeight
The height for the resolution
-
videoTimeLimit
public int videoTimeLimit
Maximum time limit for recording a video.
-
captureMode
public int captureMode
Capture mode; defaults to STILL.
-
allowRotation
public boolean allowRotation
This field is false by default so that the default camera orientation is still landscape. If this is set to true, the camera orientation will follow the device orientation. Used on Android only.
-
cameraType
public int cameraType
The camera type; defaults to CAMERA_CUSTOM.
-
targetFps
public int targetFps
Expected FPS for the output file created with CAMERA_VIDEO_RECORDER.
-
bitrate
public int bitrate
Video bitrate in kbps. Adjust this field to increase or decrease the quality and the size of the output video.Quality is subjective and context related, therefore it's hard to define objective values. Higher resolutions also requires higher bitrates for better results.
Values in the range of 100kbps (100_000) and 400kbps (400_000) should be enough for most videos up to HD resolution (1280x720 or
CAMERACAPTURE_STILLQUALITY_NORMAL).Values in the range of 1mbps (1_000_000) and 3mpbs (3_000_000) will provide the best quality a huge output file.
-
CAMERA_CUSTOM
public static final int CAMERA_CUSTOM
The original camera used in TotalCross- See Also:
- Constant Field Values
-
CAMERA_NATIVE
public static final int CAMERA_NATIVE
The native camera application; a copy of the image is returned.- See Also:
- Constant Field Values
-
CAMERA_NATIVE_NOCOPY
public static final int CAMERA_NATIVE_NOCOPY
The native camera application; the original image is deleted and a copy of it is returned.- See Also:
- Constant Field Values
-
CAMERA_FROM_GALLERY
public static final int CAMERA_FROM_GALLERY
Take the picture from the gallery.- See Also:
- Constant Field Values
-
CAMERA_VIDEO_PLAYER
public static final int CAMERA_VIDEO_PLAYER
Start video player for the file from defaultFileName.- See Also:
- Constant Field Values
-
CAMERA_VIDEO_RECORDER
public static final int CAMERA_VIDEO_RECORDER
Record video. Use the fields videoTimeLimit, targetFps and stillQuality to better control the result.- See Also:
- Constant Field Values
-
CAMERA_PICTURE
public static final int CAMERA_PICTURE
- See Also:
- Constant Field Values
-
CAMERA_FULL
public static final int CAMERA_FULL
- See Also:
- Constant Field Values
-
CAMERACAPTURE_MODE_STILL
public static final int CAMERACAPTURE_MODE_STILL
Used in the cameraMode member.- See Also:
- Constant Field Values
-
CAMERACAPTURE_MODE_VIDEOONLY
public static final int CAMERACAPTURE_MODE_VIDEOONLY
Used in the cameraMode member.- See Also:
- Constant Field Values
-
CAMERACAPTURE_MODE_VIDEOWITHAUDIO
public static final int CAMERACAPTURE_MODE_VIDEOWITHAUDIO
Used in the cameraMode member.- See Also:
- Constant Field Values
-
CAMERACAPTURE_STILLQUALITY_DEFAULT
public static final int CAMERACAPTURE_STILLQUALITY_DEFAULT
Used in the videoType member.- See Also:
- Constant Field Values
-
CAMERACAPTURE_STILLQUALITY_LOW
public static final int CAMERACAPTURE_STILLQUALITY_LOW
Used in the videoType member.- See Also:
- Constant Field Values
-
CAMERACAPTURE_STILLQUALITY_NORMAL
public static final int CAMERACAPTURE_STILLQUALITY_NORMAL
Used in the videoType member.- See Also:
- Constant Field Values
-
CAMERACAPTURE_STILLQUALITY_HIGH
public static final int CAMERACAPTURE_STILLQUALITY_HIGH
Used in the videoType member.- See Also:
- Constant Field Values
-
CAMERACAPTURE_VIDEOTYPE_ALL
public static final int CAMERACAPTURE_VIDEOTYPE_ALL
Used in the captureMode member.- See Also:
- Constant Field Values
-
CAMERACAPTURE_VIDEOTYPE_STANDARD
public static final int CAMERACAPTURE_VIDEOTYPE_STANDARD
Used in the captureMode member.- See Also:
- Constant Field Values
-
CAMERACAPTURE_VIDEOTYPE_MESSAGING
public static final int CAMERACAPTURE_VIDEOTYPE_MESSAGING
Used in the captureMode member.- See Also:
- Constant Field Values
-
fcbTitle
public static java.lang.String fcbTitle
The default title when used in desktop
-
-
Method Detail
-
click
public java.lang.String click() throws IOExceptionTakes a photo based on the members set.- Returns:
- The String with the file name where the image is located or null if the user canceled.
- Throws:
IOException- if any other error occurs.
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
getSupportedResolutions
public static java.lang.String[] getSupportedResolutions()
Returns the resolutions that are supported by the device. Works for Windows CE, Blackberry and Android.When the information is not available, a default list is returned and the first element is set to "Default values:".
If you take a photo and an image with a different resolution is returned, its because the selected resolution is not supported by the device.
Values are always in LANDSCAPE.
- Since:
- TotalCross 1.3
-
getVideoResolutions
public static java.lang.String[] getVideoResolutions()
Returns the resolutions supported by the device for video recording using the back camera. Currently, it works only on Android, other platforms return the same results asgetSupportedResolutions().When the information is not available, a default list is returned and the first element is set to "Default values:".
- Since:
- TotalCross 4.9.12
-
-