com.webos.service.camera2

Note
This API has been available since API level 11.

API Summary

Provides an interface to capture and stream images from a camera that is connected to a webOS device.

Note: Currently, only V4L2 USB cameras are supported.

It provides the following features:

  • Live Camera Preview: Continuously streams live data from the camera to the shared memory (SystemV and POSIX). The data on the shared memory can be used by applications either using the native shared memory API for Linux or through multimedia middleware framework like GStreamer.
  • Capture Images: Allows capturing images in various modes. You can take single or multiple images based on the selected mode. 
  • Control Camera Settings: Allows you to adjust the camera frame size, output format, and properties such as brightness, exposure, and so on.

Overview of the API

N/A

Methods

capture

ACG: camera.operation
  • Added: API level 27

Description

Starts capturing images using the camera. The captured images are stored as separate files at the specified location.

The default file name is of the format PictureDDMMYYYY-HHMMSS, where DDMMYYYY-HHMMSS is current date and time. Example: /tmp/Picture11022019-204128.jpeg.

Note: By default, captured images are saved in the /tmp/ folder.

Parameters

Name

Required

Type

Description

handleRequiredNumber

Indicates the handle for the device obtained using the open() API.

nimageOptionalNumber

Indicates the number of images to be captured.

Note: Default = 1, max = 30

pathOptionalString

Indicates the location where the captured images are to be saved.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Operation is successful.
  • false: Operation has failed. Check the 'errorCode' and 'errorText' fields.
pathOptionalString array

Indicates the path and file names of the captured images.

errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

The reason for the failure of the operation. See the 'API Error Codes Reference' section for details.

Error Codes Reference

Error Code

Error Text

Error Description

22, 39, 45Depends on error code

Check details in the "API Error Codes Reference" table.

Example

Example : Capture two images

# luna-send -n 1 -f luna://com.webos.service.camera2/capture '{"handle": 189,"nimage": 2}'

Response:

{
    "returnValue": true,
    "path": [
        "/tmp/Picture11022019-204128.jpeg",
        "/tmp/Picture11022019-204230.jpeg
     ]
}

close

ACG: camera.operation
  • Added: API level 11

Description

Closes the connection between the camera and the webOS device.

Parameters

Name

Required

Type

Description

handleRequiredNumber

Indicates the handle for the device obtained using the open() API. 

pidOptionalNumber

Indicates the client process ID that should be unregistered (or eliminated) from the pool the camera service manages.

Note: When the camera was opened with a valid PID, this parameter is required (mandatory), otherwise the device is not closed and the method returns false.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

pidOptionalNumber

Indicates the client process ID

Example

Example code

# luna-send -n 1 -f luna://com.webos.service.camera2/close '{"handle":886}'

Response:

{
   "returnValue":true
}

Example : App requires shared memory synchronization, with default signal

# luna-send -n 1 -f luna://com.webos.service.camera2/close '{"handle":6393, "pid": 1804}'

Response:

{
   "returnValue": true,
   "pid": 1804
}

Example : App requires shared memory synchronization, with a specified signal

# luna-send -n 1 -f luna://com.webos.service.camera2/close '{"handle":2516, "pid": 1430}'

Response;

{
   "returnValue": true,
   "pid": 1430
}

getCameraList

ACG: camera.query
  • Added: API level 11

Description

Gets the list of cameras connected to the webOS device. Returns IDs for each of the cameras connected to the device.

Parameters

Name

Required

Type

Description

subscribeOptionalBoolean

Subscribe for notifications on changes.

Possible values are:

  • true: Subscribed.
  • false: (default) Not subscribed.

Call Returns

Name

Required

Type

Description

deviceListOptionalObject array: deviceList

Indicates the list of cameras connected to the device. 

Note: The method returns an empty list if no camera is connected.

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
subscribedOptionalBoolean

Indicates if subscribed to get notifications.  

Note: Returns only if the subscribe is true.

errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Subscription Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

subscribedOptionalBoolean

Indicates if subscribed to get notifications.

deviceListOptionalObject array: deviceList

Indicates the list of cameras connected to the device. 

Note: The method returns an empty list if no camera is connected.

errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Example

Example code

# luna-send -n 1 -f luna://com.webos.service.camera2/getCameraList '{}'

Response:

{  
   "deviceList":[  
      {  
         "id":"camera1"
      }
   ],
   "returnValue":true
}

Example : With subscription

# luna-send -i -f luna://com.webos.service.camera2/getCameraList '{"subscribe":true}'

Response:

{
    "subscribed":true,
    "returnValue":true,
    "deviceList":[
        {
            "id":"camera1"
        }
    ]
}

Subscription response: (when camera2 is connected)

{
    "returnValue":true,
    "subscribed":true,
    "deviceList":[
        {
            "id":"camera1"
        },
        {
            "id":"camera2"
        }
    ]
}

Subscription response: (when camera1 is disconnected)

{
    "returnValue":true,
    "subscribed":true,
    "deviceList":[
        {
            "id":"camera2"
        }
    ]
}

getEventNotification

ACG: camera.operation
  • Added: API level 11

Description

Gets a notification when there is a change in any of the camera properties and formats or when there is an error event on your device.

Parameters

Name

Required

Type

Description

subscribeRequiredBoolean

Indicates if subscribed to get notifications.

Possible values are:

  • true: Subscribed for notifications
  • false: Not subscribed

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

subscribedOptionalBoolean

Indicates if subscribed to get notifications. 

Note: Returns only if the subscribe is true.

Subscription Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

subscribedOptionalBoolean

Indicates if subscribed to get notifications.

eventTypeOptionalString

Indicates whether there is a device error.

Possible values are:

  • preview_fault: If the device cannot send preview data due to an error during camera preview.
  • capture_fault: If an error occurs during camera capture.

Note: Currently supports only preview_fault.

idOptionalString

ID of the camera.

errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Example

Example : With subscription

# luna-send -i -f luna://com.webos.service.camera2/getEventNotification '{"subscribe":true}'

Response:

{
    "subscribed": true,
    "returnValue": true
}

Subscription response: (If there is an error during camera preview)

{
    "returnValue": true,
    "id": "camera1",
    "eventType": "preview_fault"
}

getFd

ACG: camera.operation
  • Added: API level 13

Description

Provides the FD (File Descriptor) for the POSIX shared memory.

Note: It returns the FD by attaching it using LS2 attach fd interface to the client.

Parameters

Name

Required

Type

Description

handleRequiredNumber

Indicates the handle for the device obtained using the open() API. 

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Example

Example scenario

# luna-send -n 1 -f luna://com.webos.service.camera2/getFd '{"handle": 886}'

Response:

{
   "returnValue":true
}

 

Sample for fetching the fd from getFd response:

getFdCb(LSHandle *lsHandle, LSMessage *message, void *user_data)
{
 ...
 LS::Message ls_message(message);
 LS::PayloadRef payload_ref = ls_message.accessPayload();
 fd = payload_ref.getFd();
 ...
}

getFormat

ACG: camera.operation
  • Added: API level 27

Description

Gets the current resolution, FPS, and format settings of the connected camera device.

Parameters

Name

Required

Type

Description

idRequiredString

Indicates the camera id for the device obtained using the getCameraList() API.

Note: The camera must be opened first.

subscribeOptionalBoolean

Subscribe for notifications on changes.

Possible values are:

  • true: Subscribed.
  • false: (default) Not subscribed.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Operation is successful.
  • false: Operation has failed. Check the 'errorCode' and 'errorText' fields.
subscribedOptionalBoolean

Indicates if subscribed to get notifications.

Note: Returns only if the subscription is true.

paramsOptionalObject: camera_format

Indicates the size and format of the preview stream.

errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

The reason for the failure of the operation. See the 'API Error Codes Reference' section for details.

Subscription Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

subscribedOptionalBoolean

Indicates if subscribed to get notifications.

idOptionalString

Indicates the id of the camera.

paramsOptionalObject: camera_format

Indicates the size and format of the preview stream.

errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section of this method for details.

Example

Example : Get format without subscription

# luna-send -n 1 -f luna://com.webos.service.camera2/getFormat '{ "id":"camera1"}'

Response:

{
    "returnValue":true,
    "params":{
        "format":"YUV",
        "width":640,
        "fps":30,
        "height":480
    }
}

Example : Get format with subscription

# luna-send -n 1 -f luna://com.webos.service.camera2/getFormat '{ "id":"camera1", "subscribe":true}'

Response:

{
    "subscribed":" true",
    "returnValue":true,
    "params":{
        "format":"YUV",
        "width":640,
        "fps":30,
        "height":480
    }
}

Subscription response:

{
    "subscribed":true,
    "returnValue":true,
    "id":"camera1",
    "params":{
        "format":"JPEG",
        "fps":30,
        "width":1280,
        "height":720
    }
}

getInfo

ACG: camera.query
  • Added: API level 11

Description

Gets information about a camera that is connected to the webOS device.

Parameters

Name

Required

Type

Description

idRequiredString

Indicates id of the camera obtained using the getCameraList() API.

Call Returns

Name

Required

Type

Description

infoOptionalObject: capture_info

Returns information about the camera.

errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

Example code

# luna-send -n 1 -f luna://com.webos.service.camera2/getInfo '{ "id":"camera1"}'
 

Response:

{
    "info":{
        "type":"camera",
        "builtin":false,
        "supported":true,
        "resolution":{
            "YUV":[
                "640,480,30",
                "640,480,24",
                "640,480,20",
                "640,480,15",
                "640,480,10",
                "640,480,7",
                "640,480,5",
                "160,90,30",
                "160,90,24",
                "160,90,20",
                "160,90,15",
                "160,90,10",
                "160,90,7",
                "160,90,5",
                "160,120,30",
                "160,120,24",
                "160,120,20",
                "160,120,15",
                "160,120,10",
                "160,120,7",
                "160,120,5",
                "176,144,30",
                "176,144,24",
                "176,144,20",
                "176,144,15",
                "176,144,10",
                "176,144,7",
                "176,144,5",
                "320,180,30",
                "320,180,24",
                "320,180,20",
                "320,180,15",
                "320,180,10",
                "320,180,7",
                "320,180,5",
                "320,240,30",
                "320,240,24",
                "320,240,20",
                "320,240,15",
                "320,240,10",
                "320,240,7",
                "320,240,5",
                "352,288,30",
                "352,288,24",
                "352,288,20",
                "352,288,15",
                "352,288,10",
                "352,288,7",
                "352,288,5",
                "432,240,30",
                "432,240,24",
                "432,240,20",
                "432,240,15",
                "432,240,10",
                "432,240,7",
                "432,240,5",
                "640,360,30",
                "640,360,24",
                "640,360,20",
                "640,360,15",
                "640,360,10",
                "640,360,7",
                "640,360,5",
                "800,448,30",
                "800,448,24",
                "800,448,20",
                "800,448,15",
                "800,448,10",
                "800,448,7",
                "800,448,5",
                "800,600,24",
                "800,600,20",
                "800,600,15",
                "800,600,10",
                "800,600,7",
                "800,600,5",
                "864,480,24",
                "864,480,20",
                "864,480,15",
                "864,480,10",
                "864,480,7",
                "864,480,5",
                "960,720,15",
                "960,720,10",
                "960,720,7",
                "960,720,5",
                "1024,576,15",
                "1024,576,10",
                "1024,576,7",
                "1024,576,5",
                "1280,720,10",
                "1280,720,7",
                "1280,720,5",
                "1600,896,7",
                "1600,896,5",
                "1920,1080,5",
                "2560,1472,2"
            ],
            "JPEG":[
                "640,480,30",
                "640,480,24",
                "640,480,20",
                "640,480,15",
                "640,480,10",
                "640,480,7",
                "640,480,5",
                "160,90,30",
                "160,90,24",
                "160,90,20",
                "160,90,15",
                "160,90,10",
                "160,90,7",
                "160,90,5",
                "160,120,30",
                "160,120,24",
                "160,120,20",
                "160,120,15",
                "160,120,10",
                "160,120,7",
                "160,120,5",
                "176,144,30",
                "176,144,24",
                "176,144,20",
                "176,144,15",
                "176,144,10",
                "176,144,7",
                "176,144,5",
                "320,180,30",
                "320,180,24",
                "320,180,20",
                "320,180,15",
                "320,180,10",
                "320,180,7",
                "320,180,5",
                "320,240,30",
                "320,240,24",
                "320,240,20",
                "320,240,15",
                "320,240,10",
                "320,240,7",
                "320,240,5",
                "352,288,30",
                "352,288,24",
                "352,288,20",
                "352,288,15",
                "352,288,10",
                "352,288,7",
                "352,288,5",
                "432,240,30",
                "432,240,24",
                "432,240,20",
                "432,240,15",
                "432,240,10",
                "432,240,7",
                "432,240,5",
                "640,360,30",
                "640,360,24",
                "640,360,20",
                "640,360,15",
                "640,360,10",
                "640,360,7",
                "640,360,5",
                "800,448,30",
                "800,448,24",
                "800,448,20",
                "800,448,15",
                "800,448,10",
                "800,448,7",
                "800,448,5",
                "800,600,30",
                "800,600,24",
                "800,600,20",
                "800,600,15",
                "800,600,10",
                "800,600,7",
                "800,600,5",
                "864,480,30",
                "864,480,24",
                "864,480,20",
                "864,480,15",
                "864,480,10",
                "864,480,7",
                "864,480,5",
                "960,720,30",
                "960,720,24",
                "960,720,20",
                "960,720,15",
                "960,720,10",
                "960,720,7",
                "960,720,5",
                "1024,576,30",
                "1024,576,24",
                "1024,576,20",
                "1024,576,15",
                "1024,576,10",
                "1024,576,7",
                "1024,576,5",
                "1280,720,30",
                "1280,720,24",
                "1280,720,20",
                "1280,720,15",
                "1280,720,10",
                "1280,720,7",
                "1280,720,5",
                "1600,896,30",
                "1600,896,24",
                "1600,896,20",
                "1600,896,15",
                "1600,896,10",
                "1600,896,7",
                "1600,896,5",
                "1920,1080,30",
                "1920,1080,24",
                "1920,1080,20",
                "1920,1080,15",
                "1920,1080,10",
                "1920,1080,7",
                "1920,1080,5"
            ]
        },
        "name":"HD Pro Webcam C920."
    },
    "returnValue":true
}

getProperties

ACG: camera.operation
  • Added: API level 11

Description

Gets the current settings of the connected camera device.

Parameters

Name

Required

Type

Description

paramsOptionalString array

Indicates the list of specific properties for which settings are returned.

idRequiredString

Indicates the camera id for the device obtained using the getCameraList() API.

Note: The camera must be opened first.

subscribeOptionalBoolean

Subscribe for notifications on changes.

Possible values are:

  • true: Subscribed.
  • false: (default) Not subscribed.

Call Returns

Name

Required

Type

Description

paramsRequiredObject: camera_properties

Indicates the current properties of the camera.

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
subscribedOptionalBoolean

Indicates if subscribed to get notifications. 

Note: Returns only if the subscription is true.

errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Subscription Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

subscribedOptionalBoolean

Indicates if subscribed to get notifications.

idOptionalString

ID of the camera.

paramsOptionalObject: camera_properties

Indicates the current properties of the camera.

errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Example

Example : With ID and subscription

# luna-send -n 1 -f luna://com.webos.service.camera2/getProperties '{"id":"camera1", "subscribe":true}'

Response:

{
    "subscribed":true,
    "returnValue":true,
    "params":{
        "exposure":{
            "max":10000,
            "min":78,
            "default":312,
            "step":1,
            "value":312
        },
        "backlightCompensation":{
            "max":3,
            "min":0,
            "default":0,
            "step":1,
            "value":0
        },
        "frequency":{
            "max":2,
            "min":0,
            "default":1,
            "step":1,
            "value":1
        },
        "saturation":{
            "max":100,
            "min":0,
            "default":58,
            "step":1,
            "value":58
        },
        "brightness":{
            "max":64,
            "min":-64,
            "default":0,
            "step":1,
            "value":64
        }
    }
}

Subscription response:

{
    "subscribed":true,
    "returnValue":true,
    "id":"camera1",
    "params":{
        "exposure":{
            "max":10000,
            "min":78,
            "default":312,
            "step":1,
            "value":312
        },
        "backlightCompensation":{
            "max":3,
            "min":0,
            "default":0,
            "step":1,
            "value":0
        },
        "frequency":{
            "max":2,
            "min":0,
            "default":1,
            "step":1,
            "value":1
        },
        "saturation":{
            "max":100,
            "min":0,
            "default":58,
            "step":1,
            "value":58
        },
        "brightness":{
            "max":64,
            "min":-64,
            "default":0,
            "step":1,
            "value":64
        }
    }
}

Example : With ID and params

# luna-send -n 1 -f luna://com.webos.service.camera2/getProperties '{"id": "camera1", "params": ["frequency", "saturation"]}'

Response:

{
    "returnValue": true,
    "params": {
        "saturation": {
            "max": 255,
            "min": 0,
            "default": 128,
            "step": 1,
            "value": 128
        },
        "frequency": {
            "max": 2,
            "min": 0,
            "default": 2,
            "step": 1,
            "value": 2
        }
    }
}

getSolutions

ACG: camera.operation
  • Added: API level 21

Description

Gets the current status of the supported camera solutions.

Parameters

Name

Required

Type

Description

handleOptionalNumber

Indicates the handle for the device. It is obtained using the open() API.

Note: Either one of "handle" or "id" must be provided. 

idOptionalString

Indicates the camera id for the device. It is obtained using the getCameraList() API.

Note: Either one of "handle" or "id" must be provided. 

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true - Indicates that the operation was successful.
  • false - Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
solutionsOptionalObject array: solutions

Provides current status of the supported camera solutions.

errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section of this method for details.

Error Codes Reference

Error Code

Error Text

Error Description

11Camera device is not opened

Camera device is not opened

32Wrong param

Input parameter is incorrect.

35Unknown error

Unknown error happens

47Wrong handle

Device handle number is incorrect.

Example

Example : Get solutions by specifying the -id- parameter

# luna-send -n 1 -f luna://com.webos.service.camera2/getSolutions '{"id": "camera1"}'

Response:

{
    "returnValue": true,
    "solutions": [
        {
            "name": "FaceDetectionCNN",
            "params": {
                "enable": false
            }
        },
        {
            "name": "FaceDetection",
            "params": {
                "enable": false
            }
        }
    ]
}

Example : Get solutions by specifying the -handle- parameter

# luna-send -n 1 -f luna://com.webos.service.camera2/getSolutions '{"handle": 2214}'

Response:

{
    "returnValue": true,
    "solutions": [
        {
            "name": "FaceDetectionCNN",
            "params": {
                "enable": false
            }
        },
        {
            "name": "FaceDetection",
            "params": {
                "enable": false
            }
        }
    ]
}

open

ACG: camera.operation
  • Added: API level 11

Description

Establishes a connection between a camera and the webOS device. Returns the device handle for this connection instance. 

Parameters

Name

Required

Type

Description

idRequiredString

Indicates the unique identifier of the camera obtained using the getCameraList() API.

modeOptionalString

Indicates whether the calling app can update the camera settings.

Possible values are:

  • primary: Calling app can update the camera settings.
  • secondary: Calling app cannot update the camera settings.

Note:

  • If no mode is selected, then the first call to open the camera gets primary access, and others are given secondary access.
  • If there are multiple calls with the mode set as primary, then only the first call gets primary access.
pidOptionalNumber

Indicates the process ID of the client process which intends to get notified of a shared memory writing-done event by a signal.

Note: The client process ID should be the one that is actually on the running context.

  • If a client app A calls another process B and process B is the one who is waiting for a writing-done event and reading the shared memory synchronously, then process B must call open. Otherwise, if A calls open with its open process ID, it would kill the app.
sigOptionalNumber

Indicates the ID of the signal by which the camera service reports a shared memory writing-done event and a client app will get notified of it. The number of possible values are 29 from 1 (SIGHUP) to 31 (SIGSYS) except for 9 (SIGKILL) and19 (SIGSTOP).

Note:

  • Must be provided with "pid"
  • The process ID and the signal ID passed by payload will be registered (or added) to a pool that the camera service manages.
  • If the signal ID is not specified in the payload, the default signal number 10 (SYGUSR1) will be applied. 
  • If an invalid value is passed, the camera service will reject the request and return false.
appIdOptionalString

ID of the application

Note: App must have permission to open the camera.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
handleOptionalNumber

Indicates the unique identifier for each connection instance.

errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

pidOptionalString

The process ID.

sigOptionalString

The Signal ID.

Example

Example : Open command with no mode

# luna-send -n 1 -f luna://com.webos.service.camera2/open '{
   "id":"camera1"
}'

Response:

{
   "returnValue":true,
   "handle":9383
}

Example : Open command with the mode set to primary

# luna-send -n 1 -f luna://com.webos.service.camera2/open '{
   "id":"camera1",
   "mode":"primary"
}'

Response:

{
   "returnValue":true,
   "handle":886
}

Example : Error case - Open command with mode as primary (when an application has already opened with mode as primary)

# luna-send -n 1 -f luna://com.webos.service.camera2/open '{
   "id":"camera1",
   "mode":"primary"
}'

Response:

{
   "errorCode":44,
   "returnValue":false,
   "errorText":"Already another device opened as primary"
}

Example : App does not require synchronized shared memory synchronization

# luna-send -f -n 1 luna://com.webos.service.camera2/open '{
    "id":"camera1",
    "appId": "com.webos.app.browser"
}'

Response:

{
   "returnValue": true,
   "handle": 4503
}

Example : App does not require synchronized shared memory synchronization - case to open with primary mode

# luna-send -n 1 -f luna://com.webos.service.camera2/open '{
    "id":"camera1",
    "appId": "com.webos.app.browser",
    "mode":"primary"
}'

Response:

{
   "returnValue":true,
   "handle":886
}

Example : App does not require synchronized shared memory synchronization - case when an application has already opened with mode as primary.

# luna-send -n 1 -f luna://com.webos.service.camera2/open '{
    "id":"camera1",
    "appId": "com.webos.app.browser", 
    "mode":"primary"
}'

Response:

{
   "errorCode":44,
   "returnValue":false,
   "errorText":"Already another device opened as primary"
}

Example : App requires shared memory synchronization, with default signal

# luna-send -n 1 -f luna://com.webos.service.camera2/open '{
    "id": "camera1",
    "appId": "com.webos.app.browser",
    "pid": 1804
}'

Response:

{
   "returnValue": true,
   "pid": 1804,
   "handle": 6393,
   "sig": 10
}

 

Example : App requires shared memory synchronization, with a specified signal

# luna-send -n 1 -f luna://com.webos.service.camera2/open '{
    "id": "camera1",
    "appId": "com.webos.app.browser",
    "pid": 1430,
    "sig": 2
}'

Response:

{
   "returnValue": true,
   "pid": 1430,
   "handle": 2516,
   "sig": 2
}

Example : App passes an invalid signal

# luna-send -n 1 -f luna://com.webos.service.camera2/open '{
    "id": "camera1",
    "appId": "com.webos.app.browser",
    "pid": 1970,
    "sig": 19
}'            

Response:

{                                                                                                                                 
    "errorCode": 50,                                                                                                                    
    "returnValue": false,                                                                                                                           
    "errorText": "Failed to register pid with specified signal"                                                                                                                         
}                  

setFormat

ACG: camera.operation
  • Added: API level 11

Description

Sets the size and format of the preview stream. This includes the height and width of the frame and the format in which data is to be written to the shared buffer.

Parameters

Name

Required

Type

Description

handleRequiredNumber

Indicates the camera handle obtained using the open() API.

paramsRequiredObject: camera_format

Indicates the size and format of the preview stream.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Example

Example code

# luna-send -n 1 -f luna://com.webos.service.camera2/setFormat '{
   "handle":9383,
   "params":{
      "width":640,
      "height":480,
      "format":"JPEG",
      "fps":30
   }
}'

Response:

{
   "returnValue":true
}

setProperties

ACG: camera.operation
  • Added: API level 11

Description

Sets the properties of the connected camera device.

Parameters

Name

Required

Type

Description

handleRequiredNumber

Indicates the handle for the device obtained using the open() API. 

paramsRequiredObject: camera_properties

Indicates an object containing properties of the camera.

Note: Even though the API succeeds when an empty params object is provided, we recommend that at least one value must be included.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Example

Example code

# luna-send -n 1 -f luna://com.webos.service.camera2/setProperties '{
     "handle": 9383,
     "params":
          {
             "contrast": 100
          }
}'

Response:

{
   "returnValue":true
}

setSolutions

ACG: camera.operation
  • Added: API level 21

Description

Enables and disables camera solutions.

Parameters

Name

Required

Type

Description

handleOptionalNumber

Indicates the handle for the device. It is obtained using the open() API. 

Note: Either one of "handle" or "id" must be provided. 

idOptionalString

Indicates the camera id for the device. It is obtained using the getCameraList() API.

Note: Either one of "handle" or "id" must be provided. 

solutionsRequiredObject array: solutions

Specifies the current status of the supported camera solutions.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. 

Possible values are:

  • true - Indicates that the operation was successful.
  • false - Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section of this method for details.

Error Codes Reference

Error Code

Error Text

Error Description

11Camera device is not opened

Camera device is not opened

32Wrong param

Input parameter is incorrect.

35Unknown error

Unknown error happens

47Wrong handle

Device handle number is incorrect. 

Example

Example : Set solutions by specifying the -id- parameter

# luna-send -n 1 -f luna://com.webos.service.camera2/setSolutions '{
    "id": "camera1",
    "solutions": [
        {
            "name": "AutoContrast",
            "params": {
                "enable": true
            }
        },
        {
            "name": "FaceDetection",
            "params": {
                "enable": true
            }
        }
    ]
}'

Response:

{
    "returnValue": true
}

Example : Set solutions by specifying the -handle- parameter

# luna-send -n 1 -f luna://com.webos.service.camera2/setSolutions '{
    "handle": 4231,
    "solutions": [
        {
            "name": "AutoContrast",
            "params": {
                "enable": true
            }
        },
        {
            "name": "FaceDetection",
            "params": {
                "enable": true
            }
        }
    ]
}'

Response:

{
    "returnValue": true
}

startCamera

ACG: camera.operation
  • Added: API level 27

Description

Starts camera and turns on streaming of captured image frames into the shared memory (SystemV or POSIX). The method returns a key or an FD for accessing the shared memory, which is required for applications to access data from the shared memory.

Notes:

  • Use this method if the application needs only to access image frame data kept in the shared memory.
  • In order to set the image resolution and format of the image frame, use the setFormat() method.

Parameters

Name

Required

Type

Description

handleRequiredString

Indicates the handle for the device obtained using the open() API.

paramsRequiredObject: camera_memory_source

Defines the type and source of memory.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Operation is successful.
  • false: Operation has failed. Check the 'errorCode' and 'errorText' fields.
keyOptionalNumber

Indicates the key for memory access.

  • For SystemV, key can be accessed directly for camera device buffers.
  • For POSIX, shared memory FD has to be shared over getFd() API for accessing the camera device buffers.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

The reason for the failure of the operation. See the 'API Error Codes Reference' section for details.

Error Codes Reference

Error Code

Error Text

Error Description

20, 32, 200Depends on error code

Check details in the "API Error Codes Reference" table.

Example

Example : For SystemV shared memory

# luna-send -n 1 -f luna://com.webos.service.camera2/startCamera '{"handle": 5699,"params": {"type":"sharedmemory", "source":"0"}}'

Response:

{
    "returnValue": true,
    "key": 7010
}

Example : For POSIX shared memory

# luna-send -n 1 -f luna://com.webos.service.camera2/startCamera '{"handle": 4738,"params": {"type":"posixshm", "source":"0"}}'

Response:

{
    "returnValue": true,
    "key": 11
}

startCapture

ACG: camera.operation
  • Added: API level 11

Description

Starts capturing images using the camera. The captured images are stored as separate files at the location given by the "path" parameter.

The default file name is of the format PictureDDMMYYYY-HHMMSS, where DDMMYYYY-HHMMSS is current date and time.

Example: /tmp/Picture11022019-204128.jpeg

By default, captured images are saved in the /tmp/ folder.

Parameters

Name

Required

Type

Description

handleRequiredNumber

Indicates the handle for the device obtained using the open() API. 

paramsRequiredObject: camera_capture_format

Indicates the size and format of the images to be captured. 

pathOptionalString

Indicates the location where the captured images are to be saved.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Example

Example : Without specifying the location

# luna-send -n 1 -f luna://com.webos.service.camera2/startCapture '{
     "handle": 9383,
     "params":
          {
             "width": 640,
             "height": 480,
             "format": "JPEG",
             "mode":"MODE_BURST",
             "nimage":2
          }
}'

Response:

{
   "returnValue":true
}

Example : With location specified

# luna-send -n 1 -f luna://com.webos.service.camera2/startCapture '{
     "handle": 9383,
     "params":
          {
             "width": 640,
             "height": 480,
             "format": "JPEG",
             "mode":"MODE_BURST",
             "nimage":2
          },
     "path":"/tmp/"
}'

Response:

{
   "returnValue":true
}

Example : Error case - With read-only location specified

# luna-send -n 1 -f luna://com.webos.service.camera2/startCapture '{
     "handle": 9383,
     "params":
          {
             "width": 640,
             "height": 480,
             "format": "JPEG",
             "mode":"MODE_BURST",
             "nimage":2
          },
     "path":"/sys/"
}'

Response:

{
    "errorCode": 45,
    "returnValue": false,
    "errorText": "Cannot write at specified location"
}

startPreview

ACG: camera.operation
  • Added: API level 11

Description

Turns on camera streaming of captured image frames into the shared memory (SystemV or POSIX) and shows preview on the specified surface.  The method returns a key or an fd for accessing the shared memory for applications to utilize.

Notes:

  • Use this API if the application needs to render image frames on the specified surface.
  • While the camera is previewing, the application can access the shared memory for purposes except for preview.
  • In order to set the image resolution and format of the image frame, use the setFormat() method.

Parameters

Name

Required

Type

Description

handleRequiredNumber

Indicates the handle for the device obtained using the open() API. 

paramsRequiredObject: camera_memory_source

Defines the type and source of the memory.

windowIdRequiredString

Indicates windowId associated with the surface.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
keyOptionalNumber

Indicates the key for memory access.

  • For System V, key can be accessed directly for camera device buffers
  • For Posix, shared memory fd has to be shared over getFd API for accessing the camera device buffers
mediaIdOptionalString

Indicates the Id of the preview pipeline.

errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Error Codes Reference

Error Code

Error Text

Error Description

20, 32, 106, 200Depends on error code

Check details in the "API Error Codes Reference" table.

Example

Example scenario

[Precondition]

# camera_window_manager_exporter &
Response:
displayID=0
x=0, y=0, exportWidth=1920, exportHeight=1080exporter.initialize success
exported window ID is : _Window_Id_1

[Preview]

# luna-send -n 1 -f luna://com.webos.service.camera2/startPreview '{
    "handle": 189,
    "params": {"type":"sharedmemory", "source":"0"},
    "windowId": "_Window_Id_1"
}'

Response:
{
    "returnValue": true,
    "key": 7010,
    "mediaId": "_sAMEt6vNxFRzav"
}

Example scenario

[Precondition]

# camera_window_manager_exporter &
Response:
displayID=0
x=0, y=0, exportWidth=1920, exportHeight=1080exporter.initialize success
exported window ID is : _Window_Id_1

[Preview]

# luna-send -n 1 -f luna://com.webos.service.camera2/startPreview '{
    "handle": 189,
    "params": {"type":"posixshm", "source":"0"},
    "windowId": "_Window_Id_1"
}'

Response:
{
    "returnValue": true,
    "key": 11,
    "mediaId": "_WjJf3TU1uusOef"
}

stopCamera

ACG: camera.operation
  • Added: API level 27

Description

Stops camera and turns off streaming into the shared memory.

Note: Applications that called startCamera() should call this method to stop streaming.

Parameters

Name

Required

Type

Description

handleRequiredNumber

Indicates the handle for the device obtained using the open() API.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Operation is successful.
  • false: Operation has failed. Check the 'errorCode' and 'errorText' fields.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

The reason for the failure of the operation. See the 'API Error Codes Reference' section for details.

Error Codes Reference

Error Code

Error Text

Error Description

13, 20, 32, 200Depends on error code

Check details in the "API Error Codes Reference" table.

Example

Example : Stop camera

# luna-send -n 1 -f luna://com.webos.service.camera2/stopCamera '{"handle": 5699}'

Response:

{
    "returnValue": true,
}

stopCapture

ACG: camera.operation
  • Added: API level 11

Description

Stops camera from capturing images in the continuous mode. Continuous mode captures frames in succession till the stopCapture() method is called.

Parameters

Name

Required

Type

Description

handleRequiredNumber

Indicates the handle for the device obtained using the open() API.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Example

Example code

# luna-send -n 1 -f luna://com.webos.service.camera2/stopCapture '{"handle":9383}'

Response:

{
   "returnValue":true
}

stopPreview

ACG: camera.operation
  • Added: API level 11

Description

Turns off camera streaming and finishes showing the preview on the surface.

Note: The applications should call this method to stop streaming and preview when the applications called startPreview().

Parameters

Name

Required

Type

Description

handleRequiredNumber

Indicates the handle for the device obtained using the open() API.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Error Codes Reference

Error Code

Error Text

Error Description

13, 20, 32, 200Depends on error code

Check details in the "API Error Codes Reference" table.

Example

Example code

# luna-send -n 1 -f luna://com.webos.service.camera2/stopPreview '{"handle":9383}'

Response:

{
   "returnValue":true
}

Objects

camera_capability

Contains the capability of the camera

Name

Required

Type

Description

minOptionalNumber

The minimum value of the control.

maxOptionalNumber

The maximum value of the control.

defaultOptionalNumber

The default value of the control.

stepOptionalNumber

The step value of the control.

valueOptionalNumber

The current value of the control.

camera_capture_format

Indicates the size and the format in which images are to be captured.

Name

Required

Type

Description

widthRequiredNumber

Indicates the width of the image to be captured.

Default width: 640 pixels

heightRequiredNumber

Indicates the height of the image to be captured.

Default value: 480 pixels

formatRequiredString

Indicates the format of the image.

Possible values are:

  • JPEG
  • YUV

Default: YUV

nimageOptionalNumber

Indicates the number of images to be captured.

Note: The field is required for capturing images in burst mode.

modeRequiredString

Indicates the mode in which the image is to be captured.

Possible values are:

  • MODE_ONESHOT: For one-shot mode
  • MODE_BURST: For burst mode
  • MODE_CONTINUOUS: For continuous mode

camera_format

Indicates the size and format for the preview stream and images.

Name

Required

Type

Description

widthRequiredNumber

Indicates the width of the image to be captured.

Default: 640 pixels

heightRequiredNumber

Indicates the height of the image to be captured.

Default: 480 pixels

formatRequiredString

Indicates the format of the image.

Possible values are:

  • JPEG
  • YUV

Default: YUV

fpsRequiredNumber

Indicates the frames per second.

camera_memory_source

Indicates the type of the memory for the preview data to be written.

Name

Required

Type

Description

typeRequiredString

Indicates the type of the shared memory.

Possible options: 

  • sharedmemory - For SystemV shared memory.
  • posixshm - For POSIX shared memory
sourceRequiredString

Indicates the ID of memory source, if the client has created the memory and wants data to be written at that specific address.

camera_properties

Contains the properties of the camera.

Name

Required

Type

Description

sharpnessOptionalObject: camera_capability

Indicates the camera sharpness 

autoExposureOptionalObject: camera_capability

Indicates the camera auto exposure

autoFocusOptionalObject: camera_capability

Indicates the camera auto focus

autoWhiteBalanceOptionalObject: camera_capability

Indicates the camera auto white balance

backlightCompensationOptionalObject: camera_capability

Indicates the camera backlight compensation value

brightnessOptionalObject: camera_capability

Indicates the camera brightness

contrastOptionalObject: camera_capability

Indicates the camera contrast

exposureOptionalObject: camera_capability

Indicates the exposure value

focusAbsoluteOptionalObject: camera_capability

Indicates the focus value

frequencyOptionalObject: camera_capability

Indicates the camera power line frequency

gainOptionalObject: camera_capability

Indicates the camera gain

gammaOptionalObject: camera_capability

Camera gamma

hueOptionalObject: camera_capability

Indicates the camera hue

panOptionalObject: camera_capability

Indicates the pan value

saturationOptionalObject: camera_capability

Indicates the camera saturation

tiltOptionalObject: camera_capability

Indicates the tilt value

whiteBalanceTemperatureOptionalObject: camera_capability

Indicates the white balance temperature

zoomAbsoluteOptionalObject: camera_capability

Indicates the zoom value

capture_info

Indicates the information about the camera.

Name

Required

Type

Description

nameOptionalString

Indicates the name of the camera.

typeOptionalString

Indicates the type of the device.

Possible values are:

  • camera
builtinOptionalBoolean

Indicates if the camera is built-in or not.

resolutionOptionalObject

Indicates the supported format resolutions.

supportedOptionalBoolean

Indicates whether the camera is supported.

deviceList

Contains the list of cameras connected to the webOS device. 

Name

Required

Type

Description

idOptionalString

Indicates the unique camera identifier.

params

Detailed information of a specific solution.

Name

Required

Type

Description

enableRequiredBoolean

Status of solution [enable/disable each solution]

picture

Indicates the image size and image format.

Name

Required

Type

Description

maxWidthOptionalNumber

Width value

maxHeightOptionalNumber

Height value

formatOptionalString

Supported formats

solutions

Information of all supported camera solutions.

Name

Required

Type

Description

nameRequiredString

Name of supported solution.

paramsRequiredObject: params

Detailed information of a specific solution.

video

Indicates the video size and the video format.

Name

Required

Type

Description

maxWidthOptionalNumber

Indicates the width value.

maxHeightOptionalNumber

Indicates the height value.

formatOptionalString

Gives the supported format for video.

frameRateOptionalNumber

Indicates the video frame rate.

API Error Codes Reference

Error Code

Error Text

Error Description

2Cannot close device

Device cannot be closed.

3Cannot open device

Device cannot be opened.

5Cannot start device

Preview stream cannot be started.

6Cannot stop device

Preview stream cannot be stopped.

7Device already closed

Device is already closed.

8Device is already open

Device is already opened.

9Device is already started

Preview stream is already started.

10Device is already stopped

Preview stream is already stopped.

11Device not opened

Device is not opened.

12Device not started

Preview stream is not yet started.

13There is no device

There is no device connected corresponding to input ID.

20Parsing error

Luna command parsing error.

22Out of param range

A parameter value is not within the expected or allowed range.

23Param missing

One or more parameters are missing in luna command.

29Device unsupported

Device is not supported.

30Format unsupported

Format is not supported.

32Wrong param

Input parameter is incorrect.

35Unknown error

Unknown error

38Fail to open file

Fail to open file

39Fail to write file

There is a problem or failure in writing data to a file. It could occur due to various reasons such as insufficient permissions, lack of disk space, or hardware issues.

44Already another device opened as primary

Only one application can open a camera device as primary. Other application will not be allowed to open camera if an application has already opened with primary priority.

45Cannot write at specified location

Cannot write at the specified location.

46Unsupported Memory Type

Error due to unsupported memory type

47Wrong handle

Handle is not exist.

48Preview not started

Preview is not started.

49Handle is not in POSIXSHM mode

Handle is not in POSIXSHM mode

51Failed to register pid with specified signal

Id of the signal is not valid.

52Must specify client pid

PID should be provided in the request.

100The subscribed camera is disconnected

  The subscription is canceled because the camera is disconnected.

105Request Timeout

Requested operation is timed out.

106Invalid windowId

The windowId is invalid.

200Invalid state

Camera device state is invalid.

Contents