Hi, I want to get specific categories’s bounding boxes(eg. car, human …) in image,
1 does v4 api provide entry to get object’s bounding boxes in image?
2 if not, I try to use polygons to transform to bounding boxes as polygons provided by v3 object detection api, but I work with v4 api, and use https://graph.mapillary.com/:image_id/detections
to get polygons, I use code below:
# Python 3.8.3
from urllib.parse import urljoin, urlparse, urlencode, urlunparse
import requests
import base64
default_header:requests.structures.CaseInsensitiveDict = requests.utils.default_headers()
client_token = $YOUR_CLIENT_TOKEN
default_header['Authorization'] = 'OAuth ' + client_token
if __name__ == '__main__':
img_id = '162491019065656'
url = urlparse(urljoin('https://graph.mapillary.com','{}/detections'.format(img_id)))
query = urlencode({'fields':'geometry,value,image'})
url = urlunparse(url._replace(query=query))
response = requests.get(url, headers=default_header)
js = response.json()
mytest = js['data'][0]['geometry']
print(mytest)
print(base64.b64decode(mytest).decode('utf-8'))
And get json below:
{
"data": [
{
"geometry": "GjgKBm1weS1vchIYEgIAABgDIhAJzBvgGhrMAgAAqgPLAgAPGgR0eXBlIgkKB3BvbHlnb24ogCB4AQ==",
"value": "warning--traffic-merges-left--g1",
"image": {
"geometry": {
"type": "Point",
"coordinates": [
139.7798438,
35.6831047
]
},
"id": "162491019065656"
},
"id": "164110925570332"
},
{
"geometry": "GjUKBm1weS1vchIVEgIAABgDIg0J9CLIHxpsAABCawAPGgR0eXBlIgkKB3BvbHlnb24ogCB4AQ==",
"value": "information--general-directions--g1",
"image": {
"geometry": {
"type": "Point",
"coordinates": [
139.7798438,
35.6831047
]
},
"id": "162491019065656"
},
"id": "164275338887224"
},
{
"geometry": "GlV4AgoGbXB5LW9yKIAgEkYIARgDIkAJxi+MGdoBPQAFDQDjAgQNQgEADAQIBAAABQgHCAICB1oBCAIYBQgOA4QCBGIHFEUAEQUbAAMFAAcHAAsHBwgP",
"value": "object--sign--advertisement",
"image": {
"geometry": {
"type": "Point",
"coordinates": [
139.7798438,
35.6831047
]
},
"id": "162491019065656"
},
"id": "165684308746327"
},
{
"geometry": "GjZ4AgoGbXB5LW9yKIAgEicIARgDIiEJ9ifKHmoXAwsHAXcIBSoAGgQGAgYKAxYCQAYaCQwnAQ8=",
"value": "object--sign--advertisement",
"image": {
"geometry": {
"type": "Point",
"coordinates": [
139.7798438,
35.6831047
]
},
"id": "162491019065656"
},
"id": "166312585350166"
}
]
}
3 what does each of two id in returned json mean? it seems some of them are not related to image id I set.
And also get UnicodeDecodeError
:
GjgKBm1weS1vchIYEgIAABgDIhAJzBvgGhrMAgAAqgPLAgAPGgR0eXBlIgkKB3BvbHlnb24ogCB4AQ==
Traceback (most recent call last):
File "download_img_from_key.py", line 19, in <module>
print(base64.b64decode(mytest).decode('utf-8'))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcc in position 21: invalid continuation byte
4 if decoded successfully, what is the content of geometry
?
5 Is the segmentation label(eg, "value": "information--general-directions--g1" ...
) the same as the v3 api ?
6 By the way, does v4 api provide instance segmentation?
I would appreciate your reply, because I arrange a lot of image keys provided by v3 api and prepare to download images, but keys is not valid now, and some of works using v3 object detection api can not work.By the way, object detection v3 api is a nice work, hope that v4 api also has this feature.
Thanks