Results 1 to 4 of 4

Thread: OpenCV Image to QImage

  1. #1
    Join Date
    Oct 2009
    Location
    Poland
    Posts
    34
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default OpenCV Image to QImage

    Hello I have a quick question.

    Im trying to do some object tracking with OpenCv library, and at one point I wanted to display a thresholded image, but what I got is black square.
    Here is code:
    Qt Code:
    1. QImage Camera::captureTrasholdedImage()
    2. {
    3. IplImage* frame = cvQueryFrame( this->captureHandle );
    4. IplImage* frameHSV = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 3);
    5. cvCvtColor(frame, frameHSV, CV_BGR2HSV);
    6.  
    7.  
    8. IplImage* trashold = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 1);
    9. cvInRangeS(frame, cvScalar(170, 160, 160), cvScalar(180,256, 256), trashold);
    10.  
    11.  
    12.  
    13. QByteArray buff(trashold->imageData, trashold->imageSize);
    14.  
    15. int height = trashold->height;
    16. int width = trashold->width;
    17.  
    18. QPixmap pix(width, height);
    19. pix.loadFromData(buff);
    20. return pix.toImage();
    21. }
    To copy to clipboard, switch view to plain text mode 

    Can someone give me a hint please ?

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: OpenCV Image to QImage

    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Oct 2009
    Location
    Poland
    Posts
    34
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: OpenCV Image to QImage

    Ok thanks, but what is wrong with QByteArray way ?

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: OpenCV Image to QImage

    probably different format
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. [Qt4] How to load Url image into QImage?
    By Gonzalez in forum Qt Programming
    Replies: 6
    Last Post: 13th October 2014, 11:10
  2. OpenCV conflict with QIMage in Ubuntu
    By merajc in forum Qt Programming
    Replies: 3
    Last Post: 16th February 2014, 19:59
  3. Error OpenCV capture image
    By Mien89 in forum Qt Programming
    Replies: 3
    Last Post: 18th October 2012, 23:21
  4. Loading an Image into QImage
    By jstippey in forum Qt Programming
    Replies: 5
    Last Post: 4th January 2011, 15:36
  5. Loading a raw image into QImage
    By Luc4 in forum Qt Programming
    Replies: 6
    Last Post: 16th May 2010, 16:20

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.