Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QImage->copy(x,y,width,height)

QImage->copy(x,y,width,height)

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 974 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fbee2017
    wrote on last edited by
    #1

    Hi,

    I am trying to find the equivalent of the copy(x,y,width,height) method in the QImage class for cv::Mat in OpenCV. Looking at the header qimage.h
    I see that the copy method is a wrapper over

        QImage copy(const QRect &rect = QRect()) const;
        inline QImage copy(int x, int y, int w, int h) const
            { return copy(QRect(x, y, w, h)); }
    
    

    which is wrapper over QRect. Using cv::Mat in OpenCV (http://docs.opencv.org/3.1.0/d3/d63/classcv_1_1Mat.html) would the equivalent be
    convertTo, copyTo or simply there is no equivalent and I have to write the equivalent?

    Fb.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      It's not a wrapper over QRect, it calls the copy method that takes a QRect as parameter. It's more or less the equivaled of the copyTo method that takes two parameters but in the case case of QImage, it copies all channels in the QImage object that is returned by that function.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        You can copy section using ctor

        int x = 10,
        y = 20,
        width = 200,
        height = 200;

        Mat img1, img2;
        img1 = imread("Lenna.png");
        img2 = img1(Rect(x, y, width, height));

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved