Camera widget allows you to capture pictures and videos using native Camera or using customized Camera (overlay Camera).
Some real-world scenarios when you can use Camera widget are as follows:
The key features of the Camera widget are as follows:
Compression: You can compress the image captured from the Camera widget to a manageable size. This image can then be either stored in the device or in a server.
RawBytes and base64: You can store the images captured from the Camera widget by using base64 string and raw bytes. These strings can then be assigned to an Image widget to view it in the application or be stored in a server for later use.
Back and Front Camera Compatibility: You can utilize both the front and back cameras of a mobile device by using a Camera widget.
Overlay: Overlay is a transparent form that is assigned to a Camera widget for customizing the camera screen.
Video Capturing: The Camera widget also has the capability to capture videos. You can change the mode of the camera to Video, and then capture the required video.
Camera widget is supported in Responsive Web/ Desktop Web platforms from Kony Visualizer V8 SP4 FP 20 onwards. You can create Camera widget for Responsive Web/ Desktop Web platforms through code only.
You can now capture images and videos by using the Camera widget with a web browser.
The following table displays the browser support for the various methods in Camera widget.
Browser Support | openCamera | closeCamera | takePicture | startVideoCapture | stopVideoCapture |
---|---|---|---|---|---|
Chrome(74.0) | |||||
Firefox (66.0) | |||||
Edge (42.17134) | |||||
IE (11.7) | |||||
Opera (60) | |||||
Mobile FireFox(66.0.2) | |||||
Mobile Chrome(74.0) (only using https) | |||||
Safari(11.12) | |||||
Safari iOS Mobile (only using https) | |||||
Chrome for MAC & iOS |
Widgets are normally added to your Kony application by using Kony Visualizer, but they can also be added through code. For general information on using widgets in Kony Visualizer, refer Designing an Application in the Kony Visualizer User Guide.
For general information on the Camera widget see the Camera topic in the Kony Visualizer User Guide.
Note: From Kony VisualizerV8 SP4 onwards, the Camera widget's data for a Kony Quantum App Viewer child app is stored in child app data and not under the parent app. This feature is applicable for iOS, Windows, and Android platforms.
For a more hands-on approach on the functionality of Camera widget, import and preview the Camera Feature sample app by using Kony Visualizer.
The Camera widget capabilities can be broadly categorized into the following:
Events | Description |
---|---|
doLayout | Invoked for every widget when the widget position and dimensions are computed. |
Properties | Description |
---|---|
bottom | Determines the bottom edge of the widget and is measured from the bottom bounds of the parent container. |
centerX | Determines the center of a widget measured from the left bounds of the parent container. |
centerY | Determines the center of a widget measured from the top bounds of the parent container. |
contentAlignment | Specifies the alignment of the text for a widget with respect to its boundaries. |
height | It determines the height of the widget and measured along the y-axis. |
left | Determines the lower left corner edge of the widget and is measured from the left bounds of the parent container. |
maxHeight | Specifies the maximum height of the widget and is applicable only when the height property is not specified. |
maxWidth | Specifies the maximum width of the widget and is applicable only when the width property is not specified. |
minHeight | Specifies the minimum height of the widget and is applicable only when the height property is not specified. |
minWidth | Specifies the minimum width of the widget and is applicable only when the width property is not specified. |
right | Determines the lower right corner of the widget and is measured from the right bounds of the parent container. |
top | Determines the top edge of the widget and measured from the top bounds of the parent container. |
width | Determines the width of the widget and is measured along the x-axis. |
zIndex | Specifies the stack order of a widget. |
Properties | Description |
---|---|
backgroundColor | Specifies the background color of the widget in hex format. |
focusSkin | Specifies the look and feel of the widget when in focus. |
hoverSkin | Specifies the look and feel of a widget when the cursor hovers on the widget. |
poster | Specifies the placeholder image for Camera widget when the device camera is not open. |
opacity | Specifies the opacity of the widget. |
skin |
Methods | Description |
---|---|
animate | Applies an animation to the widget. |
Methods | Description |
---|---|
closeCamera | Allows you to close the camera. |
getSupportedCameraSources | Returns an array of supported camera sources. |
openCamera | Opens the camera preview. |
startVideoCapture | Allows you to capture a video that will end as configured in the videoDuration property. |
stopVideoCapture | Allows you to stop a video that is being captured using startVideoCapture method. |
takePicture | Allows you to capture the picture when the camera is in preview mode. |
Properties | Description |
---|---|
cameraOptions | Specifies the camera options that can be used on a form. |
cameraSource | Specifies the source of the camera, either front or rear. |
captureOrientations | Specifies the orientation of the captured image. |
captureMode | Specifies the capture mode of the camera. |
compressionLevel | Specifies the compression level or picture quality with which the captured image must be stored. |
enableOverlay | The camera is launched with capability of over-lay a Form UI over the camera view. |
enablePhotoCropFeature | Enables you to crop the captured image. |
enableZoom | Set this property as true to enable pinch to zoom of the camera preview in the overlay mode. |
focusMode | Specifies the focus mode for the camera and is respected when the enableOverlay is set to true. |
imageFormat | Specifies if the image must be stored as a PNG (Portable Network Graphics) or a JPEG (Joint Photographic Experts Group) image. |
maxSideOfTheImage | Specifies the width of the camera picture/image. |
nativeUserInterface | Specifies if the camera must have the native interface on camera view (an interface with the default platform controls for camera) or the user interface with custom options. |
overlayConfig | Specifies the overlay configuration parameters for overlaying a form. |
scaleFactor | Specifies the ratio by which the captured image is reduced. |
supportedVideoQualityLevels | Returns an array of possible quality levels for the given device for the configured camera source. |
videoStabilization | Enables you to reduce the shaking of the camera while shooting a video. |
videoFormat | Specifies the video format of the captured video. |
videoDuration | Specifies the length of the captured video in seconds. |
videoQualityLevel | Specifies the quality of the video. |
Events | Description |
---|---|
onCapture | Invoked when the user captures a picture. |
onCaptureFailed | Invoked when the user has tapped on Don't Allow over permission alert and also when camera privacy is turned off under iPhone settings. |
onFailure | Invoked when an error occurs using a camera widget. |
onImageSaveFailed | Invoked when the user has performed some action over permission alert and also when image cannot be saved to photo album or due to data save error. |
Methods | Description |
---|---|
clone | When this method is used on a container widget, then all the widgets inside the container are cloned. |
Methods | Description |
---|---|
registerForPeekandPop | Registers a widget to enable 3D Touch peek and pop gestures. |
setOnPeek | Sets and overrides the existing onPeekCallback for the widget. |
setOnPop | Overrides the existing onPopCallback for the widget. |
unregisterForPeekandPop | Unregisters a widget from 3D Touch peek and pop gestures. |
Events | Description |
---|---|
onTouchEnd | Invoked by the platform when the user touch is released from the touch surface. |
onTouchMove | Invoked by the platform when the touch moves on the touch surface continuously until movement ends. |
onTouchStart | Invoked by the platform when the user touches the touch surface. |
Methods | Description |
---|---|
addGestureRecognizer | Allows you to set a gesture recognizer for a specified gesture for a specified widget. |
removeGestureRecognizer | Allows you to remove a child widget from a parent widget. |
setGestureRecognizer | Allows you to set a gesture recognizer for a specified gesture for a specified widget. |
Properties | Description |
---|---|
retainContentAlignment | Helps to retain the content alignment of the widget while applying RTL. |
retainFlexPositionProperties | Helps to retain the left, right and padding properties while applying RTL. |
retainFlowHorizontalAlignment | Enables you to change the horizontal flow of the widget from left to right. |
Methods | Description |
---|---|
getBadge | Enables you to read the badge value (if any) attached to the specified widget. |
setBadge | Enables you to set the badge value to the given widget at the upper, right corner of the widget. |
Properties | Description |
---|---|
accessMode | Specifies how the captured image must be stored. |
base64 | Returns the base64-encoded string of the image raw bytes. |
cursorType | Specifies the type of the mouse pointer used. |
rawBytes | Specifies the rawbytes representing an Image (usually the image captured from the camera) that can be used as a background for the Camera. |
Methods | Description |
---|---|
convertPointFromWidget | Allows you to convert the coordinate system from a widget to a point (receiver's coordinate system). |
convertPointToWidget | Allows you to convert the coordinate system from a widget to a point (receiver's coordinate system). |
removeFromParent | Allows you to remove a child widget from a parent widget. |
setEnabled | Specifies the widget that must be enabled or disabled. |
setFocus | Specifies the widget on which there must be focus. |
setVisibility | Use this method to set the visibility of the widget. |
Properties | Description |
---|---|
accessibilityConfig | Enables you to control accessibility behavior and alternative text for the widget. |
enableCache | Enables you to improve the performance of Positional Dimension Animations. |
id | id is a unique identifier of the Camera Widget consisting of alphanumeric characters. |
info | A custom JSObject with the key-value pairs that a developer can use to store the context with the widget. |
isVisible | Controls the visibility of a widget on the form. |
parent | Helps you access the parent of the widget. |
If you select the Camera widget, the phone camera is invoked to capture an image (which you can choose to accept or discard) and is stored as a PNG (Portable Network Graphics) image by default
Note: Camera widget is not supported for SPA platform.
The following are few examples where you can use a Camera widget:
var mycamera = new kony.ui.Camera(basicConf, layoutConf, pspConf);
Note: The configuration properties should be passed only in the respective configuration objects otherwise they are ignored.
Example
//Defining the properties for a Camera. var camBasic = { id: "camera1", skin: "camSkin", focusSkin: "camFSkin", text: "Camera", isVisible: true }; var camLayout = { containerWeight: 100, padding: [5, 5, 5, 5], margin: [5, 5, 5, 5], paddingInPixel: true, marginInPixel: true, hExpand: true, vExpand: true }; var camPSP = { enableOverlay: true }; //Creating the Camera. var camera1 = new kony.ui.Camera(camBasic, camLayout, camPSP); //Reading enableOverlay of Camera. alert("Camera enableOverlay::" + camera1.enableOverlay);
Note: For optimization, the raw bytes property can be read only once. Once it is read, the platform releases the handle. The camera image handle is provided to the action handler and if the action handler does not store the image handle, the image cannot be retrieved from the widget (the camera widget does not have the getImageHandle method).
To delete the rawbytes, use the releaseRawBytes method.
Common Issues
The following are the issues to avoid for a camera:
The following are the important considerations of the camera widget across all platforms and individual platforms:
Android: The following are the important considerations:
Windows 10: The following are the important considerations:
Limitations of Camera widget in video capture mode:
- captureOrientation
- compressionLevel
- transitionEffect
prem | Copyright © 2012 Kony, Inc. All rights reserved. |
prem | Copyright © 2012 Kony, Inc. All rights reserved. |