Forum

Author Topic: GPU in Align Photos not working?  (Read 2927 times)

ax0n

  • Newbie
  • *
  • Posts: 7
    • View Profile
GPU in Align Photos not working?
« on: August 02, 2017, 09:55:41 AM »
Greetings,

I am running a two chunk data set of about 500 photos each on an AWS g3.8xlarge instance.

the general outline of the workflow looks like this

Code: [Select]
ps.app.gpu_mask = 3

# match and align RGB chunk
chunk = doc.chunks[0]
chunk.matchPhotos()

# match and align NIR chunk
chunk = doc.chunks[1]
chunk.matchPhotos()

# align NIR and RGB chunks
doc.alignChunks()

##### for RGB Chunk #####
chunk = doc.chunks[0]
# build dense point cloud
chunk.buildDenseCloud()

##### for NIR Chunk #####
chunk = doc.chunks[1]
# build dense point cloud
chunk.buildDenseCloud()

# For RGB Chunk
chunk = doc.chunks[0]
# build DSM
chunk.buildDem()
# build Orthophoto
chunk.buildOrthomosaic()
# export DSM
chunk.exportDem()
# export Orthophoto
chunk.exportOrthomosaic()

##### for NIR Chunk #####
chunk = doc.chunks[1]
# build DSM
chunk.buildDem()
# build Orthophoto
chunk.buildOrthomosaic()
# export DSM
chunk.exportDem()
# export Orthophoto
chunk.exportOrthomosaic()




I am mid-dense cloud and I am not seeing any GPU usage... but I was in the earlier steps. Am I mistaken that I should be seeing GPU work or is something not working as it should?

Thank you for your time and input.


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14937
    • View Profile
Re: GPU in Align Photos not working?
« Reply #1 on: August 02, 2017, 01:30:46 PM »
Hello indigo,

Can you print the output results of the following command in your script:
Code: [Select]
PhotoScan.app.enumGPUDevices()Also the processing log would be helpful.

As an unrelated comment: I do not see that you are using .alignCameras() function for each chunk after matching the photos.
Best regards,
Alexey Pasumansky,
Agisoft LLC

ax0n

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: GPU in Align Photos not working?
« Reply #2 on: August 03, 2017, 12:01:48 PM »
Hey Alexey,
sorry for the delay,

I was able to sort the problem... it turns out the GPUs where not being used because it was currently in the `filtering depth maps` step. (Which I believe is CPU only)

here is the full script for reference ... One question I have is that for some reason my NIR and RGB chunks came out at different scales and different orientations.. the NIR is substantially smaller and at about 45deg orientation. do you see anything in this script that could account for this? the photos are all geotagged and I use the RGB for reference in the align chunks phase...


Code: [Select]

# start new project and save as specific unique project name
import os
import PhotoScan as ps
doc = ps.app.document
ps.app.gpu_mask = 3

project_path = ps.app.getSaveFileName('Specify project filename for saving: ')
if not project_path:
    print('Script aborted')

if project_path[-4:].lower() != '.psx':
    project_path += '.psx'

doc.save(project_path)
ps.app.update()

# get folder of RGB photos
path_photos_rgb = ps.app.getExistingDirectory('Specify folder with RGB photos: ')
path_photos_rgb += '/'

# get folder of NIR photos
path_photos_nir = ps.app.getExistingDirectory('Specify folder with NIR photos: ')
path_photos_nir += '/'

# create 'RGB' chunk and add photos
chunk = doc.addChunk()
chunk.label = 'RGB'
image_list = os.listdir(path_photos_rgb)
photo_list = list()

for photo in image_list:
    if photo.rsplit('.',1)[1].upper() in ['JPG', 'JPEG', 'TIF', 'PNG', 'TIFF']:
           photo_list.append(path_photos_rgb + photo)
           print(photo)
    else:
           print('No photo available.')

chunk.addPhotos(photo_list)
doc.save()
ps.app.update()

# create 'NIR' chunk and add photos
chunk = doc.addChunk()
chunk.label = 'NIR'
image_list = os.listdir(path_photos_nir)
photo_list = list()

for photo in image_list:
    if photo.rsplit('.',1)[1].upper() in ['JPG', 'JPEG', 'TIF', 'PNG', 'TIFF']:
           photo_list.append(path_photos_nir + photo)
           print(photo)
    else:
           print('No photo available.')

chunk.addPhotos(photo_list)
doc.save()
ps.app.update()


# match and align RGB chunk
chunk = doc.chunks[0]
chunk.matchPhotos(
  accuracy = ps.HighAccuracy,
  reference_preselection=True,
  filter_mask = False,
  keypoint_limit=40000,
  tiepoint_limit=4000)
chunk.alignCameras()
doc.save()
ps.app.update()


# match and align NIR chunk
chunk = doc.chunks[1]
chunk.matchPhotos(
  accuracy = ps.HighAccuracy,
  reference_preselection=True,
  filter_mask = False,
  keypoint_limit=40000,
  tiepoint_limit=4000)
chunk.alignCameras()
doc.save()
ps.app.update()


# align NIR and RGB chunks
doc.alignChunks(doc.chunks,
  doc.chunks[0],
  method='points',
  fix_scale=False,
  accuracy=ps.HighAccuracy,
  preselection=False,
  filter_mask=False,
  point_limit=40000
  )
doc.save()
ps.app.update()

# for RGB Chunk
chunk = doc.chunks[0]
# build dense point cloud
chunk.buildDenseCloud(
  quality = ps.MediumAccuracy,
  filter = ps.ModerateFiltering)
doc.save()
ps.app.update()

# for NIR Chunk
chunk = doc.chunks[1]
# build dense point cloud
chunk.buildDenseCloud(
  quality = ps.MediumAccuracy,
  filter = ps.ModerateFiltering)
doc.save()
ps.app.update()

# For RGB Chunk
chunk = doc.chunks[0]

# build DSM
chunk.buildDem(
  source=ps.DenseCloudData,
  interpolation=ps.EnabledInterpolation)
doc.save()
ps.app.update()

# build Orthophoto
chunk.buildOrthomosaic(
  surface=ps.ElevationData,
  blending=ps.MosaicBlending,
  color_correction=False,
  fill_holes=True,
  projection=chunk.crs,
  # ][, region ][, dx ][, dy ][, progress ]
  )
doc.save()
ps.app.update()

# export DSM
chunk.exportDem(
  project_path[:-4]+'_rgb_DSM.tif',
  #format=ps.RasterFormatXYZ,
  image_format=ps.ImageFormatTIFF,
  #projection=ps.EPSG:4326,
  #][, region][, dx][, dy]
  # [, blockw][, blockh][,
  nodata = -99999,
  write_kml=False,
  write_world=False)

# export Orthophoto
chunk.exportOrthomosaic(
  project_path[:-4]+'_rgb_ORTHO.tif',
  #format=ps.RasterFormatXYZ,
  image_format=ps.ImageFormatTIFF,
  raster_transform=ps.RasterTransformNone,
  #projection=ps.CoordinateSystem,
  #[, region ][, dx ]
  #[, dy][, blockw][, blockh],
  write_kml=False,
  write_world=False,
  write_alpha=False,
  tiff_compression=ps.TiffCompressionNone,
  tiff_big=False,
  jpeg_quality=90)


# for NIR Chunk
chunk = doc.chunks[1]
# build DSM
chunk.buildDem(
  source=ps.DenseCloudData,
  interpolation=ps.EnabledInterpolation)
doc.save()
ps.app.update()

# build Orthophoto
chunk.buildOrthomosaic(
  surface=ps.ElevationData,
  blending=ps.MosaicBlending,
  color_correction=False,
  fill_holes=True,
  projection=chunk.crs,
  # ][, region ][, dx ][, dy ][, progress ]
  )
doc.save()
ps.app.update()

# export DSM
chunk.exportDem(
  project_path[:-4]+'_nir_DSM.tif',
  #format=ps.RasterFormatXYZ,
  image_format=ps.ImageFormatTIFF,
  #projection=ps.EPSG:4326,
  #][, region][, dx][, dy]
  # [, blockw][, blockh][,
  nodata = -99999,
  write_kml=False,
  write_world=False)

# export Orthophoto
chunk.exportOrthomosaic(
  project_path[:-4]+'_nir_ORTHO.tif',
  #format=ps.RasterFormatXYZ,
  image_format=ps.ImageFormatTIFF,
  raster_transform=ps.RasterTransformNone,
  #projection=ps.CoordinateSystem,
  #[, region ][, dx ]
  #[, dy][, blockw][, blockh],
  write_kml=False,
  write_world=False,
  write_alpha=False,
  tiff_compression=ps.TiffCompressionNone,
  tiff_big=False,
  jpeg_quality=90)

doc.save()
ps.app.update()
print("Script Completed. Layers saved at " + project_path[:-4] )