I am working on augmented reality project. So the user should use the Webcam, and to see the captured video with a cube drawn on that frame. And this is where I get stuck , when I try to use glBindTexture(GL_TEXTURE_2D,texture_background) method, I get error: ( ArgumentError: argument 2: : wrong type GLUT Display callback with (),{} failed: returning None argument 2: : wrong type ) I am completely stuck, have no idea what to do . The project is done in Python 2.7 , am using opencv and PyOpenGl 3.1.0.
You can find code on this link :click here Thanks in advance.
Interesting error! So I played around with your source code (by the way in the future you should probably just add the code directly to your question instead of as a separate link), and the issue is actually just one of variable scope, not glut or opengl usage. The problem is your texture_background
variable does not exist within the scope of the _draw_scene()
function. To verify this, simply try calling print texture_background
in your _draw_scene()
function and you will find it returns None
rather than the desired integer texture identifier.
The simple hack-y solution is to just call global texture_background
before using it within your _handle_input()
function. You will also need to define texture_background = None
in the main scope of your program (underneath your ##FOR CUBE FROM OPENGL
comment). The same global comment applies for x_axis
and z_axis
.
That being said, that solution is not really that great. The rigid structure required by GLUT with all of these predefined glut*
functions makes it hard to structure code the way you might want to in terms of initializing your app. I would suggest, if you are not forced to use GLUT, to use a more flexible alternative, such as pygame, pysdl2 or pyqt, to create your context instead.