Forum

Author Topic: remove all photos from a chunk  (Read 2998 times)

Twister

  • Newbie
  • *
  • Posts: 24
    • View Profile
remove all photos from a chunk
« on: August 18, 2018, 01:01:28 PM »
Hi everybody

How can I remove all photos from a chunk, or copy a chunk without the photos?

My purpose is: I want to use a set of gamma-corrected photos for the calculation of a model, then remove all photos, load the uncorrected photos and use these for texturing.

Thank you

Twister

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14839
    • View Profile
Re: remove all photos from a chunk
« Reply #1 on: August 19, 2018, 04:45:37 PM »
Hello Twister,

Are you the images from the second set taken from the same locations as first set photos? So do you need to substitute the images actually?
Best regards,
Alexey Pasumansky,
Agisoft LLC

Twister

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: remove all photos from a chunk
« Reply #2 on: August 19, 2018, 07:28:11 PM »
Hello Alexey,

in fact, the images of the first and the second set are the same, The only difference is a nonlinear intensity correction which has been performed (with MATLAB) on the original images, in order to obtain a higher number of modelling features in the dark parts of the photos.

For texturing, however, the subjects should keep there natural appearance, therefore they should be textured with the original intensities and colours. This process works well from the GUI, but it should be automized to save user interaction time.

I have two folders, one (on path_original) with 400 original images and one (on path_corrected) with the same 400 images with gamma-correction. Within the folders, the related images have the same names (from image_001.png to image_400.png). I have no problem to import the photos form path_original using chunk.addPhotos, but I was not successful removing the gamma-corrected photos before texturing.

Your advice would be very helpful, thank you in advance  :)

Twister

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14839
    • View Profile
Re: remove all photos from a chunk
« Reply #3 on: August 19, 2018, 07:54:01 PM »
Hello Twister,

Then maybe you can use one of the options describe in the related thread:
http://www.agisoft.com/forum/index.php?topic=9214.msg43161#msg43161

This is an analogue of "Change Path" GUI option.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Twister

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: remove all photos from a chunk
« Reply #4 on: August 20, 2018, 11:32:19 AM »
Hello Alexey,

thank you for your fast reply!

It seems to me that the situation in your link is different from ours. Attached you find my complete Python code for automatic evaluation  of our insect data (ca. 400 photos for each scan). The script runs well, but the problem is that in the moment of re-texturing both sets of images (original and  gamma-optimized) are present in the chunk.

As always, your help is highly appreciated, as I am still a novice to Python  ;)

Twister


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14839
    • View Profile
Re: remove all photos from a chunk
« Reply #5 on: August 26, 2018, 02:08:52 PM »
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:
Code: [Select]
#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.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Twister

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: remove all photos from a chunk
« Reply #6 on: August 29, 2018, 12:40:07 PM »
Hello Alexey,

I followed your code, and now the original photos are loaded into newchunk. But the script still uses the gamma-corrected photos for texturing.

Only when I start "Build Texture" from the GUI (with Newchunk being the active chunk), the original photos are used, as intended. ???

Best regards

Twister


Twister

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: remove all photos from a chunk
« Reply #7 on: August 30, 2018, 06:10:32 PM »
Hello,

I found the error: the for-loop should read: "for camera in list(newchunk.cameras):" - the paths of newchunk have to be modified, not of chunk!

Now everything works as planned.

Thank you again, Alexey,

Twister