Compositing: How the resize the scene to fit the matte? I've a scene and an image matte built from an image with a green rectangle depicting a hole. I'd like to have the camera view resized to fit the hole.

The image with the hole may change, the hole may be sized and located differently (no input about that, only the green color of the pixels).

I have used a Transform node at the location indicated with ?. I have to adjust the offsets and the scale factor visually to position the camera view exactly in the hole. I'm looking for something automatic if this exists, or the most effective solution in any case.

I'm a true beginner.



Assumptions:


This final result is an image, not an animation.
The green rectangle and the camera have the same W/H ratio.
The image appears in the foreground, normal to the camera view axis, in the composited result. No perspective is involved.
You can use a Plane Track Deform: in doing so, you'll be able to apply the scene both on a rectangle or a deformed plane.




Open the "matte image" in the Movie Clip Editor on "Tracling" mode
Add 4 markers near the corners





Select all the markers and add a Plane Track





Drag the corners to fit the "hole" you want to fill with your scene
Open the Node Editor and the Plane Track Deform (add > distort > plane track deform)