Unsolved QImage->copy(x,y,width,height)
-
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 overQImage 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.
-
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.
-
Hi
You can copy section using ctorint x = 10,
y = 20,
width = 200,
height = 200;Mat img1, img2;
img1 = imread("Lenna.png");
img2 = img1(Rect(x, y, width, height));