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.
125 lines
4.9 KiB
125 lines
4.9 KiB
import os, sys, time, shlex, subprocess, shutil, requests, cv2, numpy as np |
|
from PIL import Image |
|
import platform,socket,atexit |
|
if platform.system() == 'Windows': |
|
sys.path.append('e:\\libs\\') |
|
#sys.path.append('libs') |
|
else: |
|
sys.path.append('/data/deploy/make3d/make2/libs/') |
|
import config, libs, libs_db,main_service_db,common |
|
|
|
arrPids = [184219,184215,184209,184206,184201,184199,184164,184087,184076,184069,184059,184029,184013,183993,183952,183888,183882,183868,183824,183817,183815,183812,183791,183777,183715,183705,183670,183613,183573,182974,182983,182985,182989,182997,183007,183051,183060,183054,183053,183097,183119,183108,183139,183141,183155,183163,183169,183180,183191,183196,183214,183244,183266,183278,183275,183309,183402,183422,183440,182974,182964,182958,182956,182916,182855,182854,182820,182787,182800,182809,182780,182772,182770,182766,182754,182742,182740,182723,182707,182647,182643,182614,182595,182563,182557,182547,182546,182538,182530,182517,182498,182478,182452,182386,182352,182285,182266,182260,182230,182224] |
|
|
|
r12Pids = [184219,184215,184209,184069,184059,183868,183817,183791,183613,183573,182974,182983,182985,182989,182997,183007,183051,183060,183054,183053,183097,183119,183108,183139,183141,183155,183163,183169,183180,183191,183196,183214,183244,183266,183278,183275,183309,183402,183422,183440,182974,182964,182958,182855,182854] |
|
print(f"处理的数据长度--{len(arrPids)}") |
|
i=0 |
|
noPids = '' |
|
for pid in r12Pids: |
|
pid = str(pid) |
|
path = f"D://{pid}/mask" |
|
#判断是否存在文件夹 |
|
if not os.path.exists(path): |
|
continue |
|
|
|
#判断文件夹是否为空 |
|
if len(os.listdir(path)) == 0: |
|
continue |
|
|
|
i+=1 |
|
|
|
|
|
#检查 depth 和 mask 的文件创建时间是否差异比较大 |
|
fileDepth = f"D://{pid}/depth" |
|
fileMask = f"D://{pid}/mask" |
|
|
|
diffDepthTime = [] |
|
dfffMaskTime = [] |
|
|
|
arrTimeDepth = [] |
|
arrTimeMask = [] |
|
for file in os.listdir(fileDepth): |
|
createTime = os.path.getctime(f"{fileDepth}/{file}") |
|
updateTime = os.path.getmtime(f"{fileDepth}/{file}") |
|
# print(updateTime - createTime) |
|
diffDepthTime.append(updateTime - createTime) |
|
arrTimeDepth.append(os.path.getctime(f"{fileDepth}/{file}")) |
|
|
|
for file in os.listdir(fileMask): |
|
createTime = os.path.getctime(f"{fileMask}/{file}") |
|
updateTime = os.path.getmtime(f"{fileMask}/{file}") |
|
dfffMaskTime.append(updateTime - createTime) |
|
|
|
arrTimeMask.append(os.path.getctime(f"{fileMask}/{file}")) |
|
|
|
#打印出 两者的 最大 和最小的时间信息 |
|
print(f"pid: {pid} depth: { (max(arrTimeDepth) - min(arrTimeDepth))/60 }, diffdepth: {max(diffDepthTime)}, mask: { (max(arrTimeMask) - min(arrTimeMask))/60},diffmask: {max(dfffMaskTime)}") |
|
# print(f"pid: {pid} diffdepth: {max(arrTimeDepth)} diffmask: {max(arrTimeMask)}") |
|
|
|
diffDepth = (max(arrTimeDepth) - min(arrTimeDepth))/60 |
|
diffMask = (max(arrTimeMask) - min(arrTimeMask))/60 |
|
|
|
if diffDepth > 5 or diffMask > 5: |
|
print(f"异常数据 pid: {pid} depth: {diffDepth} mask: {diffMask}") |
|
break |
|
|
|
#复制文件到指定目录 |
|
maskPath = f"D://{pid}/mask" |
|
depthPath = f"D://{pid}/depth" |
|
regPath = f"D://{pid}/reg" |
|
imageList = f"D://{pid}/{pid}_imageList.txt" |
|
outFila = f"D://{pid}/reg/{pid}_registration.out" |
|
|
|
sourcePath = f"D://model_info/{pid}" |
|
if os.path.exists(sourcePath): |
|
shutil.rmtree(sourcePath) |
|
|
|
if not os.path.exists(sourcePath): |
|
os.makedirs(sourcePath) |
|
|
|
#复制文件 |
|
shutil.copytree(maskPath, f"D://model_info/{pid}/mask") |
|
shutil.copytree(depthPath, f"D://model_info/{pid}/depth") |
|
shutil.copy(imageList, f"D://model_info/{pid}/{pid}_imageList.txt") |
|
shutil.copy(outFila, f"D://model_info/{pid}/{pid}_registration.out") |
|
|
|
#遍历reg文件夹 |
|
for file in os.listdir(regPath): |
|
if file == f"{pid}_registration.out": |
|
continue |
|
|
|
if "_1.jpg" in file: |
|
sourceTempPath = f"D://model_info/{pid}/reg/photo1" |
|
if not os.path.exists(sourceTempPath): |
|
os.makedirs(sourceTempPath) |
|
shutil.copy(f"{regPath}/{file}", f"{sourceTempPath}/{file}") |
|
|
|
if "_8.jpg" in file: |
|
sourceTempPath = f"D://model_info/{pid}/reg/photo2" |
|
if not os.path.exists(sourceTempPath): |
|
os.makedirs(sourceTempPath) |
|
shutil.copy(f"{regPath}/{file}", f"{sourceTempPath}/{file}") |
|
|
|
#shutil.copy(f"{regPath}/{file}", f"D://model_info/{pid}/reg/{file}") |
|
|
|
#移除 reg 里的 {pid}_registration.out |
|
|
|
|
|
print(f"处理完成 pid: {pid}") |
|
|
|
|
|
|
|
|
|
# shutil.copytree(f"D://{pid}", f"D://{pid}_bak") |
|
|
|
|
|
|
|
# cmd = f'{config.rcbin} {config.r2["init"]} -setInstanceName {pid} \ |
|
# -load "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}"'# -quit |
|
# print(cmd) |
|
# cmd = shlex.split(cmd) |
|
# res = subprocess.run(cmd) |
|
|
|
|
|
|
|
|
|
#print(i) |