How can I paint a mesh using projections of real photographs?
You might be able to use some of the techniques from this tutorial on camera mapping.

Namely, you may want to try using "Project from View" to project selected mesh faces' UV coordinates based on the current camera view. I've never tried using it via scripting, though.