kopia lustrzana https://github.com/OpenDroneMap/ODM
Merge pull request #786 from giovannicimolin/ImproveGDALPerformance
Make GDAL use 50% of the available memory when cropping
Former-commit-id: afe95b503f
pull/1161/head
commit
f93f8d70a3
|
@ -21,7 +21,7 @@ libexiv2-dev liblas-bin python-matplotlib libatlas-base-dev swig2.0 python-wheel
|
||||||
RUN apt-get remove libdc1394-22-dev
|
RUN apt-get remove libdc1394-22-dev
|
||||||
RUN pip install --upgrade pip
|
RUN pip install --upgrade pip
|
||||||
RUN pip install setuptools
|
RUN pip install setuptools
|
||||||
RUN pip install -U PyYAML exifread gpxpy xmltodict catkin-pkg appsettings https://github.com/OpenDroneMap/gippy/archive/v0.3.9.tar.gz loky scipy shapely numpy pyproj
|
RUN pip install -U PyYAML exifread gpxpy xmltodict catkin-pkg appsettings https://github.com/OpenDroneMap/gippy/archive/v0.3.9.tar.gz loky scipy shapely numpy pyproj psutil
|
||||||
|
|
||||||
ENV PYTHONPATH="$PYTHONPATH:/code/SuperBuild/install/lib/python2.7/dist-packages"
|
ENV PYTHONPATH="$PYTHONPATH:/code/SuperBuild/install/lib/python2.7/dist-packages"
|
||||||
ENV PYTHONPATH="$PYTHONPATH:/code/SuperBuild/src/opensfm"
|
ENV PYTHONPATH="$PYTHONPATH:/code/SuperBuild/src/opensfm"
|
||||||
|
|
|
@ -100,7 +100,7 @@ install() {
|
||||||
echo "Installing split-merge Dependencies"
|
echo "Installing split-merge Dependencies"
|
||||||
pip install -U scipy shapely numpy pyproj
|
pip install -U scipy shapely numpy pyproj
|
||||||
|
|
||||||
pip install -U https://github.com/OpenDroneMap/gippy/archive/v0.3.9.tar.gz
|
pip install -U https://github.com/OpenDroneMap/gippy/archive/v0.3.9.tar.gz psutil
|
||||||
|
|
||||||
echo "Compiling SuperBuild"
|
echo "Compiling SuperBuild"
|
||||||
cd ${RUNPATH}/SuperBuild
|
cd ${RUNPATH}/SuperBuild
|
||||||
|
|
|
@ -19,7 +19,7 @@ libexiv2-dev liblas-bin python-matplotlib libatlas-base-dev swig2.0 python-wheel
|
||||||
RUN apt-get remove libdc1394-22-dev
|
RUN apt-get remove libdc1394-22-dev
|
||||||
RUN pip install --upgrade pip
|
RUN pip install --upgrade pip
|
||||||
RUN pip install setuptools
|
RUN pip install setuptools
|
||||||
RUN pip install -U PyYAML exifread gpxpy xmltodict catkin-pkg appsettings https://github.com/OpenDroneMap/gippy/archive/v0.3.9.tar.gz loky scipy shapely numpy pyproj
|
RUN pip install -U PyYAML exifread gpxpy xmltodict catkin-pkg appsettings https://github.com/OpenDroneMap/gippy/archive/v0.3.9.tar.gz loky scipy shapely numpy pyproj psutil
|
||||||
|
|
||||||
ENV PYTHONPATH="$PYTHONPATH:/code/SuperBuild/install/lib/python2.7/dist-packages"
|
ENV PYTHONPATH="$PYTHONPATH:/code/SuperBuild/install/lib/python2.7/dist-packages"
|
||||||
ENV PYTHONPATH="$PYTHONPATH:/code/SuperBuild/src/opensfm"
|
ENV PYTHONPATH="$PYTHONPATH:/code/SuperBuild/src/opensfm"
|
||||||
|
|
|
@ -3,6 +3,7 @@ from opendm.system import run
|
||||||
from opendm import log
|
from opendm import log
|
||||||
from osgeo import ogr
|
from osgeo import ogr
|
||||||
import json, os
|
import json, os
|
||||||
|
from psutil import virtual_memory
|
||||||
|
|
||||||
class Cropper:
|
class Cropper:
|
||||||
def __init__(self, storage_dir, files_prefix = "crop"):
|
def __init__(self, storage_dir, files_prefix = "crop"):
|
||||||
|
@ -40,14 +41,16 @@ class Cropper:
|
||||||
'shapefile_path': shapefile_path,
|
'shapefile_path': shapefile_path,
|
||||||
'geotiffInput': original_geotiff,
|
'geotiffInput': original_geotiff,
|
||||||
'geotiffOutput': geotiff_path,
|
'geotiffOutput': geotiff_path,
|
||||||
'options': ' '.join(map(lambda k: '-co {}={}'.format(k, gdal_options[k]), gdal_options))
|
'options': ' '.join(map(lambda k: '-co {}={}'.format(k, gdal_options[k]), gdal_options)),
|
||||||
|
'max_memory': max(5, (100 - virtual_memory().percent) / 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
run('gdalwarp -cutline {shapefile_path} '
|
run('gdalwarp -cutline {shapefile_path} '
|
||||||
'-crop_to_cutline '
|
'-crop_to_cutline '
|
||||||
'{options} '
|
'{options} '
|
||||||
'{geotiffInput} '
|
'{geotiffInput} '
|
||||||
'{geotiffOutput} '.format(**kwargs))
|
'{geotiffOutput} '
|
||||||
|
'--config GDAL_CACHEMAX {max_memory}%'.format(**kwargs))
|
||||||
|
|
||||||
if not keep_original:
|
if not keep_original:
|
||||||
os.remove(original_geotiff)
|
os.remove(original_geotiff)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import ecto, os
|
import ecto, os
|
||||||
|
from psutil import virtual_memory
|
||||||
|
|
||||||
from opendm import io
|
from opendm import io
|
||||||
from opendm import log
|
from opendm import log
|
||||||
|
@ -109,7 +110,8 @@ class ODMOrthoPhotoCell(ecto.Cell):
|
||||||
'bigtiff': self.params.bigtiff,
|
'bigtiff': self.params.bigtiff,
|
||||||
'png': tree.odm_orthophoto_file,
|
'png': tree.odm_orthophoto_file,
|
||||||
'tiff': tree.odm_orthophoto_tif,
|
'tiff': tree.odm_orthophoto_tif,
|
||||||
'log': tree.odm_orthophoto_tif_log
|
'log': tree.odm_orthophoto_tif_log,
|
||||||
|
'max_memory': max(5, (100 - virtual_memory().percent) / 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
system.run('gdal_translate -a_ullr {ulx} {uly} {lrx} {lry} '
|
system.run('gdal_translate -a_ullr {ulx} {uly} {lrx} {lry} '
|
||||||
|
@ -121,6 +123,7 @@ class ODMOrthoPhotoCell(ecto.Cell):
|
||||||
'-co BLOCKYSIZE=512 '
|
'-co BLOCKYSIZE=512 '
|
||||||
'-co NUM_THREADS=ALL_CPUS '
|
'-co NUM_THREADS=ALL_CPUS '
|
||||||
'-a_srs \"{proj}\" '
|
'-a_srs \"{proj}\" '
|
||||||
|
'--config GDAL_CACHEMAX {max_memory}%'
|
||||||
'{png} {tiff} > {log}'.format(**kwargs))
|
'{png} {tiff} > {log}'.format(**kwargs))
|
||||||
|
|
||||||
if args.crop > 0:
|
if args.crop > 0:
|
||||||
|
|
Ładowanie…
Reference in New Issue