How to use draw_gl_point....()

82 views
Skip to first unread message

Michael Barz

unread,
Jan 6, 2014, 8:05:18 AM1/6/14
to pupil-...@googlegroups.com
Hi, I just tried to draw some points wihtin my plugin window.
Unfortunately it was not possible for me to figure out how the draw_gl_point functions work.

Here is what I tried:

 def gl_display_marker_window(self):
        active_window
= glfwGetCurrentContext()
        glfwMakeContextCurrent
(self.markerWindow)

        clear_gl_screen
()

       
# gl stuff that will show on your plugin window goes here
       
#draw_gl_texture(self.activePattern)

        center
= np.array([0.1, 0.1])
       
#center = [0.5, 0.5]
       
#center = [100, 100]
        draw_gl_point
(center, size=100,color=(1.,0.5,0.5,1.))
        glfwSwapBuffers
(self.markerWindow)
        glfwMakeContextCurrent
(active_window)

Can someone help me with that?
I'm using Version 0.3.5.1... (currently with video files)

Kind regards, Michael

Will Patera

unread,
Jan 6, 2014, 8:44:33 AM1/6/14
to pupil-...@googlegroups.com
Hi Michael, 

Do you think you could create a gist on Github with the full plugin code that you're working on, or post the code here as attachment so we can scan through the code and look for problems that you may be encountering and even run some tests with your code to help out?

In v0.3.5.1 all of the OpenGL utilities are defined here and the draw_gl_points function is defined here.  

You may also want to take a look at some of the plugins (if you haven't already) like, screen marker calibration, or in v0.3.6 maker detector (a bit more complicated stuff going on with marker detector).

Best, 
Will    

Michael Barz

unread,
Jan 6, 2014, 10:11:19 AM1/6/14
to pupil-...@googlegroups.com
Hi, thanks for your fast response!

I could solve my problem with the following function (from screen marker calibration):
def draw_circle(pos,r,c):
   pts = cv2.ellipse2Poly(tuple(pos),(r,r),0,0,360,10)
   draw_gl_polyline(pts,c,'Polygon')

Adapted, it looks as follows:
pts = cv2.ellipse2Poly((0, 0),(10,10),0,0,360,1) / float(self.markerWindowHeight)
draw_gl_polyline
(pts,(0.,0.,0.,1.),'Polygon')
which draws a 10x10 ellipse in the screen center.

It seems that gl uses flipped y axis and takes normalized input.

Still draw_gl_point/s/_norm are not working for me.
If you like I can send you an email with code files attached.

Kind regards,
Michael

Will Patera

unread,
Jan 6, 2014, 10:21:41 AM1/6/14
to pupil-...@googlegroups.com

Hi Michael,

Good to see that you got it running.  Coordinates between opengl and opencv and row/column order with numpy can be very confusing. 

We did some work on v0.3.6 to simplify coordinate systems. 

It'd be great to see the full code if you have time to attach it or post it. 

will patera
(mobile)

--
You received this message because you are subscribed to the Google Groups "pupil-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pupil-discus...@googlegroups.com.
To post to this group, send email to pupil-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pupil-discuss/e5e9ad30-e463-44c3-906c-4b5ea62202aa%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Will Patera

unread,
Jan 8, 2014, 11:09:44 AM1/8/14
to pupil-...@googlegroups.com
Hi Michael, 

I believe that I have resolved your issue with the code that you sent me (outside the group).  Now we're drawing points and your markers.  See this gist for files changed.  I only made minor changes to 2 functions in your plugin display_detector.py.
I am using v0.3.6 (just did a quick git clone http://www.github.com/pupil/pupil-labs).  There were changes from v0.3.5 to v0.3.6 regarding coordinates.

Also, I really encourage you to fork the Pupil repository on Github.  This would make debugging easier for others in the future as there were also a few changes that were needed to be made to world.py to add the plugin here and here in order to run your plugin. Plus other members in the community could learn from your work on the plugin.  There's lots of cool stuff in your code -- please share it  :-)

Let me know if this helps you or if you have further questions as you develop.  Looking forward to your next steps!

Best, 
_w  

Will Patera

unread,
Jan 8, 2014, 11:13:18 AM1/8/14
to pupil-...@googlegroups.com
Slight typo in the last response to the url in the git clone command it should read git clone http://github.com/pupil-labs/pupil

Michael Barz

unread,
Jan 12, 2014, 10:01:40 AM1/12/14
to pupil-...@googlegroups.com
Hi,

thank you very much! Your advices were really helpful... working now.
It's nice to hear, that you like my plugin :)
I think I will share my code when I finished my master thesis...

Kind regards,
Michael

Will Patera

unread,
Jan 12, 2014, 10:20:08 AM1/12/14
to pupil-...@googlegroups.com
Hi Michael, 

Excellent!  It would be great to follow your work even while you're developing it -- please let me/us know if you do decide to put the code online.  I think it would be a good resource to the Pupil community and also a way to get some feedback on incremental work.

Best, 
_w
Reply all
Reply to author
Forward
0 new messages