Thursday, 23 September 2021

Transform/warp coordinates

I have an array of coordinates that mark an area on the floor.

points on a floor marking an area

I want to generate a new array where all the coordinates are transformed, so that I get a warped array. The points should look like the following image. Please note that I want to generate the graphic using the new array. It does not exist yet. It gets generated after having to new array.

a polygon that is the same as the first graphic, but warped/transformed

I know the distance between all coordinates if it helps. The coordinates json looks like this, where distance_to_next contains the distance to the next point in cm:

[
  {
    "x": 295,
    "y": 228,
    "distance_to_next": 200
  },
  {
    "x": 559,
    "y": 263,
    "distance_to_next": 30
  },
  {
    "x": 551,
    "y": 304,
    "distance_to_next": 50
  },
  {
    "x": 473,
    "y": 290,
    "distance_to_next": 70
  },
  {
    "x": 451,
    "y": 352,
    "distance_to_next": 150
  },
  {
    "x": 249,
    "y": 313,
    "distance_to_next": 100
  }
]

The first point is always in the top left.

I'm using python and opencv2 and I know about various functions like cv.warpAffine, cv.warpPerspective, cv.findHomography, cv.perspectiveTransform, etc, but I'm not sure which one to use here.

Can someone point me in the right direction? Am I missing something obvious?



from Transform/warp coordinates

No comments:

Post a Comment