dongchangxi 11 months ago
parent
commit
c4d2d32087
  1. 31
      main_step1.py

31
main_step1.py

@ -1,6 +1,6 @@
import os, sys, time, shlex, subprocess, shutil, requests, cv2, numpy as np import os, sys, time, shlex, subprocess, shutil, requests, cv2, numpy as np
from PIL import Image from PIL import Image
import platform,socket,atexit import platform,socket,atexit,redis
if platform.system() == 'Windows': if platform.system() == 'Windows':
sys.path.append('e:\\libs\\') sys.path.append('e:\\libs\\')
#sys.path.append('libs') #sys.path.append('libs')
@ -206,12 +206,41 @@ def main(pid, experience=False, makeloop=True,task_distributed_id="",isNoColorTe
if pid == '': if pid == '':
time.sleep(3) time.sleep(3)
continue continue
#判断影棚类型,如果是方形影棚,则推入到另外一个重建队列,使用新影棚的建模方式
ps_type = get_ps_type(pid)
if ps_type == 2:
r = create_redis_connection()
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {pid} 方形影棚数据推入到重建队列用新的建模方式')
r.rpush('ai:ai_repeat_for_align_info',pid)
time.sleep(3)
continue
else: else:
experience = False experience = False
step1(pid, experience, makeloop,task_distributed_id,isNoColorTexture) step1(pid, experience, makeloop,task_distributed_id,isNoColorTexture)
else: else:
step1(pid, experience, makeloop,task_distributed_id,isNoColorTexture) step1(pid, experience, makeloop,task_distributed_id,isNoColorTexture)
def create_redis_connection():
"""创建 Redis 连接,若连接失败则重试"""
while True:
try:
r = redis.Redis(host="106.14.158.208", password="kcV2000", port=6379, db=6)
# 尝试进行一次操作,检查连接是否有效
r.ping() # ping 操作是一个简单的连接测试
print("Redis连接成功!")
return r
except ConnectionError:
print("Redis连接失败,正在重试...")
time.sleep(5)
def get_ps_type(pid):
# return 1:圆形影棚 2:方形影棚
res = requests.get("https://mp.api.suwa3d.com/api/takephotoOrder/photoStudioInfo", params={'pid': pid})
return res.json()['data']['type']
if __name__ == '__main__': if __name__ == '__main__':
# 取云端redis任务,完成第一步的数据预处理后,将数据放入共享存储目录,将第二步任务塞入本地mysql队列 # 取云端redis任务,完成第一步的数据预处理后,将数据放入共享存储目录,将第二步任务塞入本地mysql队列
# 默认循环值守,可传参数运行单一任务,以方便调试 # 默认循环值守,可传参数运行单一任务,以方便调试

Loading…
Cancel
Save