Hi!!
First of all, sorry if my english is bad, I am not a native .
I've been working with emgu cv(opencv wrapper to capture images from a webcam and using its functions to proccess this images.
I also detect the hand and track the hand movement...
Now, I need to draw a kind of earth or just an object according to the hand position, for which sharpGL is perfect for perspective transformation and so on. My problem is that I can't achieve that.
I don't know how to say to sharpGL "you guy, draw that object within this hand tracking window"
Is it impossible what I want to do? I am desperate... any help would be great. Thanks in advance
see this video if you're still confused about what I meant (
http://www.youtube.com/watch?v=ccL4t36sVvg)
so far, I've just translated this code
http://blog.damiles.com/2008/10/opencv-opengl/ into C#
and here's code snippet
private void openGLControl_OpenGLInitialized(object sender, EventArgs e)
{
uint[] textures = new uint[1];
OpenGL gl = openGLControl1.OpenGL;
gl.GenTextures(1, textures);
gl.BindTexture(OpenGL.GL_TEXTURE_2D, textures[0]);
gl.Enable(OpenGL.GL_TEXTURE_2D);
gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, OpenGL.GL_NEAREST);
gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, OpenGL.GL_NEAREST);
gl.PixelStore(OpenGL.GL_UNPACK_ALIGNMENT, 1);
gl.ClearColor(1.0f, 1.0f, 1.0f, 1.0f);
}
private void openGLControl_Resized(object sender, EventArgs e)
{
OpenGL gl = openGLControl1.OpenGL;
gl.MatrixMode(OpenGL.GL_PROJECTION);
gl.LoadIdentity();
gl.Perspective(60.0f, (double)Width / (double)Height, 0.01, 100.0);
gl.LookAt(-5, 5, -5, 0, 0, 0, 0, 1, 0);
gl.MatrixMode(OpenGL.GL_MODELVIEW);
}
and finally draw an object
private void openGLControl_OpenGLDraw(object sender, PaintEventArgs e)
{
OpenGL gl = openGLControl1.OpenGL;
if (capture == null)
{
this.start_capture();
}
if (capture != null)
{
Image<Bgr, Byte> ImageFrame = capture.QueryFrame();
Bitmap image = new Bitmap(ImageFrame.ToBitmap());
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
gl.LoadIdentity();
BitmapData bitmapData = image.LockBits(new Rectangle(0, 0, image.Width, image.Height),
ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
gl.BindTexture(OpenGL.GL_TEXTURE_2D, textures[0]);
gl.TexImage2D(OpenGL.GL_TEXTURE_2D, 0, (int)OpenGL.GL_RGBA, ImageFrame.Width, ImageFrame.Height, 0, OpenGL.GL_RGBA, OpenGL.GL_UNSIGNED_BYTE, bitmapData.Scan0);
}
}
but the output always return an white, no texture on it...
I've also consindering to use Texture class, but it's no use..because there's no method which the input parameter is the frame...
I appreciate your answer...
regards.