PDA

View Full Version : Help with using OpenGL to display frames from webcam (OpenCV)



toratora
22nd February 2007, 14:41
Hi!

I´m new to the forum a relatively new to Qt.

I´m trying to develop a programme able to display (first) and send/receive/display (in later stages) the video from a webcam.

I´m using OpenCV libraries for getting the picture, which is able to display the video with its own GUI. However, I need to use something based on Qt since this code will have to be part of some mayor Qt proyect.

It seems that OpenGL is the fastest way to display IplImages (the format OpenCV uses), better than using a conversion to QImage and using Qt itself. However, there comes my first question. I might be using jpeg to save BW when sending the pics, so, given OpenCV can store the IplImage as a jpeg image, I could also try to display jpeg images. I know that it´s possible to convert from jpeg to glformat using convertToGLFormat. But I don´t know if this whole process takes so much time as to get up to 25 frames per second.

On the other hand, I don´t know how exactly write the OpenGL code. I know I should use a paintGL method to say what show be done when painting, I´m trying to use glDrawPixels, but I don´t know how to make it paint every some miliseconds. I think it show be done with updateGL and a QTimer, but I´m not sure. How does exactly updateGL() works?


Thanks!!!

wysota
23rd February 2007, 01:14
I know that it´s possible to convert from jpeg to glformat using convertToGLFormat. But I don´t know if this whole process takes so much time as to get up to 25 frames per second.

Yes, it will.


I know I should use a paintGL method to say what show be done when painting,
Display a big rectangle (or square) using an ortho view and display the image as the texture for that rectangle.


but I don´t know how to make it paint every some miliseconds.
QTimer is your friend here. If you want 25fps, you'll need to set the timer to 40ms. Buffering frames (jpegs or textures) in advance might also be a good idea, all depends how fast can you receive and process the data.


How does exactly updateGL() works?

Tough question. The answer is so simple I don't even know what to write... Basically it... calls paintGL() :)

toratora
23rd February 2007, 09:09
Thanks for the reply

You mean it takes so much time converting I cannot use jpeg conversion for 25fps frame rates? If so, what kind of coding could I use to send compressed pics over a network?


The rest is quite clear, thank you :D

wysota
23rd February 2007, 14:30
You mean it takes so much time converting I cannot use jpeg conversion for 25fps frame rates?

I didn't say that. If you already receive the data in jpeg format, then there is no problem. But if you receive it in some other format, it'll take some time to do the conversion and it might take quite long on slower computers.

BennM
17th February 2011, 23:48
@toratora: What's about your program - is it working? I want to make the same (displaying an image of a webcam in a Qt Gui / record the images). Can you upload a snippet of your program?

With my own attempt of doing it I can display a webcam-image in a picture box and display an texture on rectacle in OpenGL, so I think there are only a few lines missing to connecet this two test programs.

BennM
18th February 2011, 19:07
I wrote a program today - it's based on the texture-example of the Qt-example folder.

This program displays the image of a webcam as an openGL texture - it's very simple. Can anybody please have a look at this program, because it is not as fast as I hoped. I am grateful for any improvements.

Thank you very much.

WhltePanda
27th February 2011, 12:45
Hi :)

I'm going to start working about implementation webcam software with qt,

as I searched on internet it seems OpenCv can use to capture image from web cam.

But if I dont use OpenCv ... do I have other way to capture image from web cam ? Can anyone please suggest me :)

Thanks

stampede
27th February 2011, 13:10
But if I dont use OpenCv ... do I have other way to capture image from web cam ?
I see that you are using Windows, so you can use DirectShow. You can find list of direct show examples here (http://msdn.microsoft.com/en-us/library/dd375468(v=vs.85).aspx) (you'll need to download Microsoft SDK).

BennM
18th March 2011, 11:27
I found a very good tutorial on this page: http://www.aishack.in/2010/03/capturing-images-with-directx/