Google 會運用 AI 技術將內容翻譯成你偏好的語言,但可能會出錯。
執行
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
/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
}
} |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2026-09-11 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2026-09-11 (世界標準時間)。"],[],["The `/osc/commands/execute` API triggers commands on a camera, defined by a command `name` and associated `parameters`. The output indicates the command's `state` (`done`, `inProgress`, or `error`), an optional `id` for `inProgress` commands, `results` for completed commands, or `error` details. Possible errors include `unknownCommand`, `disabledCommand`, `missingParameter`, and `invalidParameterValue`. Example requests demonstrate how to set options and take a picture, with the responses showing command completion or ongoing progress.\n"]]