コード例 #1
0
    def gl_display_in_window(self,world_tex_id):
        """
        here we map a selected surface onto a seperate window.
        """
        if self._window and self.detected:
            active_window = glfwGetCurrentContext()
            glfwMakeContextCurrent(self._window)
            clear_gl_screen()

            # cv uses 3x3 gl uses 4x4 tranformation matricies
            m = cvmat_to_glmat(self.m_from_screen)

            glMatrixMode(GL_PROJECTION)
            glPushMatrix()
            glLoadIdentity()
            gluOrtho2D(0, 1, 0, 1) # gl coord convention

            glMatrixMode(GL_MODELVIEW)
            glPushMatrix()
            #apply m  to our quad - this will stretch the quad such that the ref suface will span the window extends
            glLoadMatrixf(m)

            draw_named_texture(world_tex_id)

            glMatrixMode(GL_PROJECTION)
            glPopMatrix()
            glMatrixMode(GL_MODELVIEW)
            glPopMatrix()

            # now lets get recent pupil positions on this surface:
            draw_gl_points_norm(self.gaze_on_srf,color=(0.,8.,.5,.8), size=80)
           
            glfwSwapBuffers(self._window)
            glfwMakeContextCurrent(active_window)
コード例 #2
0
ファイル: accuracy_test.py プロジェクト: Esperadoce/pupil
    def gl_display(self):
        """
        use gl calls to render
        at least:
            the published position of the reference
        better:
            show the detected postion even if not published
        """

        if self.active and self.detected:
            for e in self.candidate_ellipses:
                pts = cv2.ellipse2Poly( (int(e[0][0]),int(e[0][1])),
                                    (int(e[1][0]/2),int(e[1][1]/2)),
                                    int(e[-1]),0,360,15)
                draw_gl_polyline(pts,(0.,1.,0,1.))
        else:
            pass
        if self._window:
            self.gl_display_in_window()


        if not self.active and self.error_lines is not None:
            draw_gl_polyline_norm(self.error_lines,(1.,0.5,0.,.5),type='Lines')
            draw_gl_points_norm(self.error_lines[1::2],color=(.0,0.5,0.5,.5),size=3)
            draw_gl_points_norm(self.error_lines[0::2],color=(.5,0.0,0.0,.5),size=3)
コード例 #3
0
    def gl_display(self):
        """
        use gl calls to render
        at least:
            the published position of the reference
        better:
            show the detected postion even if not published
        """

        if self.active and self.detected:
            for e in self.candidate_ellipses:
                pts = cv2.ellipse2Poly( (int(e[0][0]),int(e[0][1])),
                                    (int(e[1][0]/2),int(e[1][1]/2)),
                                    int(e[-1]),0,360,15)
                draw_gl_polyline(pts,(0.,1.,0,1.))
        else:
            pass
        if self._window:
            self.gl_display_in_window()


        if not self.active and self.error_lines is not None:
            draw_gl_polyline_norm(self.error_lines,(1.,0.5,0.,.5),type='Lines')
            draw_gl_points_norm(self.error_lines[1::2],color=(.0,0.5,0.5,.5),size=3)
            draw_gl_points_norm(self.error_lines[0::2],color=(.5,0.0,0.0,.5),size=3)
コード例 #4
0
    def gl_display_in_window(self, world_tex_id):
        """
        here we map a selected surface onto a seperate window.
        """
        if self._window and self.detected:
            active_window = glfwGetCurrentContext()
            glfwMakeContextCurrent(self._window)
            clear_gl_screen()

            # cv uses 3x3 gl uses 4x4 tranformation matricies
            m = cvmat_to_glmat(self.m_from_screen)

            glMatrixMode(GL_PROJECTION)
            glPushMatrix()
            glLoadIdentity()
            gluOrtho2D(0, 1, 0, 1)  # gl coord convention

            glMatrixMode(GL_MODELVIEW)
            glPushMatrix()
            # apply m  to our quad - this will stretch the quad such that the ref suface will span the window extends
            glLoadMatrixf(m)

            draw_named_texture(world_tex_id)

            glMatrixMode(GL_PROJECTION)
            glPopMatrix()
            glMatrixMode(GL_MODELVIEW)
            glPopMatrix()

            # now lets get recent pupil positions on this surface:
            draw_gl_points_norm(self.gaze_on_srf, color=(0.0, 8.0, 0.5, 0.8), size=80)

            glfwSwapBuffers(self._window)
            glfwMakeContextCurrent(active_window)
コード例 #5
0
 def gl_draw_corners(self):
     """
     draw surface and markers
     """
     if self.detected:
         frame = np.array([[[0,0],[1,0],[1,1],[0,1]]],dtype=np.float32)
         frame = cv2.perspectiveTransform(frame,self.m_to_screen)
         draw_gl_points_norm(frame.reshape((4,2)),15,(1.0,0.2,0.6,.5))
コード例 #6
0
 def gl_draw_corners(self):
     """
     draw surface and markers
     """
     if self.detected:
         frame = np.array([[[0,0],[1,0],[1,1],[0,1]]],dtype=np.float32)
         frame = cv2.perspectiveTransform(frame,self.m_to_screen)
         draw_gl_points_norm(frame.reshape((4,2)),15,(1.0,0.2,0.6,.5))
コード例 #7
0
ファイル: drEYEve.py プロジェクト: vdurrmann/pupil
    def gl_display(self):
        """
        use gl calls to render on world window
        """
        if self.gaze_x == 0:
            draw_gl_points_norm(self.pupil_display_list,size=60,color=(1.,.5,.5,.6))
        if self.gaze_x == 1:
            draw_gl_points_norm(self.pupil_display_list,size=60,color=(.5,1.,.5,.6))

        # gl stuff that will show on the world window goes here:

        if self._window:
            self.gl_display_in_window()
コード例 #8
0
ファイル: marker_detector.py プロジェクト: r0bert0/pupil
    def gl_display_in_window(self,surface):
        """
        here we map a selected surface onto a seperate window.
        """
        active_window = glfwGetCurrentContext()
        glfwMakeContextCurrent(self._window)
        clear_gl_screen()

        # cv uses 3x3 gl uses 4x4 tranformation matricies
        m = cvmat_to_glmat(surface.m_from_screen)

        glMatrixMode(GL_PROJECTION)
        glPushMatrix()
        glLoadIdentity()
        gluOrtho2D(0, 1, 0, 1) # gl coord convention

        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        #apply m  to our quad - this will stretch the quad such that the ref suface will span the window extends
        glLoadMatrixf(m)

        #redraw will use the most recent world img texture and use it again.
        redraw_gl_texture( ((0,0),(1,0),(1,1),(0,1)) )

        glMatrixMode(GL_PROJECTION)
        glPopMatrix()
        glMatrixMode(GL_MODELVIEW)
        glPopMatrix()


        #now lets get recent pupil positions on this surface:
        try:
            gaze_on_surface = [p['realtime gaze on '+surface.name] for p in self.recent_pupil_positions]
        except KeyError:
            gaze_on_surface = []
        draw_gl_points_norm(gaze_on_surface,color=(0.,8.,.5,.8), size=80)


        glfwSwapBuffers(self._window)
        glfwMakeContextCurrent(active_window)
コード例 #9
0
    def gl_display_in_window(self, surface):
        """
        here we map a selected surface onto a seperate window.
        """
        active_window = glfwGetCurrentContext()
        glfwMakeContextCurrent(self._window)
        clear_gl_screen()

        # cv uses 3x3 gl uses 4x4 tranformation matricies
        m = cvmat_to_glmat(surface.m_from_screen)

        glMatrixMode(GL_PROJECTION)
        glPushMatrix()
        glLoadIdentity()
        gluOrtho2D(0, 1, 0, 1)  # gl coord convention

        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()
        #apply m  to our quad - this will stretch the quad such that the ref suface will span the window extends
        glLoadMatrixf(m)

        draw_named_texture(self.g_pool.image_tex)

        glMatrixMode(GL_PROJECTION)
        glPopMatrix()
        glMatrixMode(GL_MODELVIEW)
        glPopMatrix()

        #now lets get recent pupil positions on this surface:
        try:
            gaze_on_surface = [
                p['realtime gaze on ' + surface.name]
                for p in self.recent_pupil_positions
            ]
        except KeyError:
            gaze_on_surface = []
        draw_gl_points_norm(gaze_on_surface, color=(0., 8., .5, .8), size=80)

        glfwSwapBuffers(self._window)
        glfwMakeContextCurrent(active_window)
コード例 #10
0
ファイル: display_gaze.py プロジェクト: blupixelz/pupil
 def gl_display(self):
     draw_gl_points_norm(self.pupil_display_list,size=35,color=(1.,.2,.4,.6))
コード例 #11
0
 def gl_display(self):
     draw_gl_points_norm(self.pupil_display_list,
                         size=35,
                         color=(1., .2, .4, .6))