程序优化
This commit is contained in:
1 parent
e83deda268
commit
e1a7647fcb
16 files changed
+634
-91
No files matched your search
+40
-6
@@ -1,7 +1,9 @@
|
||||
import os, time, json, requests, shutil, oss2, psutil
|
||||
from tqdm import tqdm
|
||||
from PIL import Image, ImageEnhance
|
||||
import config,libs_db
|
||||
import config,libs_db,common
|
||||
import threading
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
def find_blender_bin_path():
|
||||
base_path = 'C:\\Program Files\\Blender Foundation\\'
|
||||
@@ -222,7 +224,7 @@ def set_photo_join_type(workdir, pid, photoN, camera_id, mesh = '0', texture='0'
|
||||
with open(filename, 'w') as f:
|
||||
f.writelines(lines)
|
||||
|
||||
def down_from_oss(oss_client, workdir, pid, per=100):
|
||||
def down_from_oss(oss_client, workdir, pid, per=100,photoPath=""):
|
||||
start_time = time.time()
|
||||
path = os.path.join(workdir, pid)
|
||||
if os.path.exists(path):
|
||||
@@ -237,20 +239,52 @@ def down_from_oss(oss_client, workdir, pid, per=100):
|
||||
filelist = oss2.ObjectIteratorV2(oss_client, prefix=prefix)
|
||||
for file in tqdm(filelist):
|
||||
filename = file.key.split('/')[-1]
|
||||
localfile = ""
|
||||
# print('正在下载:', file.key)
|
||||
if filename.endswith('_1.jpg'):
|
||||
localfile = os.path.join(path, 'photo1', filename)
|
||||
if photoPath == "":
|
||||
if filename.endswith('_1.jpg'):
|
||||
localfile = os.path.join(path, 'photo1', filename)
|
||||
else:
|
||||
localfile = os.path.join(path, 'photo2', filename)
|
||||
else:
|
||||
localfile = os.path.join(path, 'photo2', filename)
|
||||
|
||||
if photoPath=="1":
|
||||
if filename.endswith('_1.jpg'):
|
||||
localfile = os.path.join(path, 'photo1', filename)
|
||||
else:
|
||||
if filename.endswith('_8.jpg'):
|
||||
localfile = os.path.join(path, 'photo2', filename)
|
||||
if localfile == "":
|
||||
continue
|
||||
style = f'image/resize,p_{per}'
|
||||
if per == 100:
|
||||
oss_client.get_object_to_file(file.key, localfile)
|
||||
else:
|
||||
oss_client.get_object_to_file(file.key, localfile, process=style)
|
||||
|
||||
#判断localfile 是否有包含 photo2
|
||||
|
||||
|
||||
#遍历处理photo2的数数据
|
||||
# if str(psid) == "96" or str(pid) == "118994":
|
||||
# path = os.path.join(workdir, pid, 'photo2')
|
||||
# files = []
|
||||
# for fileName in os.listdir(path):
|
||||
# if ".jpg" in fileName:
|
||||
# files.append(path+"\\"+fileName)
|
||||
# beginTime = time.time()
|
||||
# with ThreadPoolExecutor(max_workers=6) as executor:
|
||||
# executor.map(process_image, files)
|
||||
|
||||
# print(f'{localfile}灰度处理费时{diff_time(beginTime)}')
|
||||
|
||||
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 图片下载完成, 共费时{diff_time(start_time)}')
|
||||
|
||||
#灰度处理图片
|
||||
def process_image(localfile):
|
||||
if ".jpg" in localfile:
|
||||
common.remove_gray_and_sharpening(localfile)
|
||||
|
||||
def get_defineDistances(psid):
|
||||
res = ''
|
||||
distances = libs_db.get_floor_sticker_distances(psid).split(';')
|
||||
|
||||
Reference in new issue
Block a user