執行
/osc/commands/execute
API 會對相機執行指定的命令。 輸出是命令物件。
輸入
名稱 |
類型 |
描述 |
name |
字串 |
要執行的命令。 |
parameters |
物件 |
根據命令定義規格而定的命令輸入參數。 如需範例,請參閱 OSC API 規格。 |
輸出
名稱 |
類型 |
描述 |
name |
字串 |
要執行的命令。 |
state |
字串 |
命令的狀態。 應該為下列其中之一:
done - 完成,已在此回應中傳回結果。
inProgress - 仍在執行中。
error - 失敗,請查看回應中的錯誤。
|
id |
字串 (選擇性) |
命令 ID。 需要有這個值,命令才能傳回狀態 inProgress。 例如,camera.takePicture 命令需要進行拼接,所以會需要數秒鐘的時間。 如果更多詳細資料,請參閱「狀態」。 |
results |
物件(選擇性) |
命令結果。 如果預期命令會傳回結果,需要有這個值,命令才能傳回狀態 done;例如,
“results” : {
“AAA”:“BBB”,
...
}
如需範例,請參閱 OSC API 規格。 |
error |
物件(選擇性) |
命令錯誤描述。 需要有這個值,命令才能傳回狀態 error; 例如:
“error”: {
“code”: “missingParameter”
} |
progress |
物件(選擇性) |
命令進度描述。 需要有這個值,命令才能傳回狀態 inProgress ;例如:
“progress”: {
“completion”: 0.8
} |
錯誤
錯誤代碼 |
描述 |
unknownCommand |
要求的命令不明,例如 如果 v2 用戶端(clientVersion 設定為 2,請參閱 選項)從 API 層級 1 要求已淘汰的命令,該要求應該失敗並附上此錯誤代碼。 |
disabledCommand |
執行的指令目前已停用,例如, 當相機處於影片模式時,`takePicture` 指令停用;當相機不支援 delayProcessing 時,processPicture 指令停用。
API 層級 2 中已新增此錯誤代碼。 |
cameraInExclusiveUse |
相機處於獨佔使用中,無法啟動新的工作階段。 API 層級 2 中已淘汰此錯誤代碼。 |
missingParameter |
未指定一或多個必要參數。 |
invalidParameterName |
無法辨識或不支援一或多個輸入參數或選項名稱。 |
invalidParameterValue |
辨識出參數或選項名稱,但有一或多個無效值;例如,值超出範圍。 |
範例 |
要求 (API 1) |
POST /osc/commands/execute HTTP/1.1
Host: [camera ip address]:[httpPort]
Content-Type: application/json;charset=utf-8
Accept: application/json
Content-Length: {CONTENT_LENGTH}
X-XSRF-Protected: 1
{
"name": "camera.setOptions",
"parameters": {
"sessionId": "12ABC3",
"options": {
"iso": 200,
"exposureCompensation": -2
}
}
} |
要求 (API 2) |
POST /osc/commands/execute HTTP/1.1
Host: [camera ip address]:[httpPort]
Content-Type: application/json;charset=utf-8
Accept: application/json
Content-Length: {CONTENT_LENGTH}
X-XSRF-Protected: 1
{
"name": "camera.setOptions",
"parameters": {
"options": {
"iso": 200,
"exposureCompensation": -2
}
}
} |
回應 |
HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
Content-Length: {CONTENT_LENGTH}
X-Content-Type-Options: nosniff
{
"name": "camera.setOptions",
"state": "done"
} |
要求 (API 1) |
POST /osc/commands/execute HTTP/1.1
Host: [camera ip address]:[httpPort]
Content-Type: application/json;charset=utf-8
Accept: application/json
Content-Length: {CONTENT_LENGTH}
X-XSRF-Protected: 1
{
"name": "camera.takePicture",
"parameters": {
"sessionId": "12ABC3"
}
} |
要求 (API 2) |
POST /osc/commands/execute HTTP/1.1
Host: [camera ip address]:[httpPort]
Content-Type: application/json;charset=utf-8
Accept: application/json
Content-Length: {CONTENT_LENGTH}
X-XSRF-Protected: 1
{
"name": "camera.takePicture"
} |
回應 |
HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
Content-Length: {CONTENT_LENGTH}
X-Content-Type-Options: nosniff
{
"name": "camera.takePicture",
"state": "inProgress",
"id": "90ABCD",
"progress": {
"completion": 0
}
} |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2017-04-06 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"缺少我需要的資訊"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"過於複雜/步驟過多"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"過時"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻譯問題"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"示例/程式碼問題"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"容易理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"確實解決了我的問題"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]