**Posts:**135**Joined:**Thu Sep 16, 2021 7:05 am**Real Name:**Cody Predum

I have a question about corner pinning with the planar tracker. Basically I'm trying to figure out how to make sure that the image/footage that you composite into the corner pin is the correct aspect ratio on the surface it's being composited onto. I feel like this issue isn't very complicated at heart, but I am going to give a long explanation of it just to make sure my question is actually clear since last time I tried to explain I didn't do a very good job. (For what it's worth, I don't fault anyone for not having the time or patience to read all of this, but any help would be extremely appreciated.)

First, the image in the corner pin, at least by default, stretches to the four corners of the corner pin. If you have markers in your footage, this is probably not an issue, but if you don't, there are many circumstances where the corners of the corner pin aren't where the corners of the composite are intended to be. For example, it's common to use lines known to be parallel or perpendicular in the real world to define the correct perspective with the corner pin, even though these might be beyond the intended corners for the composited image. As I mentioned, this can easily be worked around by inserting a transform node between the media and the tracker node, which then allows you to adjust size and position relative to the plane defined by the corner pin. However, this illustrates the aspect ratio I'm talking about pretty well: as far as I know, there isn't a way to get the comped image to be the correct aspect ratio without eyeballing it. Furthermore, what really bugs me about it is that I'm pretty this can be computed from the data already defined by the original corner pin points. I'm going to go on a short math rant for a second, but then I'll give a very clear visual example.

My first image shows a few examples of the corner pin tool with "show grid" enabled, and while I don't know the proper mathematical proof for it, it's pretty easy to see that any 4 point polygon in screen-space can define a rectangle in world-space relative to the viewing angle. This essentially boils down to the idea that any 4 points in screen-space correspond to only one possible rectangle on a world-space plane. For the sake of further clarification (and/or confusion), I should add that this does not mean only one possible world-space rectangle, but a set of planes that are all parallel, whose orientation is defined by the original polygon, and for each of those planes there is only one possible rectangle that matches the screen-space polygon. All of these possible rectangles would appear the same size in screen-space, and would correspond to larger world- space rectangles for planes farther away, and smaller ones if the plane is closer. This is the geometric consequence that follows from the assumption that all the angles of the screen-space polygon are actually 90 degree angles on a plane that is being seen from a viewpoint that isn't perpendicular to it.

That said, I'm pretty sure that it's a necessary mathematical consequence that all of those possible world-space rectangles are of one specific aspect ratio, regardless of them not necessarily being any specific world-space size. What this means is that as soon as you pick ANY 4 points with the corner pin, you have already defined the only possible aspect ratio for every rectangle that could possibly be seen as that specific shape from that specific viewing angle. And while I don't know how to do this calculation off the top of my head, I feel like it is definitely way less complicated than pretty much all the other math the planar tracker already does. I'm kind of just wondering why there isn't a "maintain foreground aspect ratio" checkbox right under the "show grid" checkbox.

So back to the real question with a more practical example. Let's say there is a space on a plane in your shot that you want to composite something onto, and the footage wasn't shot with markers. That's fine though, because there are lines that you know are parallel and/or perpendicular in world-space. You use them to define the points of the corner pin, as this allows you to get the perspective correct, but those points aren't where you want the corners of the composite to be. Like I mentioned before, this is where I use a transform node to adjust within the corner pin, but I'm only able to do that by eye, and it feels very wrong to have to eyeball something that I know has only one mathematical solution for which I already have the necessary data.

Here are some images that show that scenario pretty well. In the first image (top left), let's say you're trying to comp an image into the area where I poorly drew the green square. For the sake a sort of extreme example, we're also going to imagine that the corner and line that I covered with red is occluded by something in the shot (if it wasn't, you could accurately corner pin that one metal area, but you would still have the same problem I'm describing). Since the top and bottom edges of the left metal area are clearly the same height as the first one, we can use the left corners from that one instead to still accurately define the plane we want to composite to (top right). Obviously, this will probably get you a super stretched composite (bottom left). In this case, the test image I am using for the composite is originally a square. And finally, the bottom right image shows the way I currently know to adjust the comped aspect ratio, which requires eyeballing it. The other work around I've found is to use the ImagePlane3D node for the transform changes, since you can leave the aspect ratio alone and line it up using the pitch and yaw controls; but this means you have to eyeball getting it on the correct plane, which feels like an even worse compromise than eyeballing the aspect ratio.

Sorry for making this post so long, but hopefully I at least made my question clear even it was at the expense of the length of this post.

First, the image in the corner pin, at least by default, stretches to the four corners of the corner pin. If you have markers in your footage, this is probably not an issue, but if you don't, there are many circumstances where the corners of the corner pin aren't where the corners of the composite are intended to be. For example, it's common to use lines known to be parallel or perpendicular in the real world to define the correct perspective with the corner pin, even though these might be beyond the intended corners for the composited image. As I mentioned, this can easily be worked around by inserting a transform node between the media and the tracker node, which then allows you to adjust size and position relative to the plane defined by the corner pin. However, this illustrates the aspect ratio I'm talking about pretty well: as far as I know, there isn't a way to get the comped image to be the correct aspect ratio without eyeballing it. Furthermore, what really bugs me about it is that I'm pretty this can be computed from the data already defined by the original corner pin points. I'm going to go on a short math rant for a second, but then I'll give a very clear visual example.

- CornerQuestion02.png (236.76 KiB) Viewed 505 times

My first image shows a few examples of the corner pin tool with "show grid" enabled, and while I don't know the proper mathematical proof for it, it's pretty easy to see that any 4 point polygon in screen-space can define a rectangle in world-space relative to the viewing angle. This essentially boils down to the idea that any 4 points in screen-space correspond to only one possible rectangle on a world-space plane. For the sake of further clarification (and/or confusion), I should add that this does not mean only one possible world-space rectangle, but a set of planes that are all parallel, whose orientation is defined by the original polygon, and for each of those planes there is only one possible rectangle that matches the screen-space polygon. All of these possible rectangles would appear the same size in screen-space, and would correspond to larger world- space rectangles for planes farther away, and smaller ones if the plane is closer. This is the geometric consequence that follows from the assumption that all the angles of the screen-space polygon are actually 90 degree angles on a plane that is being seen from a viewpoint that isn't perpendicular to it.

That said, I'm pretty sure that it's a necessary mathematical consequence that all of those possible world-space rectangles are of one specific aspect ratio, regardless of them not necessarily being any specific world-space size. What this means is that as soon as you pick ANY 4 points with the corner pin, you have already defined the only possible aspect ratio for every rectangle that could possibly be seen as that specific shape from that specific viewing angle. And while I don't know how to do this calculation off the top of my head, I feel like it is definitely way less complicated than pretty much all the other math the planar tracker already does. I'm kind of just wondering why there isn't a "maintain foreground aspect ratio" checkbox right under the "show grid" checkbox.

So back to the real question with a more practical example. Let's say there is a space on a plane in your shot that you want to composite something onto, and the footage wasn't shot with markers. That's fine though, because there are lines that you know are parallel and/or perpendicular in world-space. You use them to define the points of the corner pin, as this allows you to get the perspective correct, but those points aren't where you want the corners of the composite to be. Like I mentioned before, this is where I use a transform node to adjust within the corner pin, but I'm only able to do that by eye, and it feels very wrong to have to eyeball something that I know has only one mathematical solution for which I already have the necessary data.

- CornerQuestion05-2.png (407.09 KiB) Viewed 505 times

Here are some images that show that scenario pretty well. In the first image (top left), let's say you're trying to comp an image into the area where I poorly drew the green square. For the sake a sort of extreme example, we're also going to imagine that the corner and line that I covered with red is occluded by something in the shot (if it wasn't, you could accurately corner pin that one metal area, but you would still have the same problem I'm describing). Since the top and bottom edges of the left metal area are clearly the same height as the first one, we can use the left corners from that one instead to still accurately define the plane we want to composite to (top right). Obviously, this will probably get you a super stretched composite (bottom left). In this case, the test image I am using for the composite is originally a square. And finally, the bottom right image shows the way I currently know to adjust the comped aspect ratio, which requires eyeballing it. The other work around I've found is to use the ImagePlane3D node for the transform changes, since you can leave the aspect ratio alone and line it up using the pitch and yaw controls; but this means you have to eyeball getting it on the correct plane, which feels like an even worse compromise than eyeballing the aspect ratio.

Sorry for making this post so long, but hopefully I at least made my question clear even it was at the expense of the length of this post.