Hello Twister,
I don't see the difference, but maybe I'm missing something.
As far as I understand, you need to substitute the images with the gamma-optimized lighting with the original set of images, keeping the same alignment and calibration parameters (using Add Photos will not help you, since images added in such way will not be aligned and anyhow connected to the existing mesh model).
So I can suggest to try the following code instead of your lines #70-81:
#load original photos and re-texture with these
newchunk = chunk.copy()
newchunk.label = "Newchunk"
path_ori = path_main + "\\RawEDOF" #path to the original photos
for camera in list(chunk.cameras):
if not os.path.isfile("/".join([path_ori, camera.photo.path.rsplit("/",1)[1]])):
print("Missing " + camera.label + " in the new location, camera disabled.")
camera.enabled = False
continue
photo = camera.photo.copy()
photo.path = "/".join([path_ori, camera.photo.path.rsplit("/",1)[1]])
camera.photo = photo
newchunk.buildUV(mapping=PhotoScan.GenericMapping)
newchunk.buildTexture(blending=PhotoScan.MosaicBlending, size=4096)
Also I see that you are using doc.save(some_path) lines in your code that are acting as "Save As" option - it means that the document will be re-opened and your previously assigned chunk variable will be related to another document, so you should re-assign chunk after saving the document under different name.