On Wednesday, December 11, 2013 at 03:18:33 PM, Fikret Alim wrote:
> Hello,
>
>
>
> I am trying to use OpenCV and OpenGL together for some image processing
> tasks. I have already run OpenCV examples on IMX6, I can also compile and
> run the examples under gpu sdk of Freescale with X11, but when I try to use
> them together I have some problems.
>
>
>
> Actually, what I am trying to make has already been done by Freescale
>
> http://imxcv.blogspot.com/2012/03/gesture-recognition-on-imx6.html
>
> http://cache.freescale.com/files/32bit/doc/app_note/AN4629.pdf
>
>
>
> I have tried many times by using these examples in order to create a simple
> working binary, but unfortunately I could not achieve that. I have attached
> one of my trials (the source code, Makefile and the binary). I have
> modified the 06_Texturing example given under GLES2_0 folder of gpu sdk. I
> have compiled it without any problem, but when I load the binary to IMX6
> board and run the example, I see a black cube rotating.
Your texturing is broken, right ?
> I am waiting for
> the video instead of black screen. I have attached the output of the
> screen, also. If I add an imshow function after I get the image from the
> camera, I can see it without any problem. But when it is used by OpenGL, I
> can only see black screen as I said.
The examples are broken, they don't check GL errors etc. Find attached patch,
it
should give you an idea how to fix your glplane.cpp in the examples.
glEGLImageTargetTexture2DOES() usually returns GL error because the fragment
shader is completely bonkers.
Best regards,
Marek Vasut
--- a/src/glplane.cpp 2013-12-07 13:57:26.410103736 +0100
+++ b/src/glplane.cpp 2013-12-18 18:46:33.193693194 +0100
@@ -8,20 +8,12 @@
"{ \n"
" gl_FragColor = texture2D(sampler2d,myTexCoord); \n"
"} \n";*/
- "#ifdef GL_FRAGMENT_PRECISION_HIGH \n"
- " precision highp float; \n"
- "#else \n"
- " precision mediump float; \n"
- "#endif \n"
- " \n"
"uniform sampler2D s_texture; \n"
- "varying vec3 g_vVSColor; \n"
- "varying vec2 g_vVSTexCoord; \n"
+ "varying mediump vec2 g_vVSTexCoord; \n"
" \n"
"void main() \n"
"{ \n"
- " gl_FragColor = texture2D(s_texture,g_vVSTexCoord.xy); \n"
-
+ " gl_FragColor = texture2D(s_texture,g_vVSTexCoord); \n"
"} \n";
@@ -44,17 +36,13 @@
"uniform mat4 g_matProj; \n"
" \n"
"attribute vec4 g_vPosition; \n"
- "attribute vec3 g_vColor; \n"
"attribute vec2 g_vTexCoord; \n"
" \n"
- "varying vec3 g_vVSColor; \n"
"varying vec2 g_vVSTexCoord; \n"
" \n"
"void main() \n"
"{ \n"
- " vec4 vPositionES = g_matModelView * g_vPosition; \n"
- " gl_Position = g_matProj * vPositionES; \n"
- " g_vVSColor = g_vColor; \n"
+ " gl_Position = g_matProj * g_matModelView * g_vPosition;\n"
" g_vVSTexCoord = g_vTexCoord; \n"
"} \n";
@@ -392,10 +380,10 @@
//--------------------------------------------------------------------------------------
void GLPlane::PlaneSetTexBuf (uint8_t *texture_data, int w, int h)
{
+ glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, _texture);
- //glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, texture_data);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, texture_data);
-
+ glUniform1i(_s_texture_location, 0);
}
//--------------------------------------------------------------------------------------
@@ -470,24 +458,12 @@
// Pass the texture coordinates data
glVertexAttribPointer (PLANE_TEXCOORD_ARRAY, 2, GL_FLOAT, 0, 0, texcoords);
glEnableVertexAttribArray (PLANE_TEXCOORD_ARRAY);
-
- // enable depth test
- glEnable (GL_DEPTH_TEST);
- glDepthFunc (GL_LEQUAL);
- glDepthMask (GL_TRUE);
-
- // cull backside of polygons
- //glEnable(GL_CULL_FACE);
- //glCullFace (GL_BACK);
- glDisable(GL_CULL_FACE);
-
- // Binds this texture handle so we can load the data into it
- //glBindTexture(GL_TEXTURE_2D, _texture);
- /* Select Our Texture */
- glActiveTexture(GL_TEXTURE0);
- //Select eglImage
- glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, g_imgHandle);
-
+
+
+
+
+
+
glDrawArrays (GL_TRIANGLES, 0, 6);
@@ -632,6 +608,7 @@
//--------------------------------------------------------------------------------------
GLuint GLPlane::GenTextures (void)
{
+#if 0
GLuint texture_id = 0;
// Use tightly packed data
@@ -639,8 +616,38 @@
// Allocates one texture handle
glGenTextures (1, &texture_id);
+#endif
+
+ // Texture object handle
+ GLuint textureId;
+
+ // 2x2 Image, 3 bytes per pixel (R, G, B)
+ GLubyte pixels[4 * 3] =
+ {
+ 255, 0, 0, // Red
+ 0, 255, 0, // Green
+ 0, 0, 255, // Blue
+ 255, 255, 0 // Yellow
+ };
+
+ // Use tightly packed data
+ glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 );
+
+ // Generate a texture object
+ glGenTextures ( 1, &textureId );
+
+ // Bind the texture object
+ glBindTexture ( GL_TEXTURE_2D, textureId );
+
+ // Load the texture
+ glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels );
+
+ // Set the filtering mode
+ glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+ glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+
- return texture_id;
+ return textureId;
}
//--------------------------------------------------------------------------------------
@@ -654,10 +661,10 @@
_texture_h = texture_h;
_texture = GenTextures ();
-
+#if 0
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
+#endif
return;
}
@@ -765,7 +772,7 @@
// Get uniform locations
_modelview_location = glGetUniformLocation (_shader_program, "g_matModelView");
_projview_location = glGetUniformLocation (_shader_program, "g_matProj");
-
+ _s_texture_location = glGetUniformLocation (_shader_program, "s_texture");
return true;
}
_______________________________________________
meta-freescale mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-freescale