Results 1 to 20 of 29

Thread: Webcam Video Capture

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2011
    Location
    Indonesia, Surabaya
    Posts
    24
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Webcam Video Capture

    Hello everybody..

    I'm new in Qt, and new in OpenCV..

    I want to make a program to capture a video from USB webcam, then save it to the server..

    For now, i have download a source code that use Qt and OpenCV to view images from webcam.. i download it here, http://qt-apps.org/content/show.php/...?content=89995

    do you have any suggestion, how should i modifiy this source code, so that it can record the video, and save it ?

    i really appreciate your help.. thanks before

    P.S : sorry for my bad english

  2. #2
    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: Webcam Video Capture

    do you have any suggestion
    Yes, read OpenCV documentation, for example:
    CvVideoWriter
    CvWriteFrame
    Post again if you have specific problems with your code.

  3. The following 2 users say thank you to stampede for this useful post:

    bajoelkid12 (5th May 2011), thaihoangluu (28th December 2011)

  4. #3
    Join Date
    May 2011
    Location
    Indonesia, Surabaya
    Posts
    24
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Webcam Video Capture

    thank you for your respond stampede.. i'm now working on how to integrate OpenCV video writing and reading function in Qt framework.. . maybe you have some advice ?

  5. #4
    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: Webcam Video Capture

    You mean you are having some problems with using OpenCv in your code, or just thinking how to do that nicely ? If its the latter, then I'd create a wrapper class(es) with nice interface, which will hide all the OpenCV stuff from client classes. What I mean is something like:
    Qt Code:
    1. class VideoReader : public QObject{
    2. Q_OBJECT
    3. public:
    4. VideoReader( const QString& file, QObject * parent = NULL );
    5. ... /// information
    6. int frameCount() const;
    7. QSize frameSize() const;
    8. ... // other methods, like video fps etc
    9. /// capture methods
    10. QImage getFrame( int frameNumber ) const; // or return QPixmap, or your own Image class
    11. ...
    12. };
    To copy to clipboard, switch view to plain text mode 
    It's always better to have class with good interface, than C-style OpenCv api calls all over the code. I think you get the idea.

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

    bajoelkid12 (10th May 2011)

  7. #5
    Join Date
    May 2011
    Location
    Indonesia, Surabaya
    Posts
    24
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Webcam Video Capture

    actually yes.. i have some problems with using OpenCV in my code.. this is what i've done so far..

    mycamerawindow.cpp
    Qt Code:
    1. #include "MyCameraWindow.h"
    2.  
    3. MyCameraWindow::MyCameraWindow(CvCapture *cam, QWidget *parent) : QWidget(parent) {
    4. camera = cam;
    5. QVBoxLayout *layout = new QVBoxLayout;
    6. cvwidget = new QOpenCVWidget(this);
    7. layout->addWidget(cvwidget);
    8. setLayout(layout);
    9. resize(500, 400);
    10.  
    11. startTimer(100); // 0.1-second timer
    12. }
    13.  
    14. void MyCameraWindow::timerEvent(QTimerEvent*) {
    15. IplImage *image=cvQueryFrame(camera);
    16. cvwidget->putImage(image);
    17. }
    To copy to clipboard, switch view to plain text mode 

    i get this code from http://qt-apps.org/content/show.php/...?content=89995

    btw thank you for the algorithm, now i'll try to implement it to my code.. but if you don't mind, may i send my project file to you ?
    Last edited by bajoelkid12; 10th May 2011 at 06:17.

  8. #6
    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: Webcam Video Capture

    actually yes.. i have some problems with using OpenCV in my code..
    What kind of problems ? Image is not displayed ? Displayed but incorrect ? Other ?
    but if you don't mind, may i send my project file to you ?
    What for ? I think you can get all the help you need by asking specific questions on this forum.

  9. #7
    Join Date
    Jun 2010
    Posts
    102
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Webcam Video Capture

    Quote Originally Posted by bajoelkid12 View Post
    actually yes.. i have some problems with using OpenCV in my code.. this is what i've done so far..

    mycamerawindow.cpp
    Qt Code:
    1. #include "MyCameraWindow.h"
    2.  
    3. MyCameraWindow::MyCameraWindow(CvCapture *cam, QWidget *parent) : QWidget(parent) {
    4. camera = cam;
    5. QVBoxLayout *layout = new QVBoxLayout;
    6. cvwidget = new QOpenCVWidget(this);
    7. layout->addWidget(cvwidget);
    8. setLayout(layout);
    9. resize(500, 400);
    10.  
    11. startTimer(100); // 0.1-second timer
    12. }
    13.  
    14. void MyCameraWindow::timerEvent(QTimerEvent*) {
    15. IplImage *image=cvQueryFrame(camera);
    16. cvwidget->putImage(image);
    17. }
    To copy to clipboard, switch view to plain text mode 

    i get this code from http://qt-apps.org/content/show.php/...?content=89995

    btw thank you for the algorithm, now i'll try to implement it to my code.. but if you don't mind, may i send my project file to you ?
    if you use your code, you cant record with audio, how to record video with audio use OpenCV ???
    Contact: Skype: sonnh89
    Yahoo: nhs_0702@yahoo.com

    Liên hệ SKype: sonnh89

Similar Threads

  1. How to get video streaming from USB webcam
    By sanket.mehta in forum Qt Programming
    Replies: 4
    Last Post: 15th July 2011, 06:45
  2. capture iamge form webcam
    By bibhukalyana in forum Newbie
    Replies: 8
    Last Post: 29th April 2011, 09:43
  3. capture video from DV camera
    By ekkondela in forum Newbie
    Replies: 1
    Last Post: 7th March 2010, 09:38
  4. Replies: 3
    Last Post: 5th July 2009, 17:22
  5. synchronise QLabel display and webcam capture
    By fbmfbm in forum Qt Programming
    Replies: 2
    Last Post: 24th February 2009, 11:10

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.