I'm not sure if this question is on-topic or not, based on the tour. Feel free to point me elsewhere.
The short version of the question is: what's the typical technique for generating the clean-plate for footage in which the camera moves?
More detail:
It's easy to understand how computer graphics are superimposed over live footage to cover existing elements (like an actor in green pajamas). For example, it seems easy for the CG version of the Hulk to completely cover Mark Ruffalo without having to replace anything real that wasn't already visible in the shot.
It's also easy to understand where this comes from for footage where the camera doesn't move. With a locked-off shot it's not hard to get a shot without any of the actors/props or whatever is being replaced (a clean-plate, as it were), and match that to the real take.
But I'm baffled about non-locked-off shots. A good example might be a scene from Star Trek: First Contact when the Borg Queen is introduced. The upper half of her body is lowered onto a lower-half kind of rig. Whether the actress is actually lowered or not, there is background behind either her invisible real body, as she's lowered, or behind her invisible upper body as it's being rotoscoped down into position.
Either way, they had to have something to show behind the parts of the actress that weren't supposed to be there in the final footage.
One theory I've imagined is that they run the camera through the shot first without the actors, and then repeat the shot with the actors, but this seems prohibitively prone to imprecision.
Another theory is that they get the clean plate from another frame in the same footage, but this seems like it'd only work in very specific cases.
I've also seen tutorials in which the trick is that the shot IS locked-off, and the camera shake is added in after the composite. But again, this only works for certain kinds of shots, and I have a hard time believing that this is the way it's done for everything.
What is/are the typical technique(s) for generating a clean plate for footage in which the camera moves?