filming and using 3d environment

Does anyone know how to add a real filmed object to a 3d environment? And how to copy the camera tracking of the real camera? I found a lot of 3d object into a real movie, but still didn't find the other way around.