我在python中使用photo.update请求进行panos(360全景图像)连接。我只能将一个全景连接到另一个全景,但我想将一个全景连接到多个全景。我没有取得成功的结果。
我使用Python发送了以下photoUpdate请求:
update_photo_url = 'https://streetviewpublish.googleapis.com/v1/photo/{}?key={}&updateMask=connections'.format("pano_1","AIzdesdfyxscvvvvvvvvvvvvvvv")
headers = {"Authorization": "Bearer {}".format("ya29.Glx6BO91jWbjzLQKYPvP16fhT-jyOEnIdnoRcZcU9uYCqzwH3Dkuf-qf_kzUc2ykYOyVTZCfaGjOEAScsJK7WgS4NE9gfS6bSobWDIMdfpfY7SPzRMmxi4kfTrmsRQ"), "Content-Length": "0", "Content-Type": "application/json"}
update_body = {
[
{
"photo": {
"photoId": {
"id": "pano_1"
},
"connections": {
"target": {
"id": "pano_2"
},
"target": {
"id": "pano_3"
}
},
}
}
]
}
update_response = requests.put(update_photo_url,headers=headers,json=update_body)
update_response.text
错误:
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"\": Root element must be a message.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"\": Root element must be a message."
}
]
}
]
}
}
任何人都知道,如何从源pano连接多个360 panos?如果有人能够澄清它的可能性,那将是非常好的。谢谢你。
答案 0 :(得分:5)
我已经看到您的请求网址为:
https://streetviewpublish.googleapis.com/v1/photo/{}?key={}&updateMask=connections'.format("pano_1","AIzdesdfyxscvvvvvvvvvvvvvvv")
要连接多张照片,您需要使用batchUpdate
方法。
HTTP请求
POST https://streetviewpublish.googleapis.com/v1/photos:batchUpdate?
这是使用curl的示例请求:
curl --request POST \
--url 'https://streetviewpublish.googleapis.com/v1/photos:batchUpdate' \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"updatePhotoRequests": [
{
"updateMask": "connections",
"photo": {
"photoId": {
"id": "pano_1"
},
"connections": [
{
"target": {
"id": "pano_2"
}
},
{
"target": {
"id": "pano_3"
}
}
]
}
}
]
}'
更新: 如果我有四个全景,我想连接pano_1 - > pano_2,pano_3和pano_3 - >那么什么是json格式?
您应该将pano_4作为连接到pano_3的目标。
{
"updatePhotoRequests": [
{
"updateMask": "connections",
"photo": {
"photoId": {
"id": "pano_3"
},
"connections": [
{
"target": {
"id": "pano_4"
}
},
]
}
}
]
}
请注意,id
应该是上传照片的photoId
。