如何使用Google街景发布API将一个全景图与多个全景图相连? [英] How to connect one pano to multiple panos using Google street view publish API?

查看:215
本文介绍了如何使用Google街景发布API将一个全景图与多个全景图相连?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用photo.update请求在python中进行全景(360张全景图片)连接.我只能将一个Pano连接到另一个Pano,但是我想将一个Pano连接到多个Pano.我没有获得成功的结果.

我已经使用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?如果有人能弄清楚它的可能性,那将是非常不错的.预先感谢.

解决方案

我已经看到您的请求网址为:

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"
                             }
                           }
                        ]
                        }
                   }
                ]
              }'

更新: 如果我有四个Panos,并且想要连接pano_1-> pano_2,pano_3和pano_3-> pano_4,那么json格式是什么?

您应该将pano_4作为要连接到pano_3的目标.

{
  "updatePhotoRequests": [
    {
      "updateMask": "connections",
      "photo": {
        "photoId": {
          "id": "pano_3"
        },
        "connections": [
          {
            "target": {
              "id": "pano_4"
            }
          },
        ]
      }
    }
  ]
}

请注意,id应该是上载照片的photoId.

I'm using photo.update request for panos(360 panoramic images) connection in python. I'm able to do only connect one pano to another pano but I want to connect one pano to multiple panos. I'm not getting a successful result.

I have sent the following photoUpdate request using Python:

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:

{
    "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."
                    }
                ]
            }
        ]
    }
}  

Anyone know about, How to connect multiple 360 panos from the source pano? It would be really great if someone could clarify on the possibility of it.Thanks in advance.

解决方案

I've seen that your request URL is:

https://streetviewpublish.googleapis.com/v1/photo/{}?key={}&updateMask=connections'.format("pano_1","AIzdesdfyxscvvvvvvvvvvvvvvv")

In order to connect multiple photos, you need to use the batchUpdate method.

HTTP request

POST https://streetviewpublish.googleapis.com/v1/photos:batchUpdate?

Here's a sample request using 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"
                             }
                           }
                        ]
                        }
                   }
                ]
              }'

Update: If I have four panos and I want to connect pano_1 -> pano_2, pano_3 and pano_3 -> pano_4 then what will be the json format?

You should make pano_4 as your target to be connected to pano_3.

{
  "updatePhotoRequests": [
    {
      "updateMask": "connections",
      "photo": {
        "photoId": {
          "id": "pano_3"
        },
        "connections": [
          {
            "target": {
              "id": "pano_4"
            }
          },
        ]
      }
    }
  ]
}

Just be noted that the id should be photoId of the uploaded photo.

这篇关于如何使用Google街景发布API将一个全景图与多个全景图相连?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆