Note
This API has been available since API level 11.
This API has been available since API level 11.
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:
N/A
API level 27
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.
Name | Required | Type | Description |
---|---|---|---|
handle | Required | Number | Indicates the handle for the device obtained using the open() API. |
nimage | Optional | Number | Indicates the number of images to be captured. Note: Default = 1, max = 30 |
path | Optional | String | Indicates the location where the captured images are to be saved. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
path | Optional | String array | Indicates the path and file names of the captured images. |
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | The reason for the failure of the operation. See the 'API Error Codes Reference' section for details. |
Error Code | Error Text | Error Description |
---|---|---|
22, 39, 45 | Depends on error code | Check details in the "API Error Codes Reference" table. |
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
]
}
API level 11
Closes the connection between the camera and the webOS device.
Name | Required | Type | Description |
---|---|---|---|
handle | Required | Number | Indicates the handle for the device obtained using the open() API. |
pid | Optional | Number | 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. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
pid | Optional | Number | Indicates the client process ID |
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
}
API level 11
Gets the list of cameras connected to the webOS device. Returns IDs for each of the cameras connected to the device.
Name | Required | Type | Description |
---|---|---|---|
subscribe | Optional | Boolean | Subscribe for notifications on changes. Possible values are:
|
Name | Required | Type | Description |
---|---|---|---|
deviceList | Optional | Object array: deviceList | Indicates the list of cameras connected to the device. Note: The method returns an empty list if no camera is connected. |
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
subscribed | Optional | Boolean | Indicates if subscribed to get notifications. Note: Returns only if the subscribe is true. |
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. |
subscribed | Optional | Boolean | Indicates if subscribed to get notifications. |
deviceList | Optional | Object array: deviceList | Indicates the list of cameras connected to the device. Note: The method returns an empty list if no camera is connected. |
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
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"
}
]
}
API level 11
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.
Name | Required | Type | Description |
---|---|---|---|
subscribe | Required | Boolean | Indicates if subscribed to get notifications. Possible values are:
|
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
subscribed | Optional | Boolean | Indicates if subscribed to get notifications. Note: Returns only if the subscribe is true. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. |
subscribed | Optional | Boolean | Indicates if subscribed to get notifications. |
eventType | Optional | String | Indicates whether there is a device error. Possible values are:
Note: Currently supports only preview_fault. |
id | Optional | String | ID of the camera. |
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
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"
}
API level 13
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.
Name | Required | Type | Description |
---|---|---|---|
handle | Required | Number | Indicates the handle for the device obtained using the open() API. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
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();
...
}
API level 27
Gets the current resolution, FPS, and format settings of the connected camera device.
Name | Required | Type | Description |
---|---|---|---|
id | Required | String | Indicates the camera id for the device obtained using the getCameraList() API. Note: The camera must be opened first. |
subscribe | Optional | Boolean | Subscribe for notifications on changes. Possible values are:
|
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
subscribed | Optional | Boolean | Indicates if subscribed to get notifications. Note: Returns only if the subscription is true. |
params | Optional | Object: camera_format | Indicates the size and format of the preview stream. |
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | The reason for the failure of the operation. See the 'API Error Codes Reference' section for details. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. |
subscribed | Optional | Boolean | Indicates if subscribed to get notifications. |
id | Optional | String | Indicates the id of the camera. |
params | Optional | Object: camera_format | Indicates the size and format of the preview stream. |
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section of this method for details. |
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
}
}
API level 11
Gets information about a camera that is connected to the webOS device.
Name | Required | Type | Description |
---|---|---|---|
id | Required | String | Indicates id of the camera obtained using the getCameraList() API. |
Name | Required | Type | Description |
---|---|---|---|
info | Optional | Object: capture_info | Returns information about the camera. |
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
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
}
API level 11
Gets the current settings of the connected camera device.
Name | Required | Type | Description |
---|---|---|---|
params | Optional | String array | Indicates the list of specific properties for which settings are returned. |
id | Required | String | Indicates the camera id for the device obtained using the getCameraList() API. Note: The camera must be opened first. |
subscribe | Optional | Boolean | Subscribe for notifications on changes. Possible values are:
|
Name | Required | Type | Description |
---|---|---|---|
params | Required | Object: camera_properties | Indicates the current properties of the camera. |
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
subscribed | Optional | Boolean | Indicates if subscribed to get notifications. Note: Returns only if the subscription is true. |
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. |
subscribed | Optional | Boolean | Indicates if subscribed to get notifications. |
id | Optional | String | ID of the camera. |
params | Optional | Object: camera_properties | Indicates the current properties of the camera. |
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
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
}
}
}
API level 21
Gets the current status of the supported camera solutions.
Name | Required | Type | Description |
---|---|---|---|
handle | Optional | Number | Indicates the handle for the device. It is obtained using the open() API. Note: Either one of "handle" or "id" must be provided. |
id | Optional | String | Indicates the camera id for the device. It is obtained using the getCameraList() API. Note: Either one of "handle" or "id" must be provided. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
solutions | Optional | Object array: solutions | Provides current status of the supported camera solutions. |
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section of this method for details. |
Error Code | Error Text | Error Description |
---|---|---|
11 | Camera device is not opened | Camera device is not opened |
32 | Wrong param | Input parameter is incorrect. |
35 | Unknown error | Unknown error happens |
47 | Wrong handle | Device handle number is incorrect. |
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
}
}
]
}
API level 11
Establishes a connection between a camera and the webOS device. Returns the device handle for this connection instance.
Name | Required | Type | Description |
---|---|---|---|
id | Required | String | Indicates the unique identifier of the camera obtained using the getCameraList() API. |
mode | Optional | String | Indicates whether the calling app can update the camera settings. Possible values are:
Note:
|
pid | Optional | Number | 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.
|
sig | Optional | Number | 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:
|
appId | Optional | String | ID of the application Note: App must have permission to open the camera. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
handle | Optional | Number | Indicates the unique identifier for each connection instance. |
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
pid | Optional | String | The process ID. |
sig | Optional | String | The Signal ID. |
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"
}
API level 11
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.
Name | Required | Type | Description |
---|---|---|---|
handle | Required | Number | Indicates the camera handle obtained using the open() API. |
params | Required | Object: camera_format | Indicates the size and format of the preview stream. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
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
}
API level 11
Sets the properties of the connected camera device.
Name | Required | Type | Description |
---|---|---|---|
handle | Required | Number | Indicates the handle for the device obtained using the open() API. |
params | Required | Object: 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. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Example code
# luna-send -n 1 -f luna://com.webos.service.camera2/setProperties '{
"handle": 9383,
"params":
{
"contrast": 100
}
}'
Response:
{
"returnValue":true
}
API level 21
Enables and disables camera solutions.
Name | Required | Type | Description |
---|---|---|---|
handle | Optional | Number | Indicates the handle for the device. It is obtained using the open() API. Note: Either one of "handle" or "id" must be provided. |
id | Optional | String | Indicates the camera id for the device. It is obtained using the getCameraList() API. Note: Either one of "handle" or "id" must be provided. |
solutions | Required | Object array: solutions | Specifies the current status of the supported camera solutions. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section of this method for details. |
Error Code | Error Text | Error Description |
---|---|---|
11 | Camera device is not opened | Camera device is not opened |
32 | Wrong param | Input parameter is incorrect. |
35 | Unknown error | Unknown error happens |
47 | Wrong handle | Device handle number is incorrect. |
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
}
API level 27
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:
Name | Required | Type | Description |
---|---|---|---|
handle | Required | String | Indicates the handle for the device obtained using the open() API. |
params | Required | Object: camera_memory_source | Defines the type and source of memory. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
key | Optional | Number | Indicates the key for memory access.
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | The reason for the failure of the operation. See the 'API Error Codes Reference' section for details. |
Error Code | Error Text | Error Description |
---|---|---|
20, 32, 200 | Depends on error code | Check details in the "API Error Codes Reference" table. |
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
}
API level 11
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.
Name | Required | Type | Description |
---|---|---|---|
handle | Required | Number | Indicates the handle for the device obtained using the open() API. |
params | Required | Object: camera_capture_format | Indicates the size and format of the images to be captured. |
path | Optional | String | Indicates the location where the captured images are to be saved. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
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"
}
API level 11
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:
Name | Required | Type | Description |
---|---|---|---|
handle | Required | Number | Indicates the handle for the device obtained using the open() API. |
params | Required | Object: camera_memory_source | Defines the type and source of the memory. |
windowId | Required | String | Indicates windowId associated with the surface. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
key | Optional | Number | Indicates the key for memory access.
|
mediaId | Optional | String | Indicates the Id of the preview pipeline. |
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Error Code | Error Text | Error Description |
---|---|---|
20, 32, 106, 200 | Depends on error code | Check details in the "API Error Codes Reference" table. |
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"
}
API level 27
Stops camera and turns off streaming into the shared memory.
Note: Applications that called startCamera() should call this method to stop streaming.
Name | Required | Type | Description |
---|---|---|---|
handle | Required | Number | Indicates the handle for the device obtained using the open() API. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | The reason for the failure of the operation. See the 'API Error Codes Reference' section for details. |
Error Code | Error Text | Error Description |
---|---|---|
13, 20, 32, 200 | Depends on error code | Check details in the "API Error Codes Reference" table. |
Example : Stop camera
# luna-send -n 1 -f luna://com.webos.service.camera2/stopCamera '{"handle": 5699}'
Response:
{
"returnValue": true,
}
API level 11
Stops camera from capturing images in the continuous mode. Continuous mode captures frames in succession till the stopCapture() method is called.
Name | Required | Type | Description |
---|---|---|---|
handle | Required | Number | Indicates the handle for the device obtained using the open() API. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Example code
# luna-send -n 1 -f luna://com.webos.service.camera2/stopCapture '{"handle":9383}'
Response:
{
"returnValue":true
}
API level 11
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().
Name | Required | Type | Description |
---|---|---|---|
handle | Required | Number | Indicates the handle for the device obtained using the open() API. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Error Code | Error Text | Error Description |
---|---|---|
13, 20, 32, 200 | Depends on error code | Check details in the "API Error Codes Reference" table. |
Example code
# luna-send -n 1 -f luna://com.webos.service.camera2/stopPreview '{"handle":9383}'
Response:
{
"returnValue":true
}
Contains the capability of the camera
Name | Required | Type | Description |
---|---|---|---|
min | Optional | Number | The minimum value of the control. |
max | Optional | Number | The maximum value of the control. |
default | Optional | Number | The default value of the control. |
step | Optional | Number | The step value of the control. |
value | Optional | Number | The current value of the control. |
Indicates the size and the format in which images are to be captured.
Name | Required | Type | Description |
---|---|---|---|
width | Required | Number | Indicates the width of the image to be captured. Default width: 640 pixels |
height | Required | Number | Indicates the height of the image to be captured. Default value: 480 pixels |
format | Required | String | Indicates the format of the image. Possible values are:
Default: YUV |
nimage | Optional | Number | Indicates the number of images to be captured. Note: The field is required for capturing images in burst mode. |
mode | Required | String | Indicates the mode in which the image is to be captured. Possible values are:
|
Indicates the size and format for the preview stream and images.
Name | Required | Type | Description |
---|---|---|---|
width | Required | Number | Indicates the width of the image to be captured. Default: 640 pixels |
height | Required | Number | Indicates the height of the image to be captured. Default: 480 pixels |
format | Required | String | Indicates the format of the image. Possible values are:
Default: YUV |
fps | Required | Number | Indicates the frames per second. |
Indicates the type of the memory for the preview data to be written.
Name | Required | Type | Description |
---|---|---|---|
type | Required | String | Indicates the type of the shared memory. Possible options:
|
source | Required | String | Indicates the ID of memory source, if the client has created the memory and wants data to be written at that specific address. |
Contains the properties of the camera.
Name | Required | Type | Description |
---|---|---|---|
sharpness | Optional | Object: camera_capability | Indicates the camera sharpness |
autoExposure | Optional | Object: camera_capability | Indicates the camera auto exposure |
autoFocus | Optional | Object: camera_capability | Indicates the camera auto focus |
autoWhiteBalance | Optional | Object: camera_capability | Indicates the camera auto white balance |
backlightCompensation | Optional | Object: camera_capability | Indicates the camera backlight compensation value |
brightness | Optional | Object: camera_capability | Indicates the camera brightness |
contrast | Optional | Object: camera_capability | Indicates the camera contrast |
exposure | Optional | Object: camera_capability | Indicates the exposure value |
focusAbsolute | Optional | Object: camera_capability | Indicates the focus value |
frequency | Optional | Object: camera_capability | Indicates the camera power line frequency |
gain | Optional | Object: camera_capability | Indicates the camera gain |
gamma | Optional | Object: camera_capability | Camera gamma |
hue | Optional | Object: camera_capability | Indicates the camera hue |
pan | Optional | Object: camera_capability | Indicates the pan value |
saturation | Optional | Object: camera_capability | Indicates the camera saturation |
tilt | Optional | Object: camera_capability | Indicates the tilt value |
whiteBalanceTemperature | Optional | Object: camera_capability | Indicates the white balance temperature |
zoomAbsolute | Optional | Object: camera_capability | Indicates the zoom value |
Indicates the information about the camera.
Name | Required | Type | Description |
---|---|---|---|
name | Optional | String | Indicates the name of the camera. |
type | Optional | String | Indicates the type of the device. Possible values are:
|
builtin | Optional | Boolean | Indicates if the camera is built-in or not. |
resolution | Optional | Object | Indicates the supported format resolutions. |
supported | Optional | Boolean | Indicates whether the camera is supported. |
Contains the list of cameras connected to the webOS device.
Name | Required | Type | Description |
---|---|---|---|
id | Optional | String | Indicates the unique camera identifier. |
Detailed information of a specific solution.
Name | Required | Type | Description |
---|---|---|---|
enable | Required | Boolean | Status of solution [enable/disable each solution] |
Indicates the image size and image format.
Name | Required | Type | Description |
---|---|---|---|
maxWidth | Optional | Number | Width value |
maxHeight | Optional | Number | Height value |
format | Optional | String | Supported formats |
Information of all supported camera solutions.
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | Name of supported solution. |
params | Required | Object: params | Detailed information of a specific solution. |
Indicates the video size and the video format.
Name | Required | Type | Description |
---|---|---|---|
maxWidth | Optional | Number | Indicates the width value. |
maxHeight | Optional | Number | Indicates the height value. |
format | Optional | String | Gives the supported format for video. |
frameRate | Optional | Number | Indicates the video frame rate. |
Error Code | Error Text | Error Description |
---|---|---|
2 | Cannot close device | Device cannot be closed. |
3 | Cannot open device | Device cannot be opened. |
5 | Cannot start device | Preview stream cannot be started. |
6 | Cannot stop device | Preview stream cannot be stopped. |
7 | Device already closed | Device is already closed. |
8 | Device is already open | Device is already opened. |
9 | Device is already started | Preview stream is already started. |
10 | Device is already stopped | Preview stream is already stopped. |
11 | Device not opened | Device is not opened. |
12 | Device not started | Preview stream is not yet started. |
13 | There is no device | There is no device connected corresponding to input ID. |
20 | Parsing error | Luna command parsing error. |
22 | Out of param range | A parameter value is not within the expected or allowed range. |
23 | Param missing | One or more parameters are missing in luna command. |
29 | Device unsupported | Device is not supported. |
30 | Format unsupported | Format is not supported. |
32 | Wrong param | Input parameter is incorrect. |
35 | Unknown error | Unknown error |
38 | Fail to open file | Fail to open file |
39 | Fail 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. |
44 | Already 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. |
45 | Cannot write at specified location | Cannot write at the specified location. |
46 | Unsupported Memory Type | Error due to unsupported memory type |
47 | Wrong handle | Handle is not exist. |
48 | Preview not started | Preview is not started. |
49 | Handle is not in POSIXSHM mode | Handle is not in POSIXSHM mode |
51 | Failed to register pid with specified signal | Id of the signal is not valid. |
52 | Must specify client pid | PID should be provided in the request. |
100 | The subscribed camera is disconnected | The subscription is canceled because the camera is disconnected. |
105 | Request Timeout | Requested operation is timed out. |
106 | Invalid windowId | The windowId is invalid. |
200 | Invalid state | Camera device state is invalid. |
Contents