执行
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
/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":"其他"
}]