Image Stitching C++

Viewed 50

I wrote stitching class in python to stitch 2 images and it works just fine!

I am trying to convert the code to C++ but the results are not the same after the warping part.

Python Code

result = cv2.warpPerspective(self.img1, Ht.dot(M_left), (xmax-xmin, ymax-ymin))
result[t[1]:h1+t[1],t[0]:w1+t[0]] = self.img2 # result is the output image

C++ Code

cv::warpPerspective(Stitching::img1, result, Htmat * M_left, Size((int)xmax - (int)xmin, (int)ymax - (int)ymin));
Stitching::img2.copyTo(result.colRange(t[0], w1 + t[0]).rowRange(t[1], h1 + t[1]));

Am I converting result[t[1]:h1+t[1],t[0]:w1+t[0]] = self.img2 the wrong way in C++? If yes, what is the correct way? Thanks in advance!

1 Answers

maybe you can try this:

Stitching::img2.copyTo(result(Rect(t[0], t[1], w1, h1))

Regards

Related