コード例 #1
0
ファイル: sashindex.py プロジェクト: matthiascy/pycvf
 def save(self,filename):
     pycvf_debug(10, "saving sash")
     pycvf_debug(10, "keys : " + str(self._keys.shape) +":"  + str(self._keys))
     if (self._keys not in [None,[]]): 
       pickle.dump(self._values,file(filename+"-values.dat","wb"))
       scipy.io.savemat(filename+"-keys.mat",{"keys":self._keys})
       self.sashindex.save(filename+"-sash.sash")#,self._keys)
コード例 #2
0
ファイル: lshindex_lshkit.py プロジェクト: matthiascy/pycvf
 def save(self, filename):
     pycvf_debug(10, "saving lsh")
     pycvf_debug(10, "keys : " + str(self._keys))
     if self._keys not in [None, []]:
         pickle.dump(self._values, file(filename + "values.dat", "wb"))
         scipy.io.savemat(filename + "keys.mat", {"keys": self._keys})
         self.lshindex.save(filename + "index.lsh")  # ,self._keys)
コード例 #3
0
ファイル: cached.py プロジェクト: matthiascy/pycvf
 def save(self):
     if self.dirty:
       pycvf_debug(10, "writing "+self.filename+"...")
       f=file(self.filename,"wb")
       self.instance.dump(f)
       f.close()
       self.dirty=False
コード例 #4
0
 def __del__(self):
     pycvf_debug(10,"deleting "+str(self.file))        
     if (self.vr):
       self.tracks=[]
       self.vr.close()
       del self.vr
     self.vr=None
     self.stream=None
コード例 #5
0
 def copy(self):
     pycvf_debug(10,"copying "+str(self.file))                
     nvr=SimpleVideoReader7(self.file,self.ts)
     try:
       nvr.seek_to(self.get_current_frame_no())
     except:
        pass
     return nvr
コード例 #6
0
ファイル: cached.py プロジェクト: matthiascy/pycvf
 def __del__(self):
     if self.dirty:
       if (self.verbose):
         pycvf_debug(10, "writing "+self.filename+"...")
       f=file(self.filename,"wb")
       self.instance.dump(f)
       f.close()
       self.dirty=False
コード例 #7
0
ファイル: load_index.py プロジェクト: matthiascy/pycvf
 def save(self):
   if (self.dirty):
      pycvf_debug(10,"saving index "+self.filename+"...")
      try:
        self.idx.save(self.filename)
      except TypeError:
        pycvf_warning("Strange, strange, strange ... it seems that your index class "+str(type(self.idx))+(str(self.idx))+" does not accept a name while saving ")
        self.idx.save()
        pycvf_debug(20,"cache save without name done")
      self.dirty=False
コード例 #8
0
ファイル: lshindex_lshkit.py プロジェクト: matthiascy/pycvf
 def load(filename):
     pycvf_debug(10, "load " + filename)
     r = LshKitIndex()
     f = file(filename + "values.dat", "rb")
     r._values = pickle.load(f)
     r._keys = scipy.io.loadmat(filename + "keys.mat")["keys"].copy("C")
     r.lshindex = MPLSHIndex(r._keys)
     r.lshindex.load(filename + "index.lsh")
     pycvf_debug(10, "/load " + filename)
     return r
コード例 #9
0
ファイル: sashindex.py プロジェクト: matthiascy/pycvf
 def load(filename):
     pycvf_debug(10,"load "+filename)
     r=SashIndex()
     f=file(filename+"-values.dat","rb")
     r._values=pickle.load(f)
     r._keys=scipy.io.loadmat(filename+"-keys.mat")["keys"].copy('C')
     r.sashindex=Sash()
     #print r._keys
     r.sashindex.build(r._keys,filename=filename+"-sash.sash")
     pycvf_debug(10,"/load "+filename)
     return r
コード例 #10
0
ファイル: pandore.py プロジェクト: matthiascy/pycvf
def pandore(img,cmd):
    t=TempDirectory()
    tmpfile=t.get()
    try:
      infile=os.path.join(tmpfile,"in.bmp")
      resfile=os.path.join(tmpfile,"out.bmp")
      pandorecmd="""
export PATH=%s/bin:$PATH
export LD_LIBRARY_PATH=%s/lib:$LD_LIBRARY_PATH
cd %s
echo "BMP2PAN"
pbmp2pan in.bmp in.pan
echo "OPERATOR"
%s
echo "PAN2BMP"
ppan2bmp out.pan out.bmp
rm *.pan || true
    """%(PANDOREPATH,PANDOREPATH,tmpfile.get(),cmd)
      NumPy2PIL(img).save(infile)
      pycvf_debug(10,"pan")
      os.system(pandorecmd)
      pycvf_debug(10,"/pan")      
      img=PIL2NumPy(PIL.Image.open(resfile))
    return img
コード例 #11
0
ファイル: load_index.py プロジェクト: matthiascy/pycvf
 def __init__(self,idx_class,filename,idx_factory=None,verbose=True):
   if idx_factory==None:
     idx_factory=lambda : idx_class()
   try: 
      self.idx=idx_class.load(filename)
      pycvf_debug(10,"index "+filename+"sucessfully loaded !!!")
      self.dirty=False
   except Exception,e:
      pycvf_debug(10,"failed to load "+filename+"..."+str(e))
      pycvf_debug(10,"creating new index "+filename+"...")
      self.idx=idx_factory()
      self.dirty=True
コード例 #12
0
         else:
           ts=pyffmpeg.TS_VIDEO
       else:
         ts=track_selector
       self.ts=ts
       self.vr.open(file,ts)
       self.tracks=self.vr.get_tracks()
     except TypeError,e:
         print "ERROR", file,e
         raise
     except:
         raise
     self.stream=self.tracks[0]
     assert(self.stream!=None)
     self.frameno=0
     pycvf_debug(10,"/opening "+str(file))        
 def copy(self):
     pycvf_debug(10,"copying "+str(self.file))                
     nvr=SimpleVideoReader7(self.file,self.ts)
     try:
       nvr.seek_to(self.get_current_frame_no())
     except:
        pass
     return nvr
 def __del__(self):
     pycvf_debug(10,"deleting "+str(self.file))        
     if (self.vr):
       self.tracks=[]
       self.vr.close()
       del self.vr
     self.vr=None