Results 1 to 20 of 48

Thread: OpenCV integration

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2006
    Posts
    250
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    19
    Thanked 49 Times in 36 Posts

    Default Re: OpenCV integration

    Not sure why you're getting that. Have you tried looking at the dst image before you convert it to a QImage (using the highgui showimg function)? Make sure the dst image is the correct bit depth (8u or 8s).

  2. #2
    Join Date
    Nov 2009
    Posts
    1
    Thanks
    1

    Red face Re: OpenCV integration

    Hello pherthyl,


    Thanks for the framework, it's very good, but I found a problem running in my hardware. I tested the framework in a Hp notebook, with the webcam and with a external camera and worked fine. When a tried the framework in another notebook (a LG note) with the integrate webcam, a get an deadlock every time I stop and try a play again.

    The console output: (this problem in this notebook occurs every time, it's not a random problem...)


    Listing capture properties...
    CV_CAP_PROP_FRAME_WIDTH
    CV_CAP_PROP_FRAME_HEIGHT
    CV_CAP_PROP__FPS 0
    CV_CAP_PROP_FOURCC 0
    CV_CAP_PROP_BRIGHTNESS 0
    CV_CAP_PROP_CONTRAST 0
    CV_CAP_PROP_SATURATION 0
    CV_CAP_PROP_HUE 0
    Done
    Setting 640x480 1
    Attempting to set frame rate...
    Error: 0
    Starting to track
    About to start the capture thread
    Started the capture thread
    Stop capture requested.
    Waiting on capture start...
    Listing capture properties...
    CV_CAP_PROP_FRAME_WIDTH
    CV_CAP_PROP_FRAME_HEIGHT
    CV_CAP_PROP__FPS 0
    CV_CAP_PROP_FOURCC 0
    CV_CAP_PROP_BRIGHTNESS 0
    CV_CAP_PROP_CONTRAST 0
    CV_CAP_PROP_SATURATION 0
    CV_CAP_PROP_HUE 0
    Done
    Setting 640x480 1
    Attempting to set frame rate...
    Error: 0
    Starting to track
    About to start the capture thread
    Started the capture thread
    QMutex::lock Deadlock detected in thread 3916



    Well, another test that I did, it's to start a HeadTracker object when a button is pressed in the main window. Well, it works fine until I request a re-size. After a re-size the program crashes and close.


    It's just a report, but any help it's very welcome, I will have a better lock in the code to see if I can improve anything, because I think is a very good framework and really fast as well

    cheers!

  3. #3

    Default Re: OpenCV integration

    I know this thread is quite old, but still it is a very good wrapper to get images from webcam or whatnot.

    If for some reason you dont need some fancy 32 bit format you could change the updatePixmap function to only use one memcpy like this:

    Qt Code:
    1. t.start();
    2. //qDebug() << "Copying data";
    3. bool start = false;
    4. // check if the frame dimensions have changed
    5. if(frame->width != imageWidth || frame->height != imageHeight) {
    6. if(imageData) {
    7. delete[] imageData;
    8. }
    9. start = true;
    10. imageWidth = frame->width;
    11. imageHeight = frame->height;
    12. emit(frameSizeChanged(imageWidth, imageHeight));
    13. imageData = new unsigned char[3*imageWidth*imageHeight];
    14. }
    15.  
    16. int pixels = imageWidth * imageHeight;
    17. uchar* src = (uchar*)(frame->imageData);
    18.  
    19. memcpy(imageData, src, pixels*3);
    20. if(!start) {
    21. ++frames;
    22. time += t.elapsed();
    23. }
    To copy to clipboard, switch view to plain text mode 

    Then you have to change the paintEvent method to create the tImg with RGB888 format like this:
    Qt Code:
    1. QImage tImg(imageData, imageWidth, imageHeight, QImage::Format_RGB888);
    To copy to clipboard, switch view to plain text mode 

    You might run into problem of RGB <--> BGR conversion, just modify the painter.drawImage call to
    Qt Code:
    1. painter.drawImage(QPoint(0,0), tImg.rgbSwapped());
    To copy to clipboard, switch view to plain text mode 
    Last edited by mounte; 15th December 2009 at 11:40.

Similar Threads

  1. Replies: 8
    Last Post: 18th March 2011, 12:27
  2. Replies: 7
    Last Post: 22nd December 2010, 09:13
  3. Qt4 integration with VS2008 Express how-to interest?
    By thomaspu in forum Qt Programming
    Replies: 11
    Last Post: 21st May 2008, 13:53
  4. How to open two cameras with opencv?
    By alphaboy in forum General Programming
    Replies: 2
    Last Post: 21st December 2007, 11:58
  5. VS Integration plugins not visible
    By kemp in forum Qt Tools
    Replies: 1
    Last Post: 11th August 2006, 23:22

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
  •  
Qt is a trademark of The Qt Company.