forked from tykayn/mapillary_download
futures were not in loop :-/
This commit is contained in:
parent
b1fffc1fab
commit
47890081e0
@ -39,6 +39,7 @@ def download(url, filepath, metadata=None):
|
|||||||
image = write_exif(r.content, metadata)
|
image = write_exif(r.content, metadata)
|
||||||
with open(str(filepath), "wb") as f:
|
with open(str(filepath), "wb") as f:
|
||||||
f.write(image)
|
f.write(image)
|
||||||
|
print("{} downloaded".format(filepath))
|
||||||
|
|
||||||
def get_single_image_data(image_id, mly_header):
|
def get_single_image_data(image_id, mly_header):
|
||||||
req_url = 'https://graph.mapillary.com/{}?fields=thumb_original_url,altitude,camera_type,captured_at,compass_angle,geometry,exif_orientation'.format(image_id)
|
req_url = 'https://graph.mapillary.com/{}?fields=thumb_original_url,altitude,camera_type,captured_at,compass_angle,geometry,exif_orientation'.format(image_id)
|
||||||
@ -128,13 +129,13 @@ if __name__ == '__main__':
|
|||||||
#sys.exit()
|
#sys.exit()
|
||||||
|
|
||||||
print('downloading.. this process will take a while. please wait')
|
print('downloading.. this process will take a while. please wait')
|
||||||
|
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
|
||||||
for i,image_data in enumerate(images_data):
|
for i,image_data in enumerate(images_data):
|
||||||
# create a folder for each unique sequence ID to group images by sequence
|
# create a folder for each unique sequence ID to group images by sequence
|
||||||
if not os.path.exists('data/{}'.format(image_data['sequence_id'])):
|
if not os.path.exists('data/{}'.format(image_data['sequence_id'])):
|
||||||
os.makedirs('data/{}'.format(image_data['sequence_id']))
|
os.makedirs('data/{}'.format(image_data['sequence_id']))
|
||||||
date_time_image_filename = datetime.utcfromtimestamp(int(image_data['captured_at'])/1000).strftime('%Y-%m-%d_%HH%Mmn%Ss%f')[:-3]
|
date_time_image_filename = datetime.utcfromtimestamp(int(image_data['captured_at'])/1000).strftime('%Y-%m-%d_%HH%Mmn%Ss%f')[:-3]
|
||||||
path = 'data/{}/{}.jpg'.format(image_data['sequence_id'], date_time_image_filename)
|
path = 'data/{}/{}.jpg'.format(image_data['sequence_id'], date_time_image_filename)
|
||||||
print(path)
|
|
||||||
img_metadata = writer.PictureMetadata(
|
img_metadata = writer.PictureMetadata(
|
||||||
capture_time = datetime.utcfromtimestamp(int(image_data['captured_at'])/1000),
|
capture_time = datetime.utcfromtimestamp(int(image_data['captured_at'])/1000),
|
||||||
longitude = image_data['geometry']['coordinates'][0],
|
longitude = image_data['geometry']['coordinates'][0],
|
||||||
@ -143,6 +144,5 @@ if __name__ == '__main__':
|
|||||||
direction = image_data['compass_angle'],
|
direction = image_data['compass_angle'],
|
||||||
altitude = image_data['altitude'],
|
altitude = image_data['altitude'],
|
||||||
)
|
)
|
||||||
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
|
|
||||||
executor.submit(download, url=image_data['thumb_original_url'], filepath=path, metadata=img_metadata)
|
executor.submit(download, url=image_data['thumb_original_url'], filepath=path, metadata=img_metadata)
|
||||||
#download(image_data['thumb_original_url'],path, img_metadata)
|
#download(image_data['thumb_original_url'],path, img_metadata)
|
||||||
|
Loading…
Reference in New Issue
Block a user