Help with using OpenGL to display frames from webcam (OpenCV)
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!!!
Re: Help with using OpenGL to display frames from webcam (OpenCV)
Quote:
Originally Posted by
toratora
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.
Quote:
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.
Quote:
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.
Quote:
How does exactly updateGL() works?
Tough question. The answer is so simple I don't even know what to write... Basically it... calls paintGL() :)
Re: Help with using OpenGL to display frames from webcam (OpenCV)
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
Re: Help with using OpenGL to display frames from webcam (OpenCV)
Quote:
Originally Posted by
toratora
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.
Re: Help with using OpenGL to display frames from webcam (OpenCV)
@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.
1 Attachment(s)
Re: Help with using OpenGL to display frames from webcam (OpenCV)
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.
Re: Help with using OpenGL to display frames from webcam (OpenCV)
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
Re: Help with using OpenGL to display frames from webcam (OpenCV)
Quote:
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 (you'll need to download Microsoft SDK).
Re: Help with using OpenGL to display frames from webcam (OpenCV)