예제 #1
0
def main():
    print "Initializing cameras..."
    pyoptitrack.waitForInitialization()
    print 'Running...'
    cameraIDs = pyoptitrack.getCameraList()

    leftCamera = Camera(cameraIDs[0], 0, True)
    rightCamera = Camera(cameraIDs[1], 1, False)

    '''
    # Just for timing!
    blobs = []
    times = []
    while True:
        L = leftCamera
        R = rightCamera
        bs = L.blobs
        if blobs != bs:
            blobs = bs
            times += [time.time()]
            if len(times) == 100:
                print times
                times = []

        L.transformBlobs()
        R.transformBlobs()

        # cluster non-corners into nodes
        L.clusterNodes()
        R.clusterNodes()
        
        def f(n): # returns location of the cluster with n blobs, combining left and right data
            if n in L.nodes:
                if n in R.nodes:
                    return ((L.nodes[n][0] + R.nodes[n][0] + BOARD_SIZE[0]/2)/2,
                            (L.nodes[n][1] + R.nodes[n][1])/2)
                else:
                    return L.nodes[n]
            else:
                if n in R.nodes:
                    return (R.nodes[n][0] + BOARD_SIZE[0]/2, R.nodes[n][1])
                else:
                    return None
        nodes = [x for x in [f(1), f(2), f(3)] if x is not None]
    '''

    
    root = CameraDebugWindow(leftCamera, rightCamera)
    root.geometry("800x800+100+100") # WIDTHxHEIGHT+X+Y
    root.mainloop()

    print 'Shutting down...'
    pyoptitrack.shutdown()
예제 #2
0
def main():
    print "Initializing cameras..."
    pyoptitrack.waitForInitialization()
    cameras = pyoptitrack.getCameraList()

    leftCamera = Camera(cameras[0], 0)
    rightCamera = Camera(cameras[1], 1)
    
    root = Tk()
    blobFrame = BlobFrame(root, leftCamera, rightCamera)
    dims = (BOARD_SIZE[0]*SCALE, BOARD_SIZE[1]*SCALE)
    root.geometry("%dx%d+0+0" % dims) # WIDTHxHEIGHT+X+Y
    root.mainloop()

    print 'Shutting down...'
    pyoptitrack.shutdown()