尝试使用街景发布服务客户端Python更新照片元数据时出错

2024-04-29 05:31:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我在街景中上传了几张照片,我想使用Python客户端库来更新它的元数据。下面是我的代码片段:

from google.proto.streetview.publish.v1 import resources_pb2
from google.streetview.publish.v1 import street_view_publish_service_client as client
from google.protobuf import field_mask_pb2

streetview_client = client.StreetViewPublishServiceClient(credentials=credentials)

for photo in streetview_client.list_photos(0, ''):
    con = resources_pb2.Connection()
    target_id = resources_pb2.PhotoId()
    target_id.id = "photo_id"
    con.target.id = target_id.id
    photo.connections.extend([con])
    update_mask = field_mask_pb2.FieldMask()
    update_mask.FromJsonString("connections")
    response = streetview_client.update_photo(photo, update_mask)
    break

我想连接这两张照片,所以我将目标id添加到查询照片中,并将字段“connections”添加到update\u mask中。 update_photo调用后的结果是以下错误消息:

google.gax.errors.RetryError: RetryError(Exception occurred in retry method that was not classified as transient, caused by <_Rendezvous of RPC that terminated with (StatusCode.INVALID_ARGUMENT, Empty level name is not accepted.)>)

有什么提示吗?你知道吗


Tags: fromimportclientidtargetgoogleupdatemask
1条回答
网友
1楼 · 发布于 2024-04-29 05:31:57

为了在两张照片之间建立连接,需要使用^{}Connections应该设置在Photo的正下方。另外,请注意需要实现的^{}的元数据。他说

下面是一个示例代码片段。他说

pose = resources_pb2.Pose(level=resources_pb2.Level(name="lvl", number=0))
connection1 = resources_pb2.Connection(target=resources_pb2.PhotoId(id="idOfConnection1"))
photo = resources_pb2.Photo(connections=[connection1], pose=pose)

相关问题 更多 >