11

I'm using Qt 4.5 (2009.03) on Linux Gnome (Ubuntu 9.04) and would like to display video captured by my webcam in a Phonon::VideoWidget of my Qt application.

I have a first implementation using the v4l2 API where I do the YUV2 to RGB conversion and fill a QImage my self. It works well but it is not very efficient. A collegue used gStreamer to do the same thing and it was much much faster.

Since then I found out about phonon and would like to use it. Everything is configured and set up except for the binding to the webcam device as source.

I should create a MediaSource object but I don't know how to configure it. Any help would be greatly valuable.

Edit: The Phonon overview explains that it is not supported yet. But I need a solution.

feedc0de
  • 3,646
  • 8
  • 30
  • 55
chmike
  • 20,922
  • 21
  • 83
  • 106
  • I wish I could do the same but with a cross platform application working on Windows, Linux and MacOS X – Natim Oct 15 '09 at 05:44
  • 1
    I now have a working version but it uses only video for linux (v4l). opencv is straightforward to plug into Qt but the image resolution is fixed to a low value and it is very low on windows. Changing the resolution parameters has no effect. With my linux version I don't have this limitation. I convert from yuv, tilt the image by 90° and copy right away into the QImage buffer. With 800x600@5fps cpu usage is very low. – chmike Mar 30 '10 at 12:29
  • Do you have some piece of code to show me ? I need to do the same thing for a project. – Natim Jun 08 '10 at 22:23
  • +2. Great question! I'm seeking a way to make Qt to display video sequences capture by webcams too. Would you release it under public license? Thanks! – Viet Jun 25 '10 at 04:45

3 Answers3

5

I know its little bit late for this question. but I was looking for the same thing and could not find pure qt solution. Here is my solution https://sourceforge.net/p/qtv4lcapture/code/HEAD/tree/

ozkanpakdil
  • 3,199
  • 31
  • 48
4

If your goal is to display the YUV image on the screen you can use the OpenGL module. Implement the conversion as a fragment shader. If you want to do something else like save the converted image to a file then it is not a good idea.

Some links:

mavroprovato
  • 8,023
  • 5
  • 37
  • 52
stribika
  • 3,146
  • 2
  • 23
  • 21
2

Maybe you can take a look the way kapture was implemented.

ozona
  • 446
  • 4
  • 12
  • I checked but it fails to initialize the webcam. The code I wrote using v4l2 directly works correctly. I saw he converts images by hand too, which is not good. – chmike Sep 04 '09 at 13:24