Results 1 to 5 of 5

Thread: using a DirectShow enabled webcam to take still images in QT

  1. #1
    Join Date
    Aug 2008
    Posts
    7
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation using a DirectShow enabled webcam to take still images in QT

    Hey all,

    Okay, so I have a problem. I am trying to write an application that will allow the user to take a picture (using, currently, a logitech webcam) of an individual. Now, I've taken this project over from another person who is no longer with the company and there are wsome things that seem strange to me. First off, the current version allows the user to load an image from the hard drive, a functionality that we want to keep. However, the image is being loaded as a pixmap into a QLabel object (strange?). So question 1, is that ideal?
    In the new version that we are writing, we want to be able to capture that image from a webcam connected to the computer as well as read one off the HD. The webcam is a Logitech if that matters and according to Logitech, it supports a DirectShow interface for controlling it. Here's the issue: if I want to display the live stream in the window and allow the user to click a 'capture image' button when the subject is correctly in the frame how do I go about showing that in the QT UI? In reading through the forums and things, I've learned that this might be an application for Phonon; correct? But I don't see an Phonon Widgets in the QT Designer. Is that a seperate thing I'll need to buy?
    Thanks for the help with my previous questions. You've all been a great help in the past.

    Jason

  2. #2
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: using a DirectShow enabled webcam to take still images in QT

    Phonon will not yet do what you require. It is only useful for simple media playback at the moment.

    QLabel is the widget for showing images on-screen. It takes a QPixmap. However, QImage is what you will use when you're grabbing the DirectShow image bits the webcam streams out.

    You will need first to figure out how to get the streaming image data from the webcam, this part is not related to Qt. Then once you have access to the raw frame bits, you copy those frame bits to a QImage, and from there you can do whatever you want, convert it to a QPixmap and set that to a QLabel for on-screen display, or save the image onto the hard drive....etc.

  3. #3
    Join Date
    Aug 2008
    Posts
    7
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: using a DirectShow enabled webcam to take still images in QT

    Okay, so if I were to incorporate, say, the AMCap code to get the stream, do you know of any places were I could see an example of how to grab a single frame? I should point out that I'm a junior software engineer and have no experience working with hardware and the DX stuff I know is very old. Thanks again.

    Jason

  4. #4
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: using a DirectShow enabled webcam to take still images in QT

    Unfortunately this is out of my area of expertise. I recommend you go to a forum specializing in DirectShow and ask them how you can get access to the frame bits from AmCap, in the form of an uchar *. They will tell you something about locking the object, grabbing the bits, then unlocking the object. Once you can do that, all that's left on the Qt side is to copy those bits to a QImage - you can instantiate a QImage from uchar *. Sorry I can't be of more help.

  5. The following user says thank you to JimDaniel for this useful post:

    Jason Hamilton (8th October 2008)

  6. #5
    Join Date
    Aug 2008
    Posts
    7
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: using a DirectShow enabled webcam to take still images in QT

    No, hey, a pointer in the right direction is plenty of help. THanks

Tags for this Thread

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.