3

I need to merge two images with respect to its coordinate values.

I have done merging using single point to point merge using Paste an image to another image at two given co-ordinates with altered opacity using PIL or OpenCV in Python

I got output for that. But I need to do multiple coordinate comparison and merge in same 2 images.. Is there any possible way to do that?

Input1

Input 2

Result

Above images are the results. Output has only single point to point merge. But I need in multiple point merge.

The parameters are {"Headpts": [354,64, "ShoulderSpinepts": [25,234], "LeftShoulderpts": [123,243], "LeftElbowpts": [54,234], "LeftHandpts": [0, 0], "RightShoulderpts": [0, 0], "RightElbowpts": [0, 0], "RightHandpts": [0, 0], "MidSpinepts": [0, 0], "BaseSpinepts": [0, 0], "LeftHippts": [0, 0], "LeftKneepts": [0, 0], "LeftFootpts": [0, 0], "RightHippts": [0, 0], "RightKneepts": [0, 0], "RightFootpts": [0, 0], "LeftWristpts": [0, 0], "RightWristpts": [0, 0], "Neckpts": [0, 0]}

1 Answers1

2

I'm using cv2.getAffineTransform(). Because it can only add three point (only four on cv2.getPerspectiveTransform()), so I cut the image to multiple triangle.

This is my sample:

enter image description here The point:enter image description here

And my goal is to reshape the cat's head in to a 300*300 box.

First, crop the area into triangle according the point.

enter image description here

And then usingcv2.getAffineTransform() to get those specific area which had been adjusted. enter image description here enter image description here enter image description here

Then use cv2.bitwise_or() to add them together. Generated image: enter image description here

Your project is more complex, but it's the same theory. You need crop the image into several triangle . And then transform them to fit the model. After merge those triangle together, you can get your image.

CodingPeter
  • 241
  • 2
  • 10
  • 3
    How did u adjust the cut triangle section? You mentioned like "to get those specific area which had been adjusted." –  Mar 12 '21 at 11:40
  • cv2.getAffineTransform() Sample code: https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_geometric_transformations/py_geometric_transformations.html – CodingPeter Mar 14 '21 at 18:00
  • For static image your method is working. But when i apply it in live video, the frames are shrinking. Any other suggestions? THanks @CodingPeter –  Mar 18 '21 at 05:16
  • Do you know what part of your program spend most of the time? Then duel with it. – CodingPeter Mar 18 '21 at 05:32