예제 #1
0
    def draw(self):
        image = self.tracker.get_image()
        pixels = psmove.cdata(image.data, image.size)

        glDisable(GL_LIGHTING)
        glEnable(GL_TEXTURE_2D)
        glBindTexture(GL_TEXTURE_2D, self.id)
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width,
                image.height, 0, GL_RGB, GL_UNSIGNED_BYTE,
                pixels)

        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        glColor4f(1., 1., 1., 1.)
        glBegin(GL_TRIANGLE_STRIP)
        glTexCoord2f(0, 0)
        glVertex3f(-1, 1, 0)
        glTexCoord2f(0, 1)
        glVertex3f(-1, -1, 0)
        glTexCoord2f(1, 0)
        glVertex3f(1, 1, 0)
        glTexCoord2f(1, 1)
        glVertex3f(1, -1, 0)
        glEnd()
        glBindTexture(GL_TEXTURE_2D, 0)
        glDisable(GL_TEXTURE_2D)
        glEnable(GL_LIGHTING)
예제 #2
0
    def draw(self):
        image = self.tracker.get_image()
        pixels = psmove.cdata(image.data, image.size)

        glDisable(GL_LIGHTING)
        glEnable(GL_TEXTURE_2D)
        glBindTexture(GL_TEXTURE_2D, self.id)
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width, image.height, 0,
                     GL_RGB, GL_UNSIGNED_BYTE, pixels)

        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        glColor4f(1., 1., 1., 1.)
        glBegin(GL_TRIANGLE_STRIP)
        glTexCoord2f(0, 0)
        glVertex3f(-1, 1, 0)
        glTexCoord2f(0, 1)
        glVertex3f(-1, -1, 0)
        glTexCoord2f(1, 0)
        glVertex3f(1, 1, 0)
        glTexCoord2f(1, 1)
        glVertex3f(1, -1, 0)
        glEnd()
        glBindTexture(GL_TEXTURE_2D, 0)
        glDisable(GL_TEXTURE_2D)
        glEnable(GL_LIGHTING)
예제 #3
0
    def draw(self):
        image = self.tracker.get_image()
        pixels = psmove.cdata(image.data, image.size)

        self.program.bind()
        self.vertex_buffer.bind()
        self.texture.bind()
        self.texture.load_rgb(image.width, image.height, pixels)

        vtxcoord_loc = self.program.attrib('vtxcoord')
        glEnableVertexAttribArray(vtxcoord_loc)
        glVertexAttribPointer(vtxcoord_loc, 2, GL_FLOAT, GL_FALSE, 0, None)
        glUniform1f(self.program.uniform('saturation'), 1.0)
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)
        glDisableVertexAttribArray(vtxcoord_loc)

        self.texture.unbind()
        self.vertex_buffer.unbind()
        self.program.unbind()
예제 #4
0
    def draw(self):
        image = self.tracker.get_image()
        pixels = psmove.cdata(image.data, image.size)

        self.program.bind()
        self.vertex_buffer.bind()
        self.texture.bind()
        self.texture.load_rgb(image.width, image.height, pixels)

        vtxcoord_loc = self.program.attrib('vtxcoord')
        glEnableVertexAttribArray(vtxcoord_loc)
        glVertexAttribPointer(vtxcoord_loc, 2, GL_FLOAT, GL_FALSE, 0, None)
        glUniform1f(self.program.uniform('saturation'), 1.0)
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)
        glDisableVertexAttribArray(vtxcoord_loc)

        self.texture.unbind()
        self.vertex_buffer.unbind()
        self.program.unbind()
예제 #5
0
pygame.init()
display = pygame.display.set_mode((640, 480))

# Loop and update the controller
while True:
    # Get the latest input report from the controller
    while move.poll(): pass

    # Grab the latest image from the camera
    tracker.update_image()
    # Update all tracked controllers
    tracker.update()

    # This is how you can get the image from the tracker
    image = tracker.get_image()
    pixels = psmove.cdata(image.data, image.size)
    surface = pygame.image.frombuffer(pixels, (image.width, image.height), 'RGB')
    display.blit(surface, (0, 0))
    pygame.display.flip()

    # Check the tracking status
    status = tracker.get_status(move)
    if status == psmove.Tracker_TRACKING:
        x, y, radius = tracker.get_position(move)
        print 'Position: (%5.2f, %5.2f), Radius: %3.2f, Trigger: %3d' % (
                x, y, radius, move.get_trigger())
    elif status == psmove.Tracker_CALIBRATED:
        print 'Not currently tracking.'
    elif status == psmove.Tracker_CALIBRATION_ERROR:
        print 'Calibration error.'
    elif status == psmove.Tracker_NOT_CALIBRATED:
pygame.init()
display = pygame.display.set_mode((640, 480))

# Loop and update the controller
while True:
    # Get the latest input report from the controller
    while move.poll(): pass

    # Grab the latest image from the camera
    tracker.update_image()
    # Update all tracked controllers
    tracker.update()

    # This is how you can get the image from the tracker
    image = tracker.get_image()
    pixels = psmove.cdata(image.data, image.size)
    surface = pygame.image.frombuffer(pixels, (image.width, image.height), 'RGB')
    display.blit(surface, (0, 0))
    pygame.display.flip()

    # Check the tracking status
    status = tracker.get_status(move)
    if status == psmove.Tracker_TRACKING:
        x, y, radius = tracker.get_position(move)
        print 'Position: (%5.2f, %5.2f), Radius: %3.2f, Trigger: %3d' % (
                x, y, radius, move.get_trigger())
    elif status == psmove.Tracker_CALIBRATED:
        print 'Not currently tracking.'
    elif status == psmove.Tracker_CALIBRATION_ERROR:
        print 'Calibration error.'
    elif status == psmove.Tracker_NOT_CALIBRATED: