def process(cls,nrels=1,*args,**kwargs): w=World() cls.idx=load_index.__call__((cls.idx.root_class if hasattr(cls.idx,"root_class") else cls.idx.__class__),cls.index_filename) w.app=cls w.nq=int(cls.number_query.value) idb=iter(cls.vdb) w.explore_nn(idb.next()) #run() while True: if (daemon): daemon.handleRequests(0.01) taskMgr.step() w.app=None
def process(cls,nrels=1,*args,**kwargs): cls.idx=load_index.__call__((cls.idx.root_class if hasattr(cls.idx,"root_class") else cls.idx.__class__),cls.index_filename) delay=float(cls.delay.value) cls.mdl.print_tree() nq=int(cls.number_query.value) bv=int(cls.block.value) d=[ (mm[0],mm[1]) for mm in cls.mmeta.items() ] qmw=QtGui.QMainWindow() qv=QtNearestNeighborsViewerDialog(d[0],nq,bv,qmw) qv.show() qapp.processEvents() idb=iter(cls.vdb) try: while True: e=[ idb.next() for i in range(bv) ] keys=cls.mdl.process_path(map(lambda f:f[0],e),map(lambda f:f[1],e),cls.key.value,lambda x:x) #print keys #for c in keys: if True: ## compute nearest neighbours #pycvf_warning( "keysKEYSkeys:"+str( keys)) #time.sleep(0.5) keys=numpy.array(keys) l=cls.idx.getitems(keys,nq) # get the nearest element for the keys ## Extract nearest neighbours value from database #pycvf_warning( "resultRESULTresult:"+str( l)) #time.sleep(5.5) xxx=map (lambda y:map(lambda x:(cls.vdb[x[0][0]],x[1]),y),l) ## Display the results qv.push((map(lambda f:f[0],e),xxx)) qapp.processEvents() #print c if (delay): for i in range(int(delay*50)): qapp.processEvents() time.sleep(0.02) except StopIteration,e: print e