python脚本

import subprocess
import os
from os import path
import shutil


plypath=r"D:\Point_cloud\AVS_dataset"
ply_name={"Ford_01_AVS_1mm":"Ford_01_AVS_1mm\\Ford_01_1mm-0100.ply",\
          "Ford_02_AVS_1mm":"Ford_02_AVS_1mm\\Ford_02_1mm-0100.ply",\
          "Ford_03_AVS_1mm":"Ford_03_AVS_1mm\\Ford_03_1mm-0100.ply",
          "Livox_01_all_in_one_1mm":"Livox_01_all_in_one_1mm\\Livox_01_all_1mm-0000.ply",\
          "Livox_02_all_in_one_1mm":"Livox_01_all_in_one_1mm\\Livox_01_all_1mm-0000.ply",}
cfg_path=r"D:\AVS\code\74\Geometry\cfg\script"
condition={"C1-limitlossyG-lossyA-ai":("r1","r2","r3","r4","r5","r6"),\
           "C2-losslessG-lossyA-ai":("r1","r2","r3","r4","r5","r6"),\
           "C3-losslessG-limitlossyA-ai":("r1","r2","r3","r4","r5"),\
           "C4-losslessG-losslessA-ai":" "}
bin_kind=("0")
framed_count={"Ford_01_AVS_1mm":10,\
              "Ford_02_AVS_1mm":600,\
              "Ford_03_AVS_1mm":600,\
              "Livox_01_all_in_one_1mm":387,\
              "Livox_02_all_in_one_1mm":387}
compressed_init={"Ford_01_AVS_1mm":"compressed-0100.bin",\
                 "Ford_02_AVS_1mm":"compressed-0100.bin",\
              "Ford_03_AVS_1mm":"compressed-0100.bin",\
              "Livox_01_all_in_one_1mm":"compressed-0000.bin",\
              "Livox_02_all_in_one_1mm":"compressed-0000.bin"}
              
workpath=path.dirname(__file__)
Text_path=workpath+"\\"+"Text"
if os.path.exists(Text_path):
    shutil.rmtree(Text_path)
os.mkdir(Text_path)
text_condition=("C1-limitlossyG-lossyA-ai","C2-losslessG-lossyA-ai","C3-losslessG-limitlossyA-ai",\
                "C4-losslessG-losslessA-ai")
for con_dir in text_condition:
    os.mkdir(Text_path+"\\"+con_dir)

name=type(condition["C1-limitlossyG-lossyA-ai"])

def run(exe_dir,ply_dir,cfg_path,text_dir,name):
    temp_file=open(text_dir,'a')
    encode_dir=exe_dir+"_encoder.exe"
    encode_cfg=cfg_path+"\\"+"encoder.cfg"
    encode_args=encode_dir+" -c "+encode_cfg+" --input "+ ply_dir+\
                            " --bitstream "+workpath+"\\"+"compressed.bin --md5_file_name md5.txt "\
                            "--frames_to_be_coded "+str(framed_count[name])+" --recon "+workpath+"\\"+"reconstruct.ply"
    decode_dir=exe_dir+"_decoder.exe"
    decode_cfg=cfg_path+"\\"+"decoder.cfg"
    decode_args=decode_dir+" -c "+decode_cfg+" --bitstream "+workpath+"\\"+ compressed_init[name]+" --md5_file_name md5.txt "\
                            "--frames_to_be_coded "+str(framed_count[name])+" --recon "+workpath+"\\"+"dec.ply"
    encoder=subprocess.Popen(encode_args,stdout=temp_file) 
    encoder.wait()
    decoder=subprocess.Popen(decode_args,stdout=temp_file) 
    decoder.wait()
   
def begin(ply_name,condition,bin_kind):
    for name in ply_name:
        for CD in condition:
            for QP in condition[CD]:
                for B in bin_kind:
                    exe_dir=workpath+"\\"+B
                    ply_dir=plypath+"\\"+ply_name[name]
                    cfg_dir=cfg_path+"\\"+CD+"\\"+name+"\\"+QP
                    text_dir=Text_path+"\\"+CD+"\\"+name+"_"+B+".txt"
                    run(exe_dir,ply_dir,cfg_dir,text_dir,name)
            
    
begin(ply_name,condition,bin_kind)      




今天自己动手写了一个利用模块subprocess中的类Popen调用可执行文件,注意这个模块由于是可以调用多个线程,所以在同一个代码块写两个subprocess.Popen的时候,需要调用这个封装类的wait()函数,否则会出现乱序的问题。或者直接调用这个类的**subprocess.call(encode_args,stdout=temp_file)**也可以达到两个线程之间相互等待的一个过程。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值