Results 1 to 9 of 9

Thread: Help with using OpenGL to display frames from webcam (OpenCV)

  1. #1
    Join Date
    Feb 2007
    Posts
    13
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default 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!!!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Help with using OpenGL to display frames from webcam (OpenCV)

    Quote Originally Posted by toratora View Post
    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()

  3. #3
    Join Date
    Feb 2007
    Posts
    13
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Help with using OpenGL to display frames from webcam (OpenCV)

    Quote Originally Posted by toratora View Post
    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.

  5. #5
    Join Date
    Jan 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Question 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.

  6. #6
    Join Date
    Jan 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation 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.
    Attached Files Attached Files

  7. #7
    Join Date
    Feb 2011
    Location
    bkk thailand, land of smile
    Posts
    1
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

  8. #8
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Help with using OpenGL to display frames from webcam (OpenCV)

    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).

  9. The following user says thank you to stampede for this useful post:

    WhltePanda (27th February 2011)

  10. #9
    Join Date
    Jan 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Help with using OpenGL to display frames from webcam (OpenCV)

    I found a very good tutorial on this page: http://www.aishack.in/2010/03/captur...-with-directx/

Similar Threads

  1. Dynamic Data Display with OpenGL
    By showhand in forum Qt Programming
    Replies: 3
    Last Post: 14th March 2006, 02:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.