1

I am trying to make a panorama and as there is a general method of finding transformation b/w two images and then doing warpPerspective to transorm in co-ordinates of previous image. H1 is 3x3 homoraphy matrix image1Frame = H1*image2Frame

(image2Frame = [x2, y2, 1],image1Frame = [x1, y1, 1] considering this we need to devide H1*image2Frame[:2]/H1*image2Frame[2])

From this methodology I was trying to transform several image in my 1st image co-ordinates and to determine homography matrices I used linear transform. image1Frame = H1*H2*image3Frame given:- image2Frame = H2*image3Frame

after doing this task for all my images I transformed co-ordinates (x, y) (i.e the pixel co-ordinates) and got the range of (x,y) co-ordinates and then set the finalImageShape = (max of y-min of y, max of x - min of x). Using here -ve sign for min of x and y because I got them -ve.

and set a translation matrix for translating -ve image co-ordinates so that I may get whole panorama but even then I get most of my image blank and also some part of my base image (image1) also gets cut out even though I set it's H matrix np.eye(3) .

My code for making panorama:-

`

imgBase = np.zeros((dsize[0], dsize[1], 3), dtype='uint8')
for i in finalData[1:]:
    # i = [index of image, H]
    # H = multiplication of corrsponding H as describes above 

    img = cv2.warpPerspective(Data['DataCV'][i[0]], i[1]@shiftMat,(dsize[1],dsize[0]))
    print(img.shape)
    imgBase = cv2.addWeighted(img, 5, imgBase, 0.5, 1)
cv2.imshow('img',imgBase)
cv2.waitKey()
cv2.destroyAllWindows()

`

Here are some code lines from opencv docs which i am using with some changes.

H, mask = cv2.findHomography(imgAccRejPts, imgBasePts, cv2.RANSAC)

please help me and also suggest any other technique as I am just using Bitwise operations of opencv to achive it.

Thank You,

ShivamPR21
  • 119
  • 1
  • 8
  • 1
    I didnt read the posting, but from your question title: yes. If you have H1 and H2 and a point p1, the if p2 = H1*p1 and p3 = H2*p2 then p3 = (H2*H1)*p1 – Micka Jan 18 '19 at 18:52
  • What about homogenous to hetrogenous transform can we bypass this one please see edited question. – ShivamPR21 Jan 18 '19 at 19:15
  • also can you suggest may method to make these warped images displayable as i am getting images(panorama) which is inappropriate even by shifting i.e H@[[1, 0, xshift], [0, 1, yshift], [0,0,1]] – ShivamPR21 Jan 18 '19 at 20:14
  • the problem might be that most of each warped images panorama space will be blank. If you have 10 images and every panorama pixel is covered by exactly 2 of those images, you will addWeighted 8 times 0 to that pixel. Instead you could use and warp masks with the same transformations and only addWeighted each image at its warped mask's position. If you then get artifacts at the borders, use something like linear cross blending like in https://stackoverflow.com/questions/22315904/blending-does-not-remove-seams-in-opencv/22324790#22324790 – Micka Jan 19 '19 at 07:40

0 Answers0