Hi,
I'm processing images from UAV to generate DEM and Orthos. I wrote a Python script to process multiple chunks at the same time (and to learn using Python for PS).
I'm now using the script and in the build dense cloud step after processing for several hours the dense cloud is not there, even though the log file says it ran successfully. Depth maps don't seem to be there either. I'm on 1.4.
This has worked in a previous project with multiple chunks, although one one occasion I had the same problem, but on a smaller image set and I just ran it again, this time successfully. I run each step (align, dense, dem, ortho, export) separately, as I check the results and clean up before continuing.
Why is the Dense Cloud missing, what did I miss?
Cheers
Martin
code snippet that runs dense cloud:
def dense_c(self):
for _ in self.cks:
_.buildDepthMaps(quality=PhotoScan.HighQuality,
filter=PhotoScan.MildFiltering)
_.buildDenseCloud(point_colors=True)
Log (last few lines):
2018-02-13 16:45:27
2018-02-13 16:45:27 Depth reconstruction devices performance:
2018-02-13 16:45:27 - 5% done by CPU
2018-02-13 16:45:27 - 95% done by GeForce GTX 980
2018-02-13 16:45:27 Total time: 6356.12 seconds
2018-02-13 16:45:27
2018-02-13 16:45:28 Finished processing in 6375.36 sec (exit code 1)
2018-02-13 16:45:28 BuildDenseCloud
2018-02-13 16:45:28 Generating dense cloud...
2018-02-13 16:45:28 Generating dense point cloud...
2018-02-13 16:45:32 selected 284 cameras in 4.853 sec
2018-02-13 16:45:32 working volume: 8580x3829x2775
2018-02-13 16:45:32 tiles: 2x1x1
2018-02-13 16:45:32 selected 135 cameras in 0.001 sec
2018-02-13 16:45:32 preloading data... done in 3.479 sec
2018-02-13 16:45:36 filtering depth maps... done in 881.324 sec
2018-02-13 17:00:18 preloading data... done in 7.266 sec
2018-02-13 17:00:25 accumulating data... done in 12.639 sec
2018-02-13 17:00:39 building point cloud... done in 2.298 sec
2018-02-13 17:00:42 selected 232 cameras in 0.001 sec
2018-02-13 17:00:42 preloading data... done in 5.479 sec
2018-02-13 17:00:47 filtering depth maps... done in 10398 sec
2018-02-13 19:54:06 preloading data... done in 13.742 sec
2018-02-13 19:54:20 accumulating data... done in 29.615 sec
2018-02-13 19:54:51 building point cloud... done in 2.034 sec
2018-02-13 19:54:54 52859925 points extracted
2018-02-13 19:54:55 Finished processing in 11367.2 sec (exit code 1)
Full code:
import PhotoScan
import os
# Checking compatibility
compatible_major_version = "1.4"
found_major_version = ".".join(PhotoScan.app.version.split('.')[:2])
if found_major_version != compatible_major_version:
raise Exception("Incompatible PhotoScan version: {} != {}".format(found_major_version, compatible_major_version))
class ChunksProc(object):
def __init__(self, cks):
self.cks = cks
def remove_align(self):
for _ in self.cks:
for c in _.cameras:
c.transform = None
def align(self):
for _ in self.cks:
_.matchPhotos(accuracy=PhotoScan.HighAccuracy,
generic_preselection=False,
reference_preselection=True,
filter_mask=True,
keypoint_limit=40000,
tiepoint_limit=0)
_.alignCameras()
def dense_c(self):
for _ in self.cks:
_.buildDepthMaps(quality=PhotoScan.HighQuality,
filter=PhotoScan.MildFiltering)
_.buildDenseCloud(point_colors=True)
def dem(self):
for _ in self.cks:
_.buildDem(source=PhotoScan.DenseCloudData,
interpolation=PhotoScan.EnabledInterpolation)
def ortho(self):
for _ in self.cks:
_.buildOrthomosaic(surface=PhotoScan.ElevationData,
blending=PhotoScan.MosaicBlending,
fill_holes=False)
def export(self, pth, prefix):
for _ in self.cks:
num = str(_)[-3]
file = '{}_DSM_{}.tif'.format(prefix, num)
_.exportDem(path = os.path.join(pth, file),
write_world = True)
file = '{}_Ortho_{}.tif'.format(prefix, num)
_.exportOrthomosaic(path = os.path.join(pth, file),
write_world = True)
def exp_jpg(self, pth, prefix, w = None, h = None):
doc.save()
for _ in self.cks:
num = str(_)[-3]
file = '{}_Ortho_{}.jpg'.format(prefix, num)
_.exportOrthomosaic(path = os.path.join(pth, file),
write_world = True)
doc = PhotoScan.app.document
if not len(doc.chunks):
raise Exception("No chunks!")
cks = ChunksProc(doc.chunks)
pth = r'E:\Dominica\Data Output Folder'
jpgpth = r'E:\Dominica\Data Output Folder\JPG Orthos'
prefix = input('Enter file prefix: ')
cks.align()
doc.save()
cks.dense_c()
doc.save()
cks.dem()
doc.save()
cks.ortho()
doc.save()
cks.export(pth, prefix)
cks.exp_jpg(jpgpth, prefix)
doc.save()