kopia lustrzana https://github.com/OpenDroneMap/ODM
PNG creation, orthophoto flag fixes, refactoring
rodzic
4350e20d24
commit
589c47cb8c
|
@ -1075,8 +1075,11 @@ void OdmOrthoPhoto::renderPixel(int row, int col, float s, float t, const cv::Ma
|
||||||
b += static_cast<float>(tr[0]) * dl * db;
|
b += static_cast<float>(tr[0]) * dl * db;
|
||||||
b += static_cast<float>(bl[0]) * dr * dt;
|
b += static_cast<float>(bl[0]) * dr * dt;
|
||||||
b += static_cast<float>(br[0]) * dl * dt;
|
b += static_cast<float>(br[0]) * dl * dt;
|
||||||
|
|
||||||
photo_.at<cv::Vec<T, 4> >(row,col) = cv::Vec<T, 4>(static_cast<T>(b), static_cast<T>(g), static_cast<T>(r), static_cast<T>(maxRange<T>()));
|
photo_.at<cv::Vec<T, 4> >(row,col) = cv::Vec<T, 4>(static_cast<T>(b),
|
||||||
|
static_cast<T>(g),
|
||||||
|
static_cast<T>(r),
|
||||||
|
static_cast<T>(maxRange<T>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OdmOrthoPhoto::getBarycentricCoordinates(pcl::PointXYZ v1, pcl::PointXYZ v2, pcl::PointXYZ v3, float x, float y, float &l1, float &l2, float &l3) const
|
void OdmOrthoPhoto::getBarycentricCoordinates(pcl::PointXYZ v1, pcl::PointXYZ v2, pcl::PointXYZ v3, float x, float y, float &l1, float &l2, float &l3) const
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Cropper:
|
||||||
return os.path.join(self.storage_dir, '{}.{}'.format(self.files_prefix, suffix))
|
return os.path.join(self.storage_dir, '{}.{}'.format(self.files_prefix, suffix))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def crop(gpkg_path, geotiff_path, gdal_options, keep_original=True):
|
def crop(gpkg_path, geotiff_path, gdal_options, keep_original=True, warp_options=[]):
|
||||||
if not os.path.exists(gpkg_path) or not os.path.exists(geotiff_path):
|
if not os.path.exists(gpkg_path) or not os.path.exists(geotiff_path):
|
||||||
log.ODM_WARNING("Either {} or {} does not exist, will skip cropping.".format(gpkg_path, geotiff_path))
|
log.ODM_WARNING("Either {} or {} does not exist, will skip cropping.".format(gpkg_path, geotiff_path))
|
||||||
return geotiff_path
|
return geotiff_path
|
||||||
|
@ -44,12 +44,14 @@ class Cropper:
|
||||||
'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)),
|
||||||
|
'warpOptions': ' '.join(warp_options),
|
||||||
'max_memory': get_max_memory()
|
'max_memory': get_max_memory()
|
||||||
}
|
}
|
||||||
|
|
||||||
run('gdalwarp -cutline {gpkg_path} '
|
run('gdalwarp -cutline {gpkg_path} '
|
||||||
'-crop_to_cutline '
|
'-crop_to_cutline '
|
||||||
'{options} '
|
'{options} '
|
||||||
|
'{warpOptions} '
|
||||||
'{geotiffInput} '
|
'{geotiffInput} '
|
||||||
'{geotiffOutput} '
|
'{geotiffOutput} '
|
||||||
'--config GDAL_CACHEMAX {max_memory}%'.format(**kwargs))
|
'--config GDAL_CACHEMAX {max_memory}%'.format(**kwargs))
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
|
import os
|
||||||
from opendm import log
|
from opendm import log
|
||||||
from opendm import system
|
from opendm import system
|
||||||
|
from opendm.cropper import Cropper
|
||||||
|
from opendm.concurrency import get_max_memory
|
||||||
|
|
||||||
def get_orthophoto_vars(args):
|
def get_orthophoto_vars(args):
|
||||||
return {
|
return {
|
||||||
|
@ -20,4 +23,23 @@ def build_overviews(orthophoto_file):
|
||||||
system.run('gdaladdo -ro -r average '
|
system.run('gdaladdo -ro -r average '
|
||||||
'--config BIGTIFF_OVERVIEW IF_SAFER '
|
'--config BIGTIFF_OVERVIEW IF_SAFER '
|
||||||
'--config COMPRESS_OVERVIEW JPEG '
|
'--config COMPRESS_OVERVIEW JPEG '
|
||||||
'{orthophoto} 2 4 8 16'.format(**kwargs))
|
'{orthophoto} 2 4 8 16'.format(**kwargs))
|
||||||
|
|
||||||
|
def generate_png(orthophoto_file):
|
||||||
|
log.ODM_INFO("Generating PNG")
|
||||||
|
base, ext = os.path.splitext(orthophoto_file)
|
||||||
|
orthophoto_png = base + '.png'
|
||||||
|
|
||||||
|
system.run('gdal_translate -of png "%s" "%s" '
|
||||||
|
'--config GDAL_CACHEMAX %s%% ' % (orthophoto_file, orthophoto_png, get_max_memory()))
|
||||||
|
|
||||||
|
|
||||||
|
def post_orthophoto_steps(args, bounds_file_path, orthophoto_file):
|
||||||
|
if args.crop > 0:
|
||||||
|
Cropper.crop(bounds_file_path, orthophoto_file, get_orthophoto_vars(args), warp_options=['-dstalpha'])
|
||||||
|
|
||||||
|
if args.build_overviews:
|
||||||
|
build_overviews(orthophoto_file)
|
||||||
|
|
||||||
|
if args.orthophoto_png:
|
||||||
|
generate_png(orthophoto_file)
|
|
@ -8,7 +8,6 @@ from opendm import types
|
||||||
from opendm import gsd
|
from opendm import gsd
|
||||||
from opendm import orthophoto
|
from opendm import orthophoto
|
||||||
from opendm.concurrency import get_max_memory
|
from opendm.concurrency import get_max_memory
|
||||||
from opendm.cropper import Cropper
|
|
||||||
from opendm.cutline import compute_cutline
|
from opendm.cutline import compute_cutline
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,8 +97,10 @@ class ODMOrthoPhotoStage(types.ODM_Stage):
|
||||||
|
|
||||||
system.run('gdal_translate -a_ullr {ulx} {uly} {lrx} {lry} '
|
system.run('gdal_translate -a_ullr {ulx} {uly} {lrx} {lry} '
|
||||||
'{vars} '
|
'{vars} '
|
||||||
|
'-b 1 -b 2 -b 3 -mask 4 '
|
||||||
'-a_srs \"{proj}\" '
|
'-a_srs \"{proj}\" '
|
||||||
'--config GDAL_CACHEMAX {max_memory}% '
|
'--config GDAL_CACHEMAX {max_memory}% '
|
||||||
|
'--config GDAL_TIFF_INTERNAL_MASK YES '
|
||||||
'{input} {output} > {log}'.format(**kwargs))
|
'{input} {output} > {log}'.format(**kwargs))
|
||||||
|
|
||||||
bounds_file_path = os.path.join(tree.odm_georeferencing, 'odm_georeferenced_model.bounds.gpkg')
|
bounds_file_path = os.path.join(tree.odm_georeferencing, 'odm_georeferenced_model.bounds.gpkg')
|
||||||
|
@ -114,11 +115,7 @@ class ODMOrthoPhotoStage(types.ODM_Stage):
|
||||||
tmpdir=os.path.join(tree.odm_orthophoto, "grass_cutline_tmpdir"),
|
tmpdir=os.path.join(tree.odm_orthophoto, "grass_cutline_tmpdir"),
|
||||||
scale=0.25)
|
scale=0.25)
|
||||||
|
|
||||||
if args.crop > 0:
|
orthophoto.post_orthophoto_steps(args, bounds_file_path, tree.odm_orthophoto_tif)
|
||||||
Cropper.crop(bounds_file_path, tree.odm_orthophoto_tif, orthophoto_vars)
|
|
||||||
|
|
||||||
if args.build_overviews:
|
|
||||||
orthophoto.build_overviews(tree.odm_orthophoto_tif)
|
|
||||||
|
|
||||||
geotiffcreated = True
|
geotiffcreated = True
|
||||||
if not geotiffcreated:
|
if not geotiffcreated:
|
||||||
|
|
|
@ -283,14 +283,7 @@ class ODMMergeStage(types.ODM_Stage):
|
||||||
|
|
||||||
os.remove(merged_geotiff)
|
os.remove(merged_geotiff)
|
||||||
|
|
||||||
# Crop
|
orthophoto.post_orthophoto_steps(args, merged_bounds_file, tree.odm_orthophoto_tif)
|
||||||
if args.crop > 0:
|
|
||||||
Cropper.crop(merged_bounds_file, tree.odm_orthophoto_tif, orthophoto_vars)
|
|
||||||
|
|
||||||
# Overviews
|
|
||||||
if args.build_overviews:
|
|
||||||
orthophoto.build_overviews(tree.odm_orthophoto_tif)
|
|
||||||
|
|
||||||
elif len(all_orthos_and_cutlines) == 1:
|
elif len(all_orthos_and_cutlines) == 1:
|
||||||
# Simply copy
|
# Simply copy
|
||||||
log.ODM_WARNING("A single orthophoto/cutline pair was found between all submodels.")
|
log.ODM_WARNING("A single orthophoto/cutline pair was found between all submodels.")
|
||||||
|
|
|
@ -15,6 +15,11 @@ if [ "$1" = "--setup" ]; then
|
||||||
chown -R $3:$4 /code /var/www
|
chown -R $3:$4 /code /var/www
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Adding $2 to /etc/passwd"
|
||||||
|
echo "$2:x:$3:$4::/home/$2:/bin/bash" >> /etc/passwd
|
||||||
|
echo "Adding $2 to /etc/group"
|
||||||
|
echo "$2:x:$4:" >> /etc/group
|
||||||
|
|
||||||
echo "echo '' && echo '' && echo '' && echo '###################################' && echo 'ODM Dev Environment Ready. Hack on!' && echo '###################################' && echo '' && cd /code" > $HOME/.bashrc
|
echo "echo '' && echo '' && echo '' && echo '###################################' && echo 'ODM Dev Environment Ready. Hack on!' && echo '###################################' && echo '' && cd /code" > $HOME/.bashrc
|
||||||
|
|
||||||
# Install qt creator
|
# Install qt creator
|
||||||
|
@ -32,8 +37,8 @@ if [ "$1" = "--setup" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e "$HOME/liquidprompt" ]; then
|
if [ -e "$HOME/liquidprompt" ]; then
|
||||||
echo "export LP_PS1_PREFIX='(odmdev)'" >> $HOME/.bashrc
|
|
||||||
echo "source $HOME/liquidprompt/liquidprompt" >> $HOME/.bashrc
|
echo "source $HOME/liquidprompt/liquidprompt" >> $HOME/.bashrc
|
||||||
|
echo "export LP_PS1_PREFIX='(odmdev)'" >> $HOME/.bashrc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
|
@ -95,5 +100,5 @@ USER_ID=$(id -u)
|
||||||
GROUP_ID=$(id -g)
|
GROUP_ID=$(id -g)
|
||||||
USER=$(id -un)
|
USER=$(id -un)
|
||||||
xhost +
|
xhost +
|
||||||
docker run -ti --entrypoint bash --name odmdev -v $(pwd):/code -v "$DATA":/datasets -p $PORT:3000 --privileged -e DISPLAY -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 -v="/etc/passwd:/etc/passwd:ro" -v="/tmp/.X11-unix:/tmp/.X11-unix:rw" -v="$HOME/.odm-dev-home:/home/$USER" opendronemap/nodeodm -c "/code/start-dev-env.sh --setup $USER $USER_ID $GROUP_ID $QTC"
|
docker run -ti --entrypoint bash --name odmdev -v $(pwd):/code -v "$DATA":/datasets -p $PORT:3000 --privileged -e DISPLAY -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 -v="/tmp/.X11-unix:/tmp/.X11-unix:rw" -v="$HOME/.odm-dev-home:/home/$USER" opendronemap/nodeodm -c "/code/start-dev-env.sh --setup $USER $USER_ID $GROUP_ID $QTC"
|
||||||
exit 0
|
exit 0
|
Ładowanie…
Reference in New Issue