コード例 #1
0
def getKdSubsampling(bounds,points):
    pointObjs = []
    for point in points:
        pointObjs.append( ou.getPointObjects(point[0],point[1]))
    myOctree = oct.Octree(5)
    myOctree.createOctree(pointObjs, True)
    return myOctree.getKdSubsamplePoints()
コード例 #2
0
 def test(self, octDyn, pts, newPts):
     pts[len(newPts):].extend(newPts)
     staticPts = ou.copyPointObjects(pts)
     octStatic = Octree.Octree(8, octDyn.bounds, 35, 100)
     octStatic.createOctree(staticPts, True)
     isEqual = octDyn.compare(octStatic)
     print(isEqual)
     isEqual = True
     return pts, isEqual
コード例 #3
0
    def initRoach(self):
        self.wave = ss.getRoachPoints()
        self.waveLength = len(self.wave)

        self.waveStart = 0
        self.waveEnd = tde.getWaveEnd(self.waveStart)

        (tmpX, tmpY) = zip(*[(point[1], point[2]) for point in self.wave])
        bounds = self.getBoundsCreatePoints(tmpX, tmpY)
        binDepth = 6
        self.oct = Octree.Octree(binDepth, bounds, 4, 4)
        self.oct.createOctree(self.points, True)
コード例 #4
0
 def initActivityRecognition(self, sub_idx):
     #testortrain = ['test','train']
     testortrain = ['test']
     #iterations = ['1','2','3','4']
     iterations = ['1']
     self.runtime = 0
     self.tot_run = 0
     for tot in testortrain:
         for iteration in iterations:
             saveLocation = '.\\Data\\Subject' + sub_idx + '\\Subsamples_' + tot + '\\It_' + iteration + '\\'
             self.windows = ss.getWindowedPoints(sub_idx, iteration, tot)
             i = 0
             for window in self.windows:
                 self.wave = window
                 self.waveStart = 0
                 self.waveEnd = tde.getWaveEnd(self.waveStart)
                 self.x = [float(i[0]) for i in self.wave]
                 self.y = [float(i[1]) for i in self.wave]
                 self.z = [float(i[2]) for i in self.wave]
                 self.x = np.array(self.x)
                 self.y = np.array(self.y)
                 self.z = np.array(self.z)
                 self.points = ou.getPointObjects(self.x, self.y, self.z)
                 binThreshold = math.ceil(1000 / len(self.points))
                 binThreshold = min(3, binThreshold)
                 bounds = self.getBoundsThree(self.points)
                 self.oct = Octree.Octree(4, bounds, binThreshold, 10)
                 start = time.perf_counter()
                 self.oct.createOctree(self.points, True)
                 self.runtime += time.perf_counter() - start
                 self.tot_run += 1
                 # sample = self.oct.getKdSubsamplePoints()
                 # while len(sample) < 3 and self.oct.trajThreshold > 1:
                 # self.oct.decreaseThreshold()
                 # sample = self.oct.getKdSubsamplePoints()
                 # if not os.path.exists(saveLocation):
                 # os.makedirs(saveLocation)
                 # with open(saveLocation + 'joint'+str((i%6)+1)+'window'+str((i//6)+1)+'.csv','w',newline='') as outFile:
                 # writer = csv.writer(outFile)
                 # for point in sample:
                 # writer.writerow(point)
                 # i+=1
                 # plt.cla()
                 del self.oct
コード例 #5
0
 def __init__(self,fig,ax):
     self.fig = fig
     self.ax = ax
     self.wave = np.array(Startup())
     self.waveStart = 0
     self.waveEnd = tde.getWaveEnd(self.waveStart)
     self.waveLength = self.wave.size
     [self.x,self.y, self.tauX] = tde.getPhaseData(self.wave, self.waveStart, self.waveEnd)
     self.oldX = []
     self.oldY = []
     self.newX = []
     self.newY = []
     self.points = ou.getPointObjects(self.x,self.y)
     self.oct = Octree.Octree(5)
     start = time.perf_counter()
     self.oct.createOctree(self.points,True)
     self.drawScatter()
     self.drawOctree()
     self.fig.canvas.draw()
     print(time.perf_counter()-start)
コード例 #6
0
    def initMapping(self):
        self.wave = ss.getMapPoints()
        self.waveLength = len(self.wave)

        self.waveStart = 0
        self.waveEnd = tde.getWaveEnd(self.waveStart)

        (tmpX, tmpY) = zip(*[(point[0], point[1]) for point in self.wave])
        bounds = self.getBoundsCreatePoints(tmpX, tmpY)
        #self.visualizePaths()
        #plt.show()
        #return
        binDepth = 11
        self.preprocessData(bounds, binDepth)
        self.ax.set_xlim([bounds.minX, bounds.maxX])
        self.ax.set_ylim([bounds.minY, bounds.maxY])
        self.oct = Octree.Octree(binDepth, bounds, 10, 100)
        start_time = time.time()
        self.oct.createOctree(self.points, True)
        print("runtime : {}".format(time.time() - start_time))
コード例 #7
0
 def initMisc(self):
     self.wave = ss.getPointsFromFile()
     self.waveStart = 0
     self.waveEnd = tde.getWaveEnd(self.waveStart)
     self.x = [float(i[0]) for i in self.wave]
     self.y = [float(i[1]) for i in self.wave]
     self.z = [float(i[2]) for i in self.wave]
     self.x = np.array(self.x)
     self.y = np.array(self.y)
     self.z = np.array(self.z)
     self.points = ou.getPointObjects(self.x, self.y, self.z)
     binThreshold = 2
     bounds = self.getBoundsThree(self.points)
     self.oct = Octree.Octree(4, bounds, binThreshold, 10)
     start = time.perf_counter()
     self.oct.createOctree(self.points, True)
     self.visualizePaths()
     self.drawOctree()
     plt.show()
     sample = self.oct.getKdSubsamplePoints()
     print(time.perf_counter() - start)
コード例 #8
0
    newPts = dim[(i*overlap)+windowSize:((i+1)*overlap)+windowSize]
    return newPts

def getWindow(dim, i):
    windowSize = 1000
    overlap = 500
    newPts = dim[(i*overlap)+windowSize:((i+1)*overlap)+windowSize]
    return newPts


if __name__ == '__main__':
    windowSize = 1000
    overlap = 500
    dataStream = getPointsFromFile()
    points = ou.getPointObsFromSingleSrc(dataStream)
    myOctree = oct.Octree(5)
    baseSet = points[0:windowSize]
    myOctree.createOctree(baseSet,True)
    iterations = floor((len(points)-len(baseSet))/(windowSize-overlap))
    sampling = []
    for i in range(iterations):
        newPts = points[(i*overlap)+windowSize:((i+1)*overlap)+windowSize]
        myOctree.appendPoints(newPts)
        sample = myOctree.getKdSubsamplePoints()
        sampling.append(sample)
    with open('sampling.csv', 'w', newline='') as outFile:
        writer = csv.writer(outFile)
        i=0
        for line in sampling:
            i=i+1
            for point in line: