From a8b3d8bd7e33bfc7db58222df9c387ba2eeca4e6 Mon Sep 17 00:00:00 2001 From: nikhilraut Date: Mon, 31 Jan 2022 04:46:18 +0000 Subject: [PATCH 1/3] add en/application-dev/reference/apis/js-api-camera.md. --- en/application-dev/reference/apis/js-api-camera.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 en/application-dev/reference/apis/js-api-camera.md diff --git a/en/application-dev/reference/apis/js-api-camera.md b/en/application-dev/reference/apis/js-api-camera.md new file mode 100644 index 00000000000..1a1a068c514 --- /dev/null +++ b/en/application-dev/reference/apis/js-api-camera.md @@ -0,0 +1,14 @@ +# Camera + +## Modules to Import +``` +import camera from '@ohos.multimedia.camera'; +``` +## Required Permissions + +``` +ohos.permission.CAMERA +``` +## getCameraManager(context: Context, callback: AsyncCallback): void; + +Obtains an **CameraManager** instance. -- Gitee From 24f01c9aa22d42a0ed9d4cb2c5428abd8d391392 Mon Sep 17 00:00:00 2001 From: nikhilraut Date: Thu, 3 Feb 2022 04:20:09 +0000 Subject: [PATCH 2/3] Add JS camera api docs --- .../reference/apis/js-apis-camera.md | 1898 +++++++++++++++++ 1 file changed, 1898 insertions(+) create mode 100644 en/application-dev/reference/apis/js-apis-camera.md diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md new file mode 100644 index 00000000000..3aee9f3f8b2 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-camera.md @@ -0,0 +1,1898 @@ +# Camera + +## Modules to Import + +``` +import camera from '@ohos.multimedia.camera'; +``` + +## Required Permissions + +``` +ohos.permission.CAMERA +``` +## getCameraManager(context: Context, callback: AsyncCallback): void; + +Obtains the **CameraManager** instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|------------------------------|-----------|-----------------------------------------------------| +| context | Context | Yes | Application context | +| callback | AsyncCallback | Yes | Callback used to return the camera manager instance | + + +**Return values** + +none + +**Example** + +``` +camera.getCameraManager(context, (err, cameraManager) => { + if (err) { + console.error('Failed to get the camera manager ${err.message}'); + return; + } + console.log('Callback return with camera manager instance'); +}); +``` + +## getCameraManager(context: Context): Promise; + +Obtains the **CameraManager** instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------| +| context | Context | Yes | Application context | + +**Return values** + +| Type | Description | +|-------------------------|-------------------------------------------------| +| Promise | Promise used to return Camera manager instance | + +**Example** + +``` +camera.getCameraManager(context).then((cameraManger) => { + console.log('Promised returned with camera manager instance.'); +}) +``` + +## CameraStatus + +Enumerates camera status types. + +| Name | Default Value | Description | +|---------------------------|---------------|--------------------| +| CAMERA_STATUS_APPEAR | 0 | Camera appear | +| CAMERA_STATUS_DISAPPEAR | 1 | Camera disappear | +| CAMERA_STATUS_AVAILABLE | 2 | Camera available | +| CAMERA_STATUS_UNAVAILABLE | 3 | Camera unavailable | + + +## CameraPosition + +Enumerates for camera position. + +| Name | Default value | Description | +|-----------------------------|---------------|----------------------------------| +| CAMERA_POSITION_UNSPECIFIED | 0 | Camera position is not specified | +| CAMERA_POSITION_BACK | 1 | Back camera | +| CAMERA_POSITION_FRONT | 2 | Front camera | + +## CameraType + +Enumerates camera type. + +| Name | Default value | Description | +|-------------------------|---------------|-------------------------| +| CAMERA_TYPE_UNSPECIFIED | 0 | Camera type unspecified | +| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera | +| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera | +| CAMERA_TYPE_TELEPHOTO | 3 | Telephoto camera | +| CAMERA_TYPE_TRUE_DEPTH | 4 | True depth camera | + + +## ConnectionType + +Enumerates camera connection types. + +| Name | Default value | Description | +|------------------------------|---------------|----------------------------| +| CAMERA_CONNECTION_BUILT_IN | 0 | Device build in camera | +| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB | +| CAMERA_CONNECTION_REMOTE | 2 | Remote camera | + + +## CameraFormat + +Enumerates camera format. + +| Name | Default value | Description | +|----------------------------|---------------|---------------------| +| CAMERA_FORMAT_YCRCb_420_SP | 1003 | Camera YCRCb | +| CAMERA_FORMAT_JPEG | 2000 | Camera format jpeg | +| CAMERA_FORMAT_AVC | 3000 | Camera format avc | +| CAMERA_FORMAT_HEVC | 3001 | Camera format hevc | + + +## CameraManager + +Gets all device supported cameras and create the camera input. + +### getCameras(callback: AsyncCallback\>): void; + +Gets all device supported cameras. This method uses an asynchronous callback to return array device supported camera. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|------------------------------|-----------|-------------------------------------------------------| +| callback | AsyncCallback\> | Yes | Callback used to return array device supported camera.| + +**Return values** + +none + +**Example** + +``` +cameraManager.getCameras((err, cameras) => { + if (err) { + console.error('Failed to get the cameras. ${err.message}'); + return; + } + console.log('Callback return with array device supported camera :' + cameras.length); +}) +``` + +### getCameras(): Promise\>; + +Gets all device supported cameras. This method uses a promise to return the array of camera. + +**Parameters** + +none + +**Return values** + +| Type | Description | +|------------------------|------------------------------------------| +| Promise\> | Promise used to return supported cameras | + + +**Example** + +``` +cameraManager.getCameras().then((cameraArray) => { + console.log('Promised returned with cameras.' + cameraArray.length); +}) +``` + + +### createCameraInput(cameraId: string, callback: AsyncCallback): void; + +Create the camera input instance for the camera id. This method uses an asynchronous callback to returns the camera input instance. + +**Parameters** + +| Name | Default value | Mandatory | Description | +|----------|------------------------------|-----------|--------------------------------------------------| +| cameraId | string | Yes | Camera id to create the camera input | +| callback | AsyncCallback | Yes | Callback used to return the CameraInput instance | + +**Return values** + +none + +**Example** + +``` +cameraManager.createCameraInput(cameraId, (err, cameraInput) => { + if (err) { + console.error('Failed to get the cameraInput. ${err.message}'); + return; + } + console.log('Callback return with cameraInput obj'); +}) +``` + +### createCameraInput(cameraId: string): Promise; + +Create the camera input instance for the camera id. This method uses a promise to return the CameraInput instance. + +**Parameters** + +| Name | Default value | Mandatory | Description | +|----------|-----------------------------|-----------|--------------------------------------------------| +| cameraId | string | Yes | Camera id to create the camera input instance | + +**Return values** + +| Type | Description | +|-------------------------|---------------------------------------------| +| Promise | Promise used to return CameraInput instance | + +**Example** + +``` +cameraManager.createCameraInput(cameraId).then((cameraInput) => { + console.log('Promised returned with CameraInput instance'); +}) +``` + +### createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void; + +Create the camera input instance from camera position and camera type. This method uses an asynchronous callback to return the camera input instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------------|----------------------------|-----------|----------------------------------------| +| cameraPosition | CameraPosition | Yes | Camera position | +| cameraType | CameraType | Yes | Camera type | +| callback | AsyncCallback | Yes | Callback to get the CameraInput instance | + +**Return values** + +none + +**Example** + +``` +cameraManager.createCameraInput(cameraPosition, cameraType, (err, cameraInput) => { + if (err) { + console.error('Failed to get the cameraInput. ${err.message}'); + return; + } + console.log('Callback return with cameraInput instance'); +}) +``` + +### createCameraInput(position: CameraPosition, type: CameraType): Promise; + +Create the camera input instance from camera position and camera type. This method uses a promise to return the CameraInput instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------------|----------------------------|-----------|----------------------------------------| +| cameraPosition | CameraPosition | Yes | Camera position | +| cameraType | CameraType | Yes | Camera type | + +**Return values** + +| Type | Description | +|------------------------|---------------------------------------------| +| Promise | Promise used to return CameraInput instance | + +**Example** + +``` +cameraManager.createCameraInput(cameraPosition, cameraType).then((cameraInput) => { + console.log('Promised returned with cameraInput.'); +}) +``` + +## Camera + +Camera class. + +**Fields** + +| Name | Type | Access | Description | +|----------------|----------------|----------|------------------------| +| cameraId | string | readonly | Camera id | +| cameraPosition | cameraPosition | readonly | Camera position | +| cameraType | cameraType | readonly | Camera type | +| connectionType | connectionType | readonly | Camera connection type | + +``` +var cameraManager = await camera.getCameraManager(); +var cameras = await cameraManager.getCameras(); +var cameraObj = cameras[0]; +var cameraId = cameraObj.cameraId; +var cameraPosition = cameraObj.cameraPosition; +var cameraType = cameraObj.cameraType; +var cameraId = cameraObj.connectionType; + +``` + +## CameraInput + +Camera input instance. + +### getCameraId(callback: AsyncCallback\): void; + +Get camera id for which CameraInput created. This method uses an asynchronous callback to return the cameraId. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|------------------------|-----------|----------------------------------| +| callback | AsyncCallback | Yes | Callback to return the camera Id | + +**Return values** + +none + +``` +cameraInput.getCameraId((err, cameraId) => { + if (err) { + console.error('Failed to get the cameraId. ${err.message}'); + return; + } + console.log('Callback return with cameraId ' + cameraId); +}) +``` + +### getCameraId(): Promise; + +Get camera id for which CameraInput created. This method uses a promise to return the camera id. + +**Parameters** + +none + +**Return values** + +| Type | Description | +|------------------------|------------------------------------------------------| +| Promise | Promise used to return camera id of the camera input | + +**Example** + +``` +cameraInput.getCameraId().then((cameraId) => { + console.log('Promised returned with camera id:' + cameraId); +}) +``` + +### getSupportedSizes\(format: CameraFormat, callback: AsyncCallback\>\): void; + +Get supported sizes for given format. This method uses an asynchronous callback to return supported sizes. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------------|-----------|---------------------------------| +| format | CameraFormat | Yes | Camera format to get Sizes | +| callback | AsyncCallback\> | Yes | Callback to get supported sizes | + + +**Return values** + +none + +**Example** + +``` +cameraInput.getSupportedSizes(format, (err, sizes) => { + if (err) { + console.error('Failed to get the supported sizes. ${err.message}'); + return; + } + console.log('Callback return with supported sizes : ' + sizes); +}) +``` + + +### getSupportedSizes\(format: CameraFormat\): Promise\>; + +Get supported sizes for given format. This method uses a promise to return supported sizes. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------------|-----------|--------------------------------------| +| format | CameraFormat | Yes | Camera format to get supported Sizes | + +**Return values** + +| Type | Description | +|------------------------|--------------------------------------------------------| +| Promise\> | Promise used to return supported sizes for the format. | + +**Example** + +``` +cameraInput.getSupportedSizes(format).then((sizes) => { + console.log('Promised returned with supported sizes.' + sizes); +}) +``` + +### getSupportedPreviewFormats\(callback: AsyncCallback\>\): void; + +Get supported formats for preview. This method uses an asynchronous callback to return supported sizes. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|--------------------------------------|-----------|---------------------------------------------------| +| callback | AsyncCallback\> | Yes | Callback to return the supported preview formats. | + + +**Return values** + +none + +**Example** + +``` +cameraInput.getSupportedPreviewFormats((err, previewFormats) => { + if (err) { + console.error('Failed to get the supported preview formats. ${err.message}'); + return; + } + console.log('Callback return with supported preview formats : ' + previewFormats.length); +}) +``` + + +### getSupportedPreviewFormats\(\): Promise\>; + +Get supported formats for preview. This method uses a promise to return supported preview formats. + +**Parameters** + +none + +**Return values** + +| Type | Description | +|--------------------------------|---------------------------------------------------| +| Promise\> | Promise used to return supported preview formats. | + +**Example** + +``` +cameraInput.getSupportedPreviewFormats().then((previewFormats) => { + console.log('Promised returned with supported preview formats.' + previewFormats.length); +}) +``` + +### getSupportedPhotoFormats\(callback: AsyncCallback\>\): void; + +Get supported formats for photo. This method uses an asynchronous callback to return supported photo formats. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|--------------------------------------|-----------|-------------------------------------------------| +| callback | AsyncCallback\> | Yes | Callback to return the supported photo formats. | + +**Return values** + +none + +**Example** + +``` +cameraInput.getSupportedPhotoFormats((err, photoFormats) => { + if (err) { + console.error('Failed to get the supported photo formats. ${err.message}'); + return; + } + console.log('Callback return with supported photo formats'); +}) +``` + +### getSupportedPhotoFormats\(\): Promise\>; + +Get supported formats for the photo. This method uses a promise to return the supported photo formats. + +**Parameters** + +none + +**Return values** + +| Type | Description | +|--------------------------------|---------------------------------------------------| +| Promise\> | Promise used to return supported photo formats. | + +**Example** + +``` +cameraInput.getSupportedPhotoFormats().then((photoFormats) => { + console.log('Promised returned with supported photo formats.' + photoFormats.length); +}) +``` + +### getSupportedVideoFormats\(callback: AsyncCallback\>\): void; + +Get supported formats for the video. This method uses an asynchronous callback to return the supported video formats. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|--------------------------------------|-----------|-------------------------------------------------| +| callback | AsyncCallback\> | Yes | Callback to return the supported video formats. | + +**Return values** + +none + +**Example** + +``` +cameraInput.getSupportedVideoFormats((err, videoFormats) => { + if (err) { + console.error('Failed to get the supported video formats. ${err.message}'); + return; + } + console.log('Callback return with supported video formats : ' + videoFormats.length); +}) +``` + +### getSupportedVideoFormats\(\): Promise\>; + +Get supported formats for the video. This method uses a promise to return the supported video format. + +**Parameters** + +none + +**Return values** + +| Type | Description | +|--------------------------------|---------------------------------------------------| +| Promise\> | Promise used to return supported video formats. | + +**Example** + +``` +cameraInput.getSupportedVideoFormats().then((videoFormats) => { + console.log('Promised returned with supported video formats.' + videoFormats.length); +}) +``` + +### hasFlash(callback: AsyncCallback): void; + +Check if device has flash light. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|-------------------------|-----------|----------------------------------------------------| +| callback | AsyncCallback | Yes | Callback to return the device flash support status | + +**Return values** + +none + +**Example** + +``` +cameraInput.hasFlash((err, status) => { + if (err) { + console.error('Failed to check if device has flash light. ${err.message}'); + return; + } + console.log('Callback return with flash light support status : ' + status); +}) +``` + +### hasFlash(): Promise; + +Check if device has flash light. This method uses a promise to return the execution result. + +**Parameters** + +none + +**Return values** + +| Type | Description | +|-----------------------|-----------------------------------------------------------| +| Promise | Promise used to return device flash light support status. | + +**Example** + +``` +cameraInput.hasFlash().then((status) => { + console.log('Promised returned with device flash light support status.' + status); +}) +``` + +### isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void; + +Check for flash mode support. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-----------|------------------------|-----------|----------------------------------------------------| +| flashMode | FlashMode | Yes | Flash mode | +| callback | AsyncCallback | Yes | Callback to return the device flash support status | + +**Return values** + +none + +**Example** + +``` +cameraInput.isFlashModeSupported(flashMode, (err, status) => { + if (err) { + console.error('Failed to check flash mode supported. ${err.message}'); + return; + } + console.log('Callback return with flash mode support status : ' + status); +}) +``` + +### isFlashModeSupported(flashMode: FlashMode): Promise; + +Check for flash mode support. This method uses a promise to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-----------|------------------------|-----------|----------------------------------------------------| +| flashMode | FlashMode | Yes | Flash mode | + +**Return values** + +| Type | Description | +|-----------------------|---------------------------------------------------| +| Promise | Promise used to return flash mode support status. | + +**Example** + +``` +cameraInput.isFlashModeSupported(flashMode).then((status) => { + console.log('Promised returned with flash mode support status.' + status); +}) +``` +## FlashMode + +Enum for flash mode + +| Name | Default value | Description | +|------------------------|---------------|------------------------| +| FLASH_MODE_CLOSE | 0 | Flash mode close | +| FLASH_MODE_OPEN | 1 | Flash mode open | +| FLASH_MODE_AUTO | 2 | Flash mode auto | +| FLASH_MODE_ALWAYS_OPEN | 3 | Flash mode always open | + + +## createCaptureSession\(context: Context, callback: AsyncCallback\): void; + +Obtains the **CaptureSession** instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|--------------------------------|-----------|-----------------------------------------------------| +| context | Context | Yes | Application Context | +| callback | AsyncCallback | Yes | Callback used to return the CaptureSession instance | + +**Return values** + +none + +**Example** + +``` +camera.createCaptureSession(context), (err, captureSession) => { + if (err) { + console.error('Failed to get the CaptureSession ${err.message}'); + return; + } + console.log('Callback return with CaptureSession instance' + captureSession); +}); +``` + +## createCaptureSession(context: Context\): Promise; + +Create the CaptureSession. This method uses a promise to return the CaptureSession instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|-------------------------------|-----------|-----------------------------------------------------| +| context | Context | Yes | Application Context | + +**Return values** + +| Type | Description | +|---------------------------|---------------------------------------------------| +| Promise | Promise used to return CaptureSession instance. | + +**Example** + +``` +camera.createCaptureSession(context).then((captureSession) => { + console.log('Promised returned with CaptureSession instance'); +}) +``` + +## CaptureSession + +Capture session. + +### beginConfig\(callback: AsyncCallback\): void; + +Start configuration for the capture session. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|---------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the execution result | + + +**Return values** + +none + +**Example** + +``` +camera.beginConfig((err) => { + if (err) { + console.error('Failed to start begin session ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the begin config success.'); +}); +``` + +### beginConfig\(\): Promise; + +Start configuration for the capture session. This method uses a promise to return the execution result. + +**Parameters** + +none + +**Return values** + +| Type | Description | +|---------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + + +**Example** + +``` +camera.beginConfig().then(() => { + console.log('Promise returned to indicate that the begin config success.'); +}) +``` + +### commitConfig\(callback: AsyncCallback\): void; + +Commit the for the capture session settings. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|---------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +camera.commitConfig((err) => { + if (err) { + console.error('Failed to commit session ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the commit config success.'); +}); +``` + + +### commitConfig\(\): Promise; + +Save the capture session config. This method uses a promise to return the execution result. + +**Parameters** + +none + +**Return values** + +| Type | Description | +|---------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + +**Example** + +``` +camera.commitConfig().then(() => { + console.log('Promise returned to indicate that the commit config success.'); +}) +``` + +### addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void; + +Add camera input to the capture session. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-------------|---------------------|-----------|----------------------------------------------| +| cameraInput | CameraInput | Yes | Camera input for the session | +| callback | AsyncCallback | Yes | Callback used to return the execution result | + + +**Return values** + +none + +**Example** + +``` +camera.addInput(cameraInput, (err) => { + if (err) { + console.error('Failed to add input session ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the cameraInput added into session.'); +}); +``` + +### addInput\(cameraInput: CameraInput\): Promise; + +Add camera input to the capture session. This method uses a promise to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-------------|---------------------|-----------|----------------------------------------------| +| cameraInput | CameraInput | Yes | Camera input for the session | + +**Return values** + +| Type | Description | +|---------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + +**Example** + +``` +camera.addInput(cameraInput).then(() => { + console.log('Promise returned to indicate that add input success.'); +}) +``` + +### addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void; + +Add preview output to the capture session. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|----------------------------------------------| +| previewOutput | PreviewOutput | Yes | Preview output for the session | +| callback | AsyncCallback | Yes | Callback used to return the execution result | + + +**Return values** + +none + +**Example** + +``` +camera.addOutput(previewOutput, (err) => { + if (err) { + console.error('Failed to add previewOutput to the session ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the previewOutput added into session.'); +}); +``` + +### addOutput\(previewOutput: PreviewOutput\): Promise; + +Add preview output to the capture session. This method uses a promise to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|----------------------------------------------| +| previewOutput | PreviewOutput | Yes | Preview output for the session | + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + +**Example** + +``` +camera.addOutput(previewOutput).then(() => { + console.log('Promise returned to indicate that add preview output success.'); +}) +``` + +### addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback\): void; + +Add photo output to the capture session. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|----------------------------------------------| +| photoOutput | PhotoOutput | Yes | Photo output for the session | +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +camera.addOutput(photoOutput, (err) => { + if (err) { + console.error('Failed to add PhotoOutput to the session ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the PhotoOutput added into session.'); +}); +``` + +### addOutput\(photoOutput: PhotoOutput\): Promise; + +Add photo output to the capture session. This method uses a promise to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|----------------------------------------------| +| photoOutput | PhotoOutput | Yes | Photo output for the session | + +**Return values** + +| Type | Description | +|---------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + +**Example** + +``` +camera.addOutput(photoOutput).then(() => { + console.log('Promise returned to indicate that add photo output success.'); +}) +``` + +### addOutput\(videoOutput: VideoOutput, callback: AsyncCallback\): void; + +Add video output to the capture session. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|----------------------------------------------| +| videoOutput | VideoOutput | Yes | Video output for the session | +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +camera.addOutput(videoOutput, (err) => { + if (err) { + console.error('Failed to add VideoOutput to the session ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the VideoOutput added into session.'); +}); +``` + +### addOutput\(videoOutput: VideoOutput\): Promise; + +Add video output to the capture session. This method uses a promise to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|----------------------------------------------| +| videoOutput | VideoOutput | Yes | Video output for the session | + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + +**Example** + +``` +camera.addOutput(videoOutput).then(() => { + console.log('Promise returned to indicate that add video output success.'); +}) +``` + +### removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void; + +Remove camera input from the capture session. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-------------|----------------------|-----------|----------------------------------------------| +| cameraInput | CameraInput | Yes | Camera input for the session | +| callback | AsyncCallback | Yes | Callback used to return the execution result | + + +**Return values** + +none + +**Example** + +``` +camera.removeInput(cameraInput, (err) => { + if (err) { + console.error('Failed to remove the camera input from session ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the cameraInput removed into session.'); +}); +``` + +### removeInput\(cameraInput: CameraInput\): Promise; + +Remove camera input from the capture session. This method uses a promise to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|-------------|---------------------|-----------|----------------------------------------------| +| cameraInput | CameraInput | Yes | Camera input for the session | + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + +**Example** + +``` +camera.removeInput(cameraInput).then(() => { + console.log('Promise returned to indicate that remove camera input success.'); +}) +``` + +### removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void; + +Remove preview output from the capture session. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|----------------------|-----------|----------------------------------------------| +| previewOutput | PreviewOutput | Yes | Preview output for the session | +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +camera.removeOutput(previewOutput, (err) => { + if (err) { + console.error('Failed to remove previewOutput from the session ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the previewOutput removed from session.'); +}); +``` + +### removeOutput(previewOutput: PreviewOutput): Promise; + +Remove preview output from the capture session. This method uses a promise to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|----------------------------------------------| +| previewOutput | PreviewOutput | Yes | Preview output for the session | + + +**Return values** + +| Type | Description | +|---------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + + +**Example** + +``` +camera.removeOutput(previewOutput).then(() => { + console.log('Promise returned to removeOutput function executed.'); +}) +``` + +### removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void; + +Remove photo output from the capture session. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|----------------------|-----------|----------------------------------------------| +| photoOutput | PhotoOutput | Yes | Photo output for the session | +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +camera.removeOutput(photoOutput, (err) => { + if (err) { + console.error('Failed to remove photoOutput from the session ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the photoOutput removed from session.'); +}); +``` + +### removeOutput(photoOutput: PhotoOutput): Promise; + +Remove photo output from the capture session. This method uses a promise to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|----------------------------------------------| +| photoOutput | PhotoOutput | Yes | Photo output for the session | + + +**Return values** + +| Type | Description | +|---------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + + +**Example** + +``` +camera.removeOutput(photoOutput).then(() => { + console.log('Promise returned to removeOutput function executed.'); +}) +``` + +### removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void; + +Remove video output from the capture session. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|----------------------|-----------|----------------------------------------------| +| videoOutput | VideoOutput | Yes | Video output for the session | +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +camera.removeOutput(videoOutput, (err) => { + if (err) { + console.error('Failed to remove videoOutput from the session ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the videoOutput removed from session.'); +}); +``` + +### removeOutput(videoOutput: VideoOutput): Promise; + +Remove video output from the capture session. This method uses a promise to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|---------------|---------------------|-----------|----------------------------------------------| +| videoOutput | VideoOutput | Yes | Video output for the session | + + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + + +**Example** + +``` +camera.removeOutput(videoOutput).then(() => { + console.log('Promise returned to removeOutput function executed.'); +}) +``` + +### start\(callback: AsyncCallback\): void; + +Start the session. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +camera.start((err) => { + if (err) { + console.error('Failed to start the session ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the session start success.'); +}); +``` + +### start\(\): Promise; + +Start the capture session. This method uses a promise to return the execution result. + +**Parameters** + +none + +**Return values** + +| Type | Description | +|---------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + +**Example** + +``` +camera.start().then(() => { + console.log('Promise returned to indicate that the session started success.'); +}) +``` + +### stop\(callback: AsyncCallback\): void; + +Stop the session. This method uses an asynchronous callback to return the execution result. + +**Parameters** + + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +camera.stop((err) => { + if (err) { + console.error('Failed to stop the session ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the session stop success.'); +}); +``` + + +### stop(): Promise; + +Stop the capture session. This method uses a promise to return the execution result. + +**Parameters** + +none + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + +**Example** + +``` +camera.stop().then(() => { + console.log('Promise returned to indicate that the session stop success.'); +}) +``` + +### release\(callback: AsyncCallback\): void; + +Release the session. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +camera.release((err) => { + if (err) { + console.error('Failed to release the session ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the session release success.'); +}); +``` + +### release(): Promise; + +Release the capture session. This method uses a promise to return the execution result. + +**Parameters** + +none + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + +**Example** + +``` +camera.release().then(() => { + console.log('Promise returned to indicate that session release success.'); +}) +``` + +## createPreviewOutput(surfaceId: string, callback: AsyncCallback): void; + +Obtains the **PreviewOutput** instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|------------|-------------------------------|-----------|----------------------------------------------------| +| surfaceId | string | Yes | Surface id received from XComponent view | +| callback | AsyncCallback | Yes | Callback used to return the PreviewOutput instance | + +**Return values** + +none + +**Example** + +``` +camera.createPreviewOutput(surfaceId), (err, previewOutput) => { + if (err) { + console.error('Failed to get the previewOutput ${err.message}'); + return; + } + console.log('Callback return with previewOutput instance'); +}); +``` + +## createPreviewOutput(surfaceId: string): Promise; + +Create the PreviewOutput. This method uses a promise to return the PreviewOutput instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|------------|-----------------|-----------|----------------------------------------------------| +| surfaceId | string | Yes | Surface id received from XComponent view | + +**Return values** + +| Type | Description | +|-------------------------|------------------------------------------| +| Promise | Promise used to return the PreviewOutput | + +**Example** + +``` +camera.createPreviewOutput(surfaceId).then((previewOutput) => { + console.log('Promised returned with previewOutput instance'); +}) +``` + +## PreviewOutput + +Preview output + +### release(callback: AsyncCallback): void; + +Release the preview output. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +previewOutput.release((err) => { + if (err) { + console.error('Failed to release the previewOutput ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the previewOutput release success.'); +}); +``` + +### release(): Promise; + +Release the preview output. This method uses a promise to return the execution result. + +**Parameters** +none + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + + +**Example** + +``` +previewOutput.release().then(() => { + console.log('Promise returned to indicate that release method execution success.'); +}) +``` + +## createPhotoOutput(surfaceId: string, callback: AsyncCallback): void; + +Obtains the **PhotoOutput** instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|------------|-------------------------------|-----------|----------------------------------------------------| +| surfaceId | string | Yes | Surface id received from ImageReceiver | +| callback | AsyncCallback | Yes | Callback used to return the PhotoOutput instance | + +**Return values** + +none + +**Example** + +``` +camera.createPhotoOutput(surfaceId), (err, photoOutput) => { + if (err) { + console.error('Failed to get the PhotoOutput ${err.message}'); + return; + } + console.log('Callback return with PhotoOutput instance'); +}); +``` + +## createPhotoOutput(surfaceId: string): Promise; + +Create the PhotoOutput. This method uses a promise to return the PhotoOutput instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|------------|-----------------|-----------|----------------------------------------------------| +| surfaceId | string | Yes | Surface id received from ImageReceiver | + +**Return values** + +| Type | Description | +|-------------------------|------------------------------------------| +| Promise | Promise used to return the PhotoOutput | + +**Example** + +``` +camera.createPhotoOutput(surfaceId).then((photoOutput) => { + console.log('Promised returned with PhotoOutput instance'); +}) +``` +## ImageRotation + +Enumerates Image rotation. +| Name | Default Value | Description | +|--------------|---------------|-----------------------------------| +| ROTATION_0 | 0 | Capture image rotation 0 degree | +| ROTATION_90 | 90 | Capture image rotation 90 degree | +| ROTATION_180 | 180 | Capture image rotation 180 degree | +| ROTATION_270 | 270 | Capture image rotation 270 degree | + + +## Location + +Capture image location + +| Name | Type | Access | Description | +|-----------|--------|--------------|-------------| +| latitude | number | read / write | Latitude | +| longitude | number | read / write | Longitude | + +## QualityLevel +Enumerates for image quality level + +| Name | Default value | Description | +|----------------------|---------------|----------------------| +| QUALITY_LEVEL_HIGH | 0 | Image quality high | +| QUALITY_LEVEL_MEDIUM | 1 | Image quality medium | +| QUALITY_LEVEL_LOW | 2 | Image quality low | + + +## PhotoCaptureSetting +Setting to capture the image. + +| Name | Type | Mandatory | Description | +|----------|---------------|-----------|---------------------| +| quality | QualityLevel | Optional | Photo image quality | +| rotation | ImageRotation | Optional | Photo rotation. | +| location | Location | Optional | Photo location. | +| mirror | boolean | Optional | Mirror mode. | + + +## PhotoOutput + +Photo output + +### capture(callback: AsyncCallback): void; + +Photo capture. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|---------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +photoOutput.capture((err) => { + if (err) { + console.error('Failed to capture the photo ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the photo capture request success.'); +}); +``` + +### capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void; + +Photo capture with capture settings. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| setting | PhotoCaptureSetting | Yes | Photo capture settings | +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +photoOutput.capture(settings, (err) => { + if (err) { + console.error('Failed to capture the photo ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the photo capture request success.'); +}); +``` + +### capture(setting?: PhotoCaptureSetting): Promise; + +Capture the photo request. This method uses a promise to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|---------------------|-----------|----------------------------------------------| +| setting | PhotoCaptureSetting | No | Photo capture settings | + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + + +**Example** + +``` +photoOutput.capture().then(() => { + console.log('Promise returned to indicate that photo capture request success.'); +}) +``` + +### release(callback: AsyncCallback): void; + +Release the photo output. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +photoOutput.release((err) => { + if (err) { + console.error('Failed to release the PhotoOutput ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the photoOutput release success.'); +}); +``` + +### release(): Promise; + +Release the photo output. This method uses a promise to return the execution result. + +**Parameters** +none + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + + +**Example** + +``` +photoOutput.release().then(() => { + console.log('Promise returned to indicate that release method execution success.'); +}) +``` + +## createVideoOutput(surfaceId: string, callback: AsyncCallback): void; + +Obtains the **VideoOutput** instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|------------|-------------------------------|-----------|----------------------------------------------------| +| surfaceId | string | Yes | Surface id received from VideoRecorder | +| callback | AsyncCallback | Yes | Callback used to return the VideoOutput instance | + +**Return values** + +none + +**Example** + +``` +camera.createVideoOutput(surfaceId), (err, videoOutput) => { + if (err) { + console.error('Failed to get the VideoOutput ${err.message}'); + return; + } + console.log('Callback return with VideoOutput instance'); +}); +``` + +## createVideoOutput(surfaceId: string): Promise; + +Create the VideoOutput. This method uses a promise to return the VideoOutput instance. + +**Parameters** + +| Name | Type | Mandatory | Description | +|------------|-----------------|-----------|----------------------------------------------------| +| surfaceId | string | Yes | Surface id received from ImageReceiver | + +**Return values** + +| Type | Description | +|-------------------------|------------------------------------------| +| Promise | Promise used to return the VideoOutput | + +**Example** + +``` +camera.createVideoOutput(surfaceId).then((videoOutput) => { + console.log('Promised returned with VideoOutput instance'); +}) +``` + +### start(callback: AsyncCallback): void; + +Start the video output. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +videoOutput.start((err) => { + if (err) { + console.error('Failed to start the video output ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the video output start success.'); +}); +``` + +### start(): Promise; + +Start the video output. This method uses a promise to return the execution result. + +**Parameters** +none + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + + +**Example** + +``` +videoOutput.start().then(() => { + console.log('Promise returned to indicate that start method execution success.'); +}) +``` + +### stop(callback: AsyncCallback): void; + +Stop the video output. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +videoOutput.stop((err) => { + if (err) { + console.error('Failed to stop the video output ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the video output stop success.'); +}); +``` + +### stop(): Promise; + +Stop the video output. This method uses a promise to return the execution result. + +**Parameters** +none + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + +**Example** + +``` +videoOutput.start().then(() => { + console.log('Promise returned to indicate that stop method execution success.'); +}) +``` + +### release(callback: AsyncCallback): void; + +Release the video output. This method uses an asynchronous callback to return the execution result. + +**Parameters** + +| Name | Type | Mandatory | Description | +|----------|----------------------|-----------|----------------------------------------------| +| callback | AsyncCallback | Yes | Callback used to return the execution result | + +**Return values** + +none + +**Example** + +``` +videoOutput.release((err) => { + if (err) { + console.error('Failed to release the videoOutput ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the videoOutput release success.'); +}); +``` + +### release(): Promise; + +Release the video output. This method uses a promise to return the execution result. + +**Parameters** +none + +**Return values** + +| Type | Description | +|----------------|---------------------------------------------| +| Promise | Promise used to return the execution result | + + +**Example** + +``` +videoOutput.release().then(() => { + console.log('Promise returned to indicate that release method execution success.'); +}) +``` \ No newline at end of file -- Gitee From 21317ac1fe95ded9caf06833ced9e62230213b2e Mon Sep 17 00:00:00 2001 From: nikhilraut Date: Thu, 3 Feb 2022 04:23:37 +0000 Subject: [PATCH 3/3] Remove en/application-dev/reference/apis/js-api-camera.md --- en/application-dev/reference/apis/js-api-camera.md | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 en/application-dev/reference/apis/js-api-camera.md diff --git a/en/application-dev/reference/apis/js-api-camera.md b/en/application-dev/reference/apis/js-api-camera.md deleted file mode 100644 index 1a1a068c514..00000000000 --- a/en/application-dev/reference/apis/js-api-camera.md +++ /dev/null @@ -1,14 +0,0 @@ -# Camera - -## Modules to Import -``` -import camera from '@ohos.multimedia.camera'; -``` -## Required Permissions - -``` -ohos.permission.CAMERA -``` -## getCameraManager(context: Context, callback: AsyncCallback): void; - -Obtains an **CameraManager** instance. -- Gitee