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

    Quote Originally Posted by kosirm View Post
    Thanks for code!
    I'm running example and capture frame size isn't changing, it seems to me that cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640); does nothing. Or have I missed something?

    if(size == Size640) {
    cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);
    cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);
    qDebug() << "Setting 640x480:CV_CAP_PROP_FRAME_WIDTH:" << cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
    qDebug() << "Setting 640x480CV_CAP_PROP_FRAME_HEIGHT:" << cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);

    }

    returns:
    Setting 640x480:CV_CAP_PROP_FRAME_WIDTH: 320
    Setting 640x480CV_CAP_PROP_FRAME_HEIGHT: 240

    Any ideas how could I change frame width/height?
    Best regards,
    Milan
    No. This is what I was talking about when I said the highgui functions suck

    On some cameras those functions will work, but on most they won't. If you want to control camera properties like capture size and others you'll have to use another image acquisition library or try cvcam as someone else suggested. I never had much luck with it. It'll do basic capture, but that's it.

  2. #2
    Join Date
    Jul 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: OpenCV integration

    thanks...

    best regards, Milan
    Last edited by kosirm; 11th July 2009 at 14:42.

  3. #3
    Join Date
    Jul 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    2
    Thanked 2 Times in 1 Post

    Default Re: OpenCV integration

    Sorry to re-awaken an old topic but i am having some difficulties converting an opencv Monochrome image into a Qimage. The image is a result of calling the opencv function
    void cvInRangeS( const CvArr* src, CvScalar lower, CvScalar upper, CvArr* dst );

    When i pass this image to the function IplImageToQImage it does convert the image into qimage however the image is 8 times smaller and duplicated. The results can be seen below

    Opencv Image


    Convertion to Qimage results



    Does anybody know why this has happened? And any ideas how to correct the error?

  4. The following 2 users say thank you to switch for this useful post:

    droetker (18th May 2012)

  5. #4
    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).

  6. #5
    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!

  7. #6

    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.