cvt_dat.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import cv
00003 import os
00004 import sys
00005 import numpy
00006 import shutil
00007 
00008 
00009 def convert_dat(path):
00010   os.chdir(path)
00011 
00012   dir_list=os.listdir(".")
00013   dat_list=list()
00014   #get all dat files in directory
00015   for file in dir_list:
00016     if os.path.splitext(file)[1]==".dat":
00017       dat_list.append(file)
00018     #training_set_file_stream = open(training_set_list_path,"w")
00019 
00020     #convert dat files ony by one
00021   filerange=len(dat_list)
00022   file_ctr=0
00023   for file in dat_list:
00024     f = open(file,"r")
00025 
00026     file_content = f.read().strip()
00027     file_content = file_content.replace('\n', ';')
00028     mat=numpy.matrix(file_content)
00029     for(r,c),value in numpy.ndenumerate(mat):
00030         if mat[r,c]==-1:
00031           mat[r,c]=0
00032     mat=mat.astype(float)
00033     mat/=1000
00034 
00035     cv_mat=cv.fromarray(mat)
00036 
00037     o_path=path+"/"+os.path.splitext(file)[0]+".xml"
00038 
00039     cv.Save(o_path,cv_mat,"depthmap")
00040     o_str= "processed file "+str(file_ctr)+ " of "+ str(filerange)
00041     print o_str
00042     file_ctr+=1
00043 
00044 
00045 
00046 if __name__=="__main__":
00047   #path="/share/goa-tz/people_detection/eval/Kinect3D/"
00048   path="/home/goa-tz/Kinect3D/"
00049 
00050   folder=sys.argv[1]
00051   i_path=path+folder
00052   print i_path
00053   #src_dir="/share/goa-tz/people_detection/eval/Kinect3D_tar/"
00054   #os.chdir(path)
00055   #src_list=os.listdir(src_dir)
00056   #dir_ctr=0
00057   #for src in src_list:
00058   #  dir_str=path+str(dir_ctr)
00059   #  #os.mkdir(dir_str)
00060   #  #os.chdir(dir_str)
00061   #  src_mod=src.replace("(","\(")
00062   #  src_mod=src_mod.replace(")","\)")
00063   #  src_path_mod=src_dir+src_mod
00064   #  tarext_str="unzip "+src_path_mod+" -d ."
00065   #  os.system(tarext_str)
00066   #  tmppath=path+src
00067   #  tmppath= os.path.splitext(tmppath)[0]
00068   #  os.rename(str(tmppath),path+str(dir_ctr))
00069   #  dir_ctr+=1
00070 
00071 
00072   convert_dat(i_path)
00073 
00074   #os.system("gnome-session-save --force-logout")
00075 


cob_people_detection
Author(s): Richard Bormann , Thomas Zwölfer
autogenerated on Fri Aug 28 2015 10:24:12