First off I dont know of any such plugin and am not an experienced scripter, so Im no help here.
But the problem certainly sounds interesting.
In principle I guess it should not be beyond Photoshop/Scriptings reach to recognize some defined forms and use them as basis for a perspectival transformations, because that seems to be one of the operations »Photomerge« accomplishes.
But how to make it recognize distorted rectangles (possibly with crooked and broken lines depending on the ornamentation and form of the frame), which arent even necessarily of the same proportions, and define the amount of correction seems pretty close to unfathomable to me.
As of now I guess Youre better off doing it manually and automate whatever else is possible to speed up the process.
Was it a studio-shoot or done on location?