Forum

Author Topic: Images are not visble after alignment  (Read 1604 times)

Aravinth

  • Newbie
  • *
  • Posts: 18
    • View Profile
Images are not visble after alignment
« on: December 10, 2019, 09:48:10 PM »
Hello,
          I have used the below code to align the thermal images the console shows the process but the images are not shown in the workspace and in the reference tab. Kindly help me.
 
Code: [Select]

import glob
try:
    import Metashape as env
    doc = Metashape.app.document
    env_type = 1
except:
    import PhotoScan as env
    doc = PhotoScan.app.document
    env_type = 2
   
load_images = True
load_thermal = True
# Thermal data
path_calib = 'C:\\Program Files\\Agisoft\\Metashape Pro'
path_images = 'C:\\Program Files\\Agisoft\Metashape Pro\\flir'
path_subdir = 'flir\\'
fileext = '*.tiff'
chunk_name = 'FLIR'
calib_fname = 'xt2_flir_20190206.xml'
flength = 13
psize = 0.017

ch = env.app.document.addChunk()
ch.label = chunk_name

# initiate images list
imgList = []
imgListNames = []
# construct flight directory
dir_srs = path_subdir
# reset file counter
cnt = 0

# go over all images
for filename in glob.glob(dir_srs + fileext):
# add image to list
    imgList.append(filename)
    fname = filename.split('\\')
    # add file name
    imgListNames.append(fname[-1])
    #' increment counter
    cnt += 1
   
if load_images == 1:
    # add images to chunk
    ch.addPhotos(imgList)
# create calibration instance
calibData = env.Calibration()
# load calibration data from file
calibData.load(calib_fname, format="xml")
# load camera calibration params
ch.sensors[0].user_calib = calibData
# assign camera focal length
ch.sensors[0].focal_length = flength
# assign camera pixel size
ch.sensors[0].pixel_size = env.Vector([psize,psize])
# do not optimise camera intrinsics
if env_type == 1:
    ch.sensors[0].fixed_calibration = True
else:
    ch.sensors[0].fixed = True

# ch = Metashape.app.document.chunk
path = '20191024_gcp_coordinates.txt'
ch.loadReference(path, format = Metashape.ReferenceFormatCSV, delimiter=",", columns="nxyz")

for frame in ch.frames:
    frame.matchPhotos(accuracy=Metashape.HighestAccuracy, generic_preselection=True,reference_preselection=True)

# ch.matchPhotos(accuracy=Metashape.LowAccuracy, generic_preselection=True,reference_preselection=True)
ch.alignCameras()
# ch.buildDepthMaps(quality=Metashape.MediumQuality, filter=Metashape.AggressiveFiltering)
# ch.buildDenseCloud()
# ch.buildModel(surface=Metashape.Arbitrary, interpolation=Metashape.EnabledInterpolation)
# ch.buildUV(mapping=Metashape.GenericMapping)
# ch.buildTexture(blending=Metashape.MosaicBlending, size=4096)
#optimizeCameras(fit_f=True, fit_cx=True, fit_cy=True, fit_b1=True, fit_b2=True, fit_k1=True, fit_k2=True, fit_k3=True, fit_k4=False, fit_p1=True, fit_p2=True, fit_p3=False, fit_p4=False)


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Images are not visble after alignment
« Reply #1 on: December 10, 2019, 10:04:47 PM »
Hello Aravinth,

Do you mean that even chunk.addPhotos() doesn't work in your code?

Are there any error messages in the Console pane when you run this script? I can suggest to debugging purposes to print out the paths that you are trying to load as images. Probably, using the absolute paths would solve the problem.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Aravinth

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Images are not visble after alignment
« Reply #2 on: December 10, 2019, 10:11:18 PM »
Hello Alexey,
 
The console shows the image alignment process completely. The points are deducted and the alignment is done in the console but the images are not visible.


« Last Edit: December 10, 2019, 10:25:53 PM by Aravinth »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Images are not visble after alignment
« Reply #3 on: December 11, 2019, 02:00:57 PM »
Hello Aravinth,

I think that the situation is the following:

by default the project workspace has a single empty chunk. You have added the new chunk to the document and performed the processing there, however, the active chunk has not been switched, so you see the contents of the default empty chunk.

If you have the Workspace pane opened, you should see the second chunk with the custom label that contain the aligned cameras.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Aravinth

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Images are not visble after alignment
« Reply #4 on: December 11, 2019, 02:05:36 PM »
Hello Alexey,

Thank you for your guidance. I can see the images in a new chunk Flir.  Thank you so much.