convert bitmap stream to a texture???

Hello everybody!

I get a stream of bitmaps from a logitech camera. Now I have the problem to map this bitmaps to a texture.
The function gluBuild2DMipmaps is not fast enough.

After that, I tried to create a white dummy texture with this command and to
copy only the bitmap data into the dummy texture with the following two commands:

glDrawPixels(m_TexBitmap.GetWidth(), m_TexBitmap.GetHeight(),GL_BGR_EXT, GL_UNSIGNED_BYTE, m_TexBitmap.GetLine(0));
glCopyTexSubImage2D(GL_TEXTURE_2D, 0,0 , 0, 0,0,m_TexBitmap.GetWidth(), m_TexBitmap.GetHeight());

This works very fine (and fast) for 320x240 or 160x120 bitmaps. For the next higher resolution (640x480) I get a black border at the right side
(starting at 600 Pixel) on the Texture.

Please help me.

Thank you

Are you simply trying to display the output on the screen (glDrawPixels) or are you actually trying to do something with the texture? (eg. Display the video feed on a rotating cube etc)

Have you tried using glTexSubImage2D?

let me see if i undertood, you copied the contents of the bitmap to the screen and then to the texture? if that’s what you’re doing then it’s wrong!

here is what i suggest:
-your textures must have dimensions of 2^n
-your texture must be first created with glTexImage2D(you can initialize it with a black bitmap if you want)
-every time you want to pass a new frame to the texture you must call glTexSubIimage2D

remember to create textures with correct dimensions, to convert a bitmap with 640x480(for example) of dimensions, i suggest you to use the windows DIB functions to do this dirty work. anyway i believe that there are better tricks for doing that, but this one is the best i know.

one last thing, you should never use gluBuild2DMipmaps when you have intentions of making changes to the texture because it’s just to slow, you should always use glTexImage2D and glTexSubImage2D for textures that will be submited do changes.

[This message has been edited by jcabeleira (edited 07-23-2003).]

to bild fast mipmaps use (if present):

It’s pretty annoying when it comes to using mipmapping for this sort of thing. I made an app once with something like a big TV screen in a virtual world. Since the eyepoint was always moving relative to the TV screen, I really wanted to use mipmapping but it just ran too slow with every frame of my animation needing to be mipped. Maybe you’ll have better luck if you keep your frames small enough.

Just out of curiosity, how are you getting the frames from your camera into your system? I just posted a related question in the hardware section, trying to see if I could send a video stream through the video input on my graphics card and straight into texture memory. This would be ideal because you wouldn’t use the AGP bus at all.

i’m not sure if SGIS_generate_mipmap extension is avaiable on most graphics cards, so i have my doubts about the use of that extension.

As far as i know that extension is widely available.
You just have to make one decision: Do you need mipmaps or not?

If you really need them, then there is no better way than using that extension.
If you don´t need mipmapping, then why bother about it, at all.


Originally posted by mogumbo:
Maybe you’ll have better luck if you keep your frames small enough.

there’s no need for that. some time ago i’ve made a virtual monitor(made of about 1000 polys) in opengl that displayed an AVI movie(640x480)in a texture without mipmapping using the suggestions that i posted above.
i think the concept between my program and andymeyer’s is the same, the only difference is the source from where the are frames coming. my program runs pretty well even in slow machines but it still is slower that a regular program because of the DIB operation’s and the texture runtime modifications wich are pretty heavy.

if you decide to really use mipmapping in your program that you can count with a big performance decrease.

[This message has been edited by jcabeleira (edited 07-23-2003).]

[This message has been edited by jcabeleira (edited 07-23-2003).]

Hey jcabeleira, what framerate were you able to upload those frames at? And what sort of bus were you going across? AGP4x?

in my geforce3 the program ran really smooth, more than 30 fps.

in the slow computers, with nasty graphics cards ran in about 10fps, while in other computers with not-so-good geforces ran with 15-20 fps

Well, I’m still stumped on where to start with this project. I have a RS170 signal, which, as I understand it, is like a black & white NTSC signal. I need to convert this signal to 640x480 frames at 30Hz and upload them to my graphics card. This will all be done on Linux.

Can anyone recommend a video capture card that will work for this? The best software option I’ve found so far is video4linux. Is that the right thing to use, or would something else work better?

If you can do without mipmaps, simply use the GL_TEXTURE_RECTANGLE_EXT extension (same as GL_TEXTURE_RECTANGLE_NV) to allow non-power-of-two texture dimensions. You will be forced to GL_NEAREST or GL_LINEAR for the min and max functions, but it should be sufficient.

Tex2DSubImage is supposed to work with the GL_TEXTURE_RECTANGLE_EXT target but I could not get it to work correctly but it was fast enough without it.

If you can get the video images into a YCrCb format buffer or some other 1:1 format, you can use the imaging subset color matrix to do color space conversion in hardware. Alternatively you can use a pixel shader to do whatever color space conversion code you require.

I’m currently processing two 720x480 YCrCb framebuffers, preprocessing the data, dumping the data into output buffers and then using multitexturing and ‘invalid’ texture coordinates with a constant border color to display a main YCrCb plane and overlay YCrCb plane where each framebuffer can be arbitrarily sized and offset. I easily get 60 frames per second when both buffers are 720x480x32 and the output resolution is 800x600.


At first , sorry that the answer come so late.

The suggestion from “jcabeleira” was very good.

These Solution is not so fast like my Version, but it have no black border in the Picture.

Thank you for all