You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.6 KiB
65 lines
2.6 KiB
#!/usr/bin/python |
|
import oss2, os, sys, shutil, requests |
|
from PIL import Image |
|
from threading import Thread |
|
import time |
|
|
|
def getPSType(pid): |
|
res = requests.get(get_ps_type_url, params={'pid': pid}) |
|
return res.json()['data']['type'] |
|
|
|
def down(path, pid): |
|
psType = getPSType(pid) |
|
if psType == 1: |
|
camera = '103' |
|
elif psType == 2: |
|
camera = '74' |
|
else: |
|
print('未知的相机类型,', psType) |
|
return |
|
|
|
photo1_file = f'photos/{pid}/photo1/{camera}_1.jpg' |
|
photo2_file = f'photos/{pid}/photo2/{camera}_8.jpg' |
|
texture_auto_file = f'objs/auto/{pid}/{pid}.jpg' |
|
texture_print_file = f'objs/print/{pid}/{pid}Tex1.jpg' |
|
if oss_client.object_exists(photo1_file) and oss_client.object_exists(photo2_file): |
|
os.mkdir(f'{workdir}/{pid}') |
|
os.mkdir(f'{workdir}/{pid}/photo1') |
|
os.mkdir(f'{workdir}/{pid}/photo2') |
|
print(f'{pid}正在下载 {photo1_file}') |
|
print(f'{pid}正在下载 {photo2_file}') |
|
print(f'{pid}正在下载 {texture_auto_file}') |
|
print(f'{pid}正在下载 {texture_print_file}') |
|
oss_client.get_object_to_file(photo1_file, f'{workdir}/{pid}/photo1/{camera}_1.jpg') |
|
oss_client.get_object_to_file(photo2_file, f'{workdir}/{pid}/photo2/{camera}_8.jpg') |
|
if oss_client.object_exists(texture_auto_file): |
|
os.mkdir(f'{workdir}/{pid}/texture_auto') |
|
oss_client.get_object_to_file(texture_auto_file, f'{workdir}/{pid}/texture_auto/{pid}.jpg') |
|
if oss_client.object_exists(texture_print_file): |
|
os.mkdir(f'{workdir}/{pid}/texture_print') |
|
oss_client.get_object_to_file(texture_print_file, f'{workdir}/{pid}/texture_print/{pid}Tex1.jpg') |
|
print(f'{pid}下载完成') |
|
else: |
|
print(f'{pid} 文件不完整, 跳过下载') |
|
|
|
if __name__ == '__main__': |
|
workdir = '/data/datasets/photos/' |
|
AccessKeyId = 'LTAI5tSReWm8hz7dSYxxth8f' |
|
AccessKeySecret = '8ywTDF9upPAtvgXtLKALY2iMYHIxdS' |
|
Endpoint = 'oss-cn-shanghai.aliyuncs.com' |
|
Bucket = 'suwa3d-securedata' |
|
oss_client = oss2.Bucket(oss2.Auth(AccessKeyId, AccessKeySecret), Endpoint, Bucket) |
|
|
|
get_ps_type_url = "https://mp.api.suwa3d.com/api/takephotoOrder/photoStudioInfo" |
|
|
|
if len(sys.argv) == 1: |
|
pids = [55165, 55118, 54862, 54790, 55065, 51056, 56025, 55806, 55592, 54864, 54521, 54623, 53861, 53787, 53596, 53147, 52487, 52768, 51394, 51007, 51294, 50052, 50766, 50464, 50117, 49626] |
|
else: |
|
pids = sys.argv[1].split(',') |
|
|
|
for item in pids: |
|
pid = str(item) |
|
path = os.path.join(workdir, pid) |
|
down(path, pid) |
|
|
|
print(f'下载完成总数:{len(pids)}') |