kopia lustrzana https://github.com/OpenDroneMap/ODM
Merge branch 'gh-pages' of https://github.com/OpenDroneMap/BundlerTools into gh-pages
Former-commit-id: 9036561b43
gh-pages
commit
109e56f8d3
|
@ -1,6 +1,8 @@
|
|||
Steps to get OpenDroneMap running:
|
||||
==================================
|
||||
|
||||
(Requires Ubuntu 12.04 32-bit at this time. May also work with Ubuntu 12.04 64-bit)
|
||||
|
||||
Run install.sh to build.
|
||||
|
||||
``` ./install.sh ```
|
||||
|
@ -26,3 +28,7 @@ From Meshlab 1.3.3:
|
|||
* Filters:Remeshing, Simplification and Reconstruction:Surface Reconstruction Poisson
|
||||
* Texture the mesh
|
||||
* Parameterization + texturing from registered rasters
|
||||
|
||||
---
|
||||
|
||||
Example data can be found at https://github.com/OpenDroneMap/odm_data
|
|
@ -1,342 +0,0 @@
|
|||
#!/bin/bash/bin/bash
|
||||
|
||||
set -o nounset
|
||||
set -o errexit
|
||||
|
||||
echo
|
||||
echo " created by Daniel Schwarz/daniel.schwarz@topoi.org"
|
||||
echo " released under Creative Commons/CC-BY"
|
||||
echo " Attribution"
|
||||
echo
|
||||
echo " if the script doesn't finish properly"
|
||||
echo " (i.e. it doesn't print \"script finished\" at the end)"
|
||||
echo " please email me the content of the logs folder"
|
||||
echo
|
||||
echo
|
||||
echo " - script started - `date`"
|
||||
|
||||
## dest base path
|
||||
TOOLS_PATH="$PWD"
|
||||
|
||||
## paths for the tools
|
||||
TOOLS_BIN_PATH="$TOOLS_PATH/bin"
|
||||
TOOLS_INC_PATH="$TOOLS_PATH/include"
|
||||
TOOLS_LIB_PATH="$TOOLS_PATH/lib"
|
||||
TOOLS_SRC_PATH="$TOOLS_PATH/src"
|
||||
TOOLS_LOG_PATH="$TOOLS_PATH/logs"
|
||||
TOOLS_PATCHED_PATH="$TOOLS_PATH/patched_files"
|
||||
|
||||
## get sys vars
|
||||
ARCH=`uname -m`
|
||||
CORES=`grep -c processor /proc/cpuinfo`
|
||||
|
||||
## loacal dest paths
|
||||
if [ "$ARCH" = "i686" ]; then
|
||||
LIB_PATH="/lib"
|
||||
fi
|
||||
|
||||
if [ "$ARCH" = "x86_64" ]; then
|
||||
LIB_PATH="/lib64"
|
||||
fi
|
||||
INC_PATH="/usr/local/include"
|
||||
|
||||
## source paths
|
||||
BUNDLER_PATH="$TOOLS_SRC_PATH/bundler"
|
||||
CMVS_PATH="$TOOLS_SRC_PATH/cmvs"
|
||||
PMVS_PATH="$TOOLS_SRC_PATH/pmvs"
|
||||
CLAPACK_PATH="$TOOLS_SRC_PATH/clapack"
|
||||
VLFEAT_PATH="$TOOLS_SRC_PATH/vlfeat"
|
||||
PARALLEL_PATH="$TOOLS_SRC_PATH/parallel"
|
||||
PSR_PATH="$TOOLS_SRC_PATH/PoissonRecon"
|
||||
GRACLUS_PATH="$TOOLS_SRC_PATH/graclus"
|
||||
|
||||
## executables
|
||||
EXTRACT_FOCAL="$TOOLS_BIN_PATH/extract_focal.pl"
|
||||
MATCHKEYS="$TOOLS_BIN_PATH/KeyMatch"
|
||||
MATCHKEYSFULL="$TOOLS_BIN_PATH/KeyMatchFull"
|
||||
BUNDLER="$TOOLS_BIN_PATH/bundler"
|
||||
BUNDLE2PVMS="$TOOLS_BIN_PATH/Bundle2PMVS"
|
||||
CMVS="$TOOLS_BIN_PATH/cmvs"
|
||||
PMVS="$TOOLS_BIN_PATH/pmvs2"
|
||||
GENOPTION="$TOOLS_BIN_PATH/genOption"
|
||||
VLSIFT="$TOOLS_BIN_PATH/vlsift"
|
||||
PARALLEL="$TOOLS_BIN_PATH/parallel"
|
||||
PSR="$TOOLS_BIN_PATH/PoissonRecon"
|
||||
VLSIFT_TO_LOWESIFT="$TOOLS_BIN_PATH/convert_vlsift_to_lowesift.pl"
|
||||
|
||||
## prevents different (localized) output
|
||||
LC_ALL=C
|
||||
|
||||
## removing old stuff
|
||||
sudo rm -Rf "$TOOLS_BIN_PATH"
|
||||
sudo rm -Rf "$TOOLS_INC_PATH"
|
||||
sudo rm -Rf "$TOOLS_LIB_PATH"
|
||||
sudo rm -Rf "$TOOLS_SRC_PATH"
|
||||
sudo rm -Rf "$TOOLS_LOG_PATH"
|
||||
|
||||
## create needed directories
|
||||
mkdir -p "$TOOLS_BIN_PATH"
|
||||
mkdir -p "$TOOLS_INC_PATH"
|
||||
mkdir -p "$TOOLS_LIB_PATH"
|
||||
mkdir -p "$TOOLS_SRC_PATH"
|
||||
mkdir -p "$TOOLS_LOG_PATH"
|
||||
|
||||
## output sys info
|
||||
echo "System info:" > "$TOOLS_LOG_PATH/sysinfo.txt"
|
||||
uname -a > "$TOOLS_LOG_PATH/sysinfo.txt"
|
||||
|
||||
## install packages
|
||||
echo
|
||||
echo " > installing required packages"
|
||||
|
||||
echo " - updating"
|
||||
sudo yum update -y > "$TOOLS_LOG_PATH/apt-get_get.log" 2>&1
|
||||
|
||||
echo " - installing"
|
||||
yum install -y \
|
||||
cmake gcc gcc-c++ compat-gcc-32 compat-gcc-32-c++ gcc-gfortran perl ruby rubygems git \
|
||||
curl wget \
|
||||
unzip \
|
||||
ImageMagick jhead \
|
||||
libjpeg-devel boost-devel gsl-devel libX11-devel libXext-devel lapack-devel blas-devel \
|
||||
zlib-devel \
|
||||
opencv-devel \
|
||||
> "$TOOLS_LOG_PATH/apt-get_install.log" 2>&1
|
||||
|
||||
sudo gem install parallel > /dev/null 2>&1
|
||||
|
||||
echo " < done - `date`"
|
||||
|
||||
## downloading sources
|
||||
echo
|
||||
echo " > getting the sources"
|
||||
|
||||
## getting all archives if not already present; save them to .tmp and rename them after download
|
||||
while read target source
|
||||
do
|
||||
if [ ! -f "$target" ] ; then
|
||||
echo " - getting $source"
|
||||
|
||||
curl --progress-bar --insecure --location -o "$target.tmp" "$source"
|
||||
mv "$target.tmp" "$target"
|
||||
echo " - finished $target"
|
||||
echo
|
||||
else
|
||||
echo " - already downloaded $source"
|
||||
fi
|
||||
done <<EOF
|
||||
parallel.tar.bz2 http://ftp.gnu.org/gnu/parallel/parallel-20100922.tar.bz2
|
||||
clapack.tgz http://www.netlib.org/clapack/clapack-3.2.1-CMAKE.tgz
|
||||
bundler.zip http://phototour.cs.washington.edu/bundler/distr/bundler-v0.4-source.zip
|
||||
PoissonRecon.zip http://www.cs.jhu.edu/~misha/Code/PoissonRecon/Version2/PoissonRecon.zip
|
||||
vlfeat.tar.gz http://www.vlfeat.org/download/vlfeat-0.9.13-bin.tar.gz
|
||||
cmvs.tar.gz http://www.di.ens.fr/cmvs/cmvs-fix2.tar.gz
|
||||
graclus.tar.gz https://www.topoi.hu-berlin.de/graclus1.2.tar.gz
|
||||
EOF
|
||||
|
||||
echo " < done - `date`"
|
||||
|
||||
## unzipping sources
|
||||
echo
|
||||
echo " - unzipping sources"
|
||||
|
||||
for i in *.tar.bz2 ; do
|
||||
tar xjf "$i" > "$TOOLS_LOG_PATH/extract_$i.log" 2>&1 &
|
||||
done
|
||||
for i in *.tgz *.tar.gz ; do
|
||||
tar xzf "$i" > "$TOOLS_LOG_PATH/extract_$i.log" 2>&1 &
|
||||
done
|
||||
for i in *.zip ; do
|
||||
unzip "$i" > "$TOOLS_LOG_PATH/extract_$i.log" 2>&1 &
|
||||
done
|
||||
|
||||
wait
|
||||
|
||||
mv -f graclus1.2 "$GRACLUS_PATH"
|
||||
mv -f clapack-3.2.1-CMAKE "$CLAPACK_PATH"
|
||||
mv -f vlfeat-0.9.13 "$VLFEAT_PATH"
|
||||
mv -f bundler-v0.4-source "$BUNDLER_PATH"
|
||||
mv -f parallel-20100922 "$PARALLEL_PATH"
|
||||
mv -f PoissonRecon "$PSR_PATH"
|
||||
mv -f cmvs "$CMVS_PATH"
|
||||
|
||||
echo " < done - `date`"
|
||||
|
||||
|
||||
## copying patches
|
||||
echo
|
||||
echo " - copying patches"
|
||||
echo
|
||||
|
||||
for file in `find $TOOLS_PATCHED_PATH -type f -print` ; do
|
||||
cp $file $TOOLS_PATH/${file/$TOOLS_PATCHED_PATH/.}
|
||||
done
|
||||
|
||||
echo " < done - `date`"
|
||||
|
||||
|
||||
# building
|
||||
echo
|
||||
echo " - building"
|
||||
echo
|
||||
|
||||
sudo chown -R `id -u`:`id -g` *
|
||||
sudo chmod -R 777 *
|
||||
|
||||
|
||||
echo " > graclus"
|
||||
cd "$GRACLUS_PATH"
|
||||
|
||||
if [ "$ARCH" = "i686" ]; then
|
||||
sed -i "$GRACLUS_PATH/Makefile.in" -e "11c\COPTIONS = -DNUMBITS=32"
|
||||
fi
|
||||
|
||||
if [ "$ARCH" = "x86_64" ]; then
|
||||
sed -i "$GRACLUS_PATH/Makefile.in" -e "11c\COPTIONS = -DNUMBITS=64"
|
||||
fi
|
||||
|
||||
echo " - cleaning graclus"
|
||||
make clean > "$TOOLS_LOG_PATH/graclus_1_clean.log" 2>&1
|
||||
|
||||
echo " - building graclus"
|
||||
make -j > "$TOOLS_LOG_PATH/graclus_2_build.log" 2>&1
|
||||
|
||||
mkdir "$TOOLS_INC_PATH/metisLib"
|
||||
cp -f "$GRACLUS_PATH/metisLib/"*.h "$TOOLS_INC_PATH/metisLib/"
|
||||
|
||||
cp -f lib* "$TOOLS_LIB_PATH/"
|
||||
echo " < done - `date`"
|
||||
echo
|
||||
|
||||
echo " > poisson surface reconstruction "
|
||||
cd "$PSR_PATH"
|
||||
|
||||
sed -i "$PSR_PATH/Makefile" -e "21c\BIN = ./"
|
||||
|
||||
echo " - building poisson surface reconstruction"
|
||||
make -j > "$TOOLS_LOG_PATH/poisson_1_build.log" 2>&1
|
||||
|
||||
cp -f "$PSR_PATH/PoissonRecon" "$TOOLS_BIN_PATH/PoissonRecon"
|
||||
|
||||
echo " < done - `date`"
|
||||
echo
|
||||
|
||||
|
||||
echo " > parallel"
|
||||
cd "$PARALLEL_PATH"
|
||||
|
||||
echo " - configuring parallel"
|
||||
./configure > "$TOOLS_LOG_PATH/parallel_1_build.log" 2>&1
|
||||
|
||||
echo " - building paralel"
|
||||
make -j > "$TOOLS_LOG_PATH/parallel_2_build.log" 2>&1
|
||||
|
||||
cp -f src/parallel "$TOOLS_BIN_PATH/"
|
||||
|
||||
echo " < done - `date`"
|
||||
echo
|
||||
|
||||
|
||||
echo " > clapack"
|
||||
cd "$CLAPACK_PATH"
|
||||
cp make.inc.example make.inc
|
||||
|
||||
set +e
|
||||
echo " - building clapack"
|
||||
make all -j > "$TOOLS_LOG_PATH/clapack_1_build.log" 2>&1
|
||||
set -e
|
||||
|
||||
echo " - installing clapack"
|
||||
make lapack_install > "$TOOLS_LOG_PATH/clapack_2_install.log" 2>&1
|
||||
|
||||
cp -Rf INCLUDE "$INC_PATH/clapack"
|
||||
|
||||
echo " < done - `date`"
|
||||
echo
|
||||
|
||||
|
||||
echo " > vlfeat"
|
||||
cd "$VLFEAT_PATH"
|
||||
|
||||
echo " - installing vlfeat"
|
||||
|
||||
if [ "$ARCH" = "i686" ]; then
|
||||
cp -f "$VLFEAT_PATH/bin/glnx86/sift" "$TOOLS_BIN_PATH/vlsift"
|
||||
cp -f "$VLFEAT_PATH/bin/glnx86/libvl.so" "$TOOLS_LIB_PATH/"
|
||||
fi
|
||||
|
||||
if [ "$ARCH" = "x86_64" ]; then
|
||||
cp -f "$VLFEAT_PATH/bin/glnxa64/sift" "$TOOLS_BIN_PATH/vlsift"
|
||||
cp -f "$VLFEAT_PATH/bin/glnxa64/libvl.so" "$TOOLS_LIB_PATH/"
|
||||
fi
|
||||
echo " < done - `date`"
|
||||
echo
|
||||
|
||||
|
||||
echo " > cmvs"
|
||||
cd "$CMVS_PATH/program/main"
|
||||
|
||||
sed -i "$CMVS_PATH/program/main/genOption.cc" -e "5c\#include <stdlib.h>\n"
|
||||
sed -i "$CMVS_PATH/program/base/cmvs/bundle.cc" -e "3c\#include <numeric>\n"
|
||||
|
||||
sed -i "$CMVS_PATH/program/main/Makefile" -e "10c\#Your INCLUDE path (e.g., -I\/usr\/include)"
|
||||
sed -i "$CMVS_PATH/program/main/Makefile" -e "11c\YOUR_INCLUDE_PATH =-I$INC_PATH -I$TOOLS_INC_PATH"
|
||||
sed -i "$CMVS_PATH/program/main/Makefile" -e "13c\#Your metis directory (contains header files under graclus1.2/metisLib/)"
|
||||
sed -i "$CMVS_PATH/program/main/Makefile" -e "14c\YOUR_INCLUDE_METIS_PATH = -I$TOOLS_INC_PATH/metisLib/"
|
||||
sed -i "$CMVS_PATH/program/main/Makefile" -e "16c\#Your LDLIBRARY path (e.g., -L/usr/lib)"
|
||||
sed -i "$CMVS_PATH/program/main/Makefile" -e "17c\YOUR_LDLIB_PATH = -L$LIB_PATH -L$TOOLS_LIB_PATH"
|
||||
|
||||
if [ "$ARCH" = "i686" ]; then
|
||||
sed -i "$CMVS_PATH/program/main/Makefile" -e "22c\CXXFLAGS_CMVS = -O2 -Wall -Wno-deprecated -DNUMBITS=32 \\\\"
|
||||
sed -i "$CMVS_PATH/program/main/Makefile" -e '24c\ -fopenmp -DNUMBITS=32 ${OPENMP_FLAG}'
|
||||
fi
|
||||
|
||||
if [ "$ARCH" = "x86_64" ]; then
|
||||
sed -i "$CMVS_PATH/program/main/Makefile" -e "22c\CXXFLAGS_CMVS = -O2 -Wall -Wno-deprecated -DNUMBITS=64 \\\\"
|
||||
sed -i "$CMVS_PATH/program/main/Makefile" -e '24c\ -fopenmp -DNUMBITS=64 ${OPENMP_FLAG}'
|
||||
fi
|
||||
|
||||
echo " - cleaning cmvs"
|
||||
make clean > "$TOOLS_LOG_PATH/cmvs_1_clean.log" 2>&1
|
||||
|
||||
echo " - building cmvs"
|
||||
make -j > "$TOOLS_LOG_PATH/cmvs_2_build.log" 2>&1
|
||||
|
||||
echo " - make depend cmvs"
|
||||
sudo make depend > "$TOOLS_LOG_PATH/cmvs_3_depend.log" 2>&1
|
||||
|
||||
cp -f "$CMVS_PATH/program/main/cmvs" "$CMVS_PATH/program/main/pmvs2" "$CMVS_PATH/program/main/genOption" "$TOOLS_BIN_PATH/"
|
||||
cp -f "$CMVS_PATH/program/main/"*so* "$TOOLS_LIB_PATH/"
|
||||
echo " < done - `date`"
|
||||
echo
|
||||
|
||||
|
||||
echo " > bundler"
|
||||
cd "$BUNDLER_PATH"
|
||||
|
||||
sed -i "$BUNDLER_PATH/src/BundlerApp.h" -e "620c\ BundlerApp();"
|
||||
|
||||
echo " - cleaning bundler"
|
||||
make clean > "$TOOLS_LOG_PATH/bundler_1_clean.log" 2>&1
|
||||
|
||||
echo " - building bundler"
|
||||
make -j > "$TOOLS_LOG_PATH/bundler_2_build.log" 2>&1
|
||||
|
||||
cp -f "$BUNDLER_PATH/bin/Bundle2PMVS" "$BUNDLER_PATH/bin/Bundle2Vis" "$BUNDLER_PATH/bin/KeyMatchFull" "$BUNDLER_PATH/bin/KeyMatch" "$BUNDLER_PATH/bin/bundler" "$BUNDLER_PATH/bin/RadialUndistort" "$TOOLS_BIN_PATH/"
|
||||
|
||||
cp -f "$BUNDLER_PATH/lib/libANN_char.so" "$TOOLS_LIB_PATH/"
|
||||
echo " < done - `date`"
|
||||
echo
|
||||
|
||||
|
||||
cd "$TOOLS_PATH"
|
||||
|
||||
sudo install -o `id -u` -g `id -g` -m 644 -t "$LIB_PATH" lib/*.so
|
||||
sudo /sbin/ldconfig -v > "$TOOLS_LOG_PATH/ldconfig.log" 2>&1
|
||||
|
||||
sudo chown -R `id -u`:`id -g` *
|
||||
sudo chmod -R 777 *
|
||||
|
||||
echo " - script finished - `date`"
|
||||
|
||||
exit
|
426
run.rb
426
run.rb
|
@ -1,426 +0,0 @@
|
|||
#!/usr/bin/ruby
|
||||
# encoding: utf-8
|
||||
|
||||
require 'rubygems'
|
||||
require 'optparse'
|
||||
require 'pp'
|
||||
require 'parallel'
|
||||
require 'fileutils'
|
||||
|
||||
#alias :puts_original :puts
|
||||
#
|
||||
#def puts (*args)
|
||||
# puts_original(args)
|
||||
# puts_original(args)
|
||||
#end
|
||||
|
||||
$options = {}
|
||||
|
||||
optparse = OptionParser.new do|opts|
|
||||
opts.banner = "Usage: run.rb [options] <path>"
|
||||
|
||||
$options[:base_path] = "."
|
||||
|
||||
$options[:resize_to] = 1200
|
||||
opts.on('-r', '--resize-to int', "") do |param|
|
||||
$options[:resize_to] = param.to_i
|
||||
end
|
||||
|
||||
$options[:match_size] = 200
|
||||
opts.on('-m', '--match-size int', "") do |param|
|
||||
$options[:match_size] = param.to_i
|
||||
end
|
||||
|
||||
$options[:start_with] = "resize"
|
||||
opts.on('', '--start-with ', "values: \"resize\", \"getKeypoints\", \"match\", \"bundler\", \"cmvs\", \"pmvs\"") do |param|
|
||||
$options[:start_with] = param
|
||||
end
|
||||
|
||||
$options[:end_with] = "pmvs"
|
||||
opts.on('', '--end-with ', "values: \"resize\", \"getKeypoints\", \"match\", \"bundler\", \"cmvs\", \"pmvs\"") do |param|
|
||||
$options[:end_with] = param
|
||||
end
|
||||
|
||||
$options[:force_ccd] = false
|
||||
opts.on('', '--force-ccd float', "") do |param|
|
||||
$options[:force_ccd] = param.to_f
|
||||
end
|
||||
|
||||
|
||||
$options[:force_focal] = false
|
||||
opts.on('', '--force-focal float', "") do |param|
|
||||
$options[:force_focal] = param.to_f
|
||||
end
|
||||
|
||||
$options[:cmvs_max_images] = 100
|
||||
opts.on('', '--cmvs-max-images int', "") do |param|
|
||||
$options[:cmvs_max_images] = param.to_i
|
||||
end
|
||||
|
||||
$options[:matcher_ratio] = 0.6
|
||||
opts.on('', '--matcher-ratio float', "") do |param|
|
||||
$options[:matcher_ratio] = param.to_f
|
||||
end
|
||||
|
||||
$options[:matcher_threshold] = 2.0
|
||||
opts.on('', '--matcher-threshold float', "") do |param|
|
||||
$options[:matcher_threshold] = param.to_f
|
||||
end
|
||||
|
||||
$options[:pmvs_min_image_num] = 3
|
||||
opts.on('', '--pmvs-minImageNum n', "") do |param|
|
||||
$options[:pmvs_min_image_num] = param.to_i
|
||||
end
|
||||
$options[:pmvs_wsize] = 7
|
||||
opts.on('', '--pmvs-wsize int', "") do |param|
|
||||
$options[:pmvs_wsize] = param.to_i
|
||||
end
|
||||
$options[:pmvs_threshold] = 0.7
|
||||
opts.on('', '--pmvs-threshold float', "") do |param|
|
||||
$options[:pmvs_threshold] = param.to_f
|
||||
end
|
||||
$options[:pmvs_csize] = 2
|
||||
opts.on('', '--pmvs-csize int', "") do |param|
|
||||
$options[:pmvs_csize] = param.to_i
|
||||
end
|
||||
$options[:pmvs_level] = 1
|
||||
opts.on('', '--pmvs-level int', "") do |param|
|
||||
$options[:pmvs_level] = param.to_i
|
||||
end
|
||||
|
||||
opts.on( '-h', '--help', 'Display this screen' ) do
|
||||
puts opts
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
optparse.parse!
|
||||
|
||||
$options[:path_base] = ARGV[0] if ARGV.length == 1
|
||||
$options[:path_base] = File.expand_path($options[:path_base])
|
||||
|
||||
$options[:path_bin] = File.expand_path(File.dirname(__FILE__)) + "/bin"
|
||||
|
||||
require "#{File.expand_path(File.dirname(__FILE__))}/ccd_defs.rb"
|
||||
|
||||
begin
|
||||
puts " Configuration:"
|
||||
puts " bin_path = #{$options[:path_bin]}"
|
||||
puts " base_path = #{$options[:path_base]}"
|
||||
puts " "
|
||||
puts " start_with = #{$options[:start_with]}"
|
||||
puts " end_with = #{$options[:end_with]}"
|
||||
puts " "
|
||||
puts " resize_to = #{$options[:resize_to]}"
|
||||
puts " "
|
||||
puts " match_size = #{$options[:match_size]}"
|
||||
puts " matcher_ratio = #{$options[:matcher_ratio]}"
|
||||
puts " matcher_threshold = #{$options[:matcher_threshold]}"
|
||||
puts " "
|
||||
puts " cmvs_max_images = #{$options[:cmvs_max_images]}"
|
||||
puts " "
|
||||
puts " pmvs_threshold = #{$options[:pmvs_threshold]}"
|
||||
puts " pmvs_csize = #{$options[:pmvs_csize]}"
|
||||
puts " pmvs_level = #{$options[:pmvs_level]}"
|
||||
puts " pmvs_min_image_num = #{$options[:pmvs_min_image_num]}"
|
||||
puts " pmvs_wsize = #{$options[:pmvs_wsize]}"
|
||||
puts " "
|
||||
end
|
||||
|
||||
file_objects = []
|
||||
|
||||
source_files = `ls -1 #{$options[:path_base]} | egrep "\.[jJ]{1}[pP]{1}[eE]{0,1}[gG]{1}"`.split("\n")
|
||||
file_objects = Parallel.map(source_files) { |source_file|
|
||||
file_object = Hash.new
|
||||
|
||||
file_object[:file_name] = "#{source_file}"
|
||||
file_object[:file_basename] = "#{source_file}".sub(/\.[^\.]+$/, "")
|
||||
file_object[:path_src] = "#{$options[:path_base]}/#{source_file}"
|
||||
|
||||
jhead_text = `jhead #{file_object[:path_src]}`
|
||||
file_object[:jhead] = Hash.new
|
||||
|
||||
jhead_text.split("\n").each { |jhead_line|
|
||||
jhead_parts = jhead_line.split(/\ +:\ /)
|
||||
|
||||
file_object[:jhead][jhead_parts[0].to_sym] = jhead_parts[1] if jhead_parts.length == 2
|
||||
}
|
||||
|
||||
file_object[:model_id] = "#{file_object[:jhead][:'Camera make']} #{file_object[:jhead][:'Camera model']}"
|
||||
|
||||
file_object[:width],file_object[:height] = [file_object[:jhead][:Resolution].split(" x ")[0].to_i, file_object[:jhead][:Resolution].split(" x ")[1].to_i] if file_object[:jhead][:Resolution]
|
||||
|
||||
|
||||
if file_object[:jhead][:'CCD width']
|
||||
file_object[:ccd] = file_object[:jhead][:'CCD width'][/([\.0-9]+)/].to_f
|
||||
end
|
||||
|
||||
if file_object[:jhead][:'Focal length']
|
||||
file_object[:focal] = file_object[:jhead][:'Focal length'][/([\.0-9]+)/].to_f
|
||||
end
|
||||
|
||||
file_object[:ccd] = $ccd_widths[file_object[:model_id].to_sym] unless file_object[:ccd]
|
||||
|
||||
file_object[:focal] = $options[:force_focal] if $options[:force_focal]
|
||||
file_object[:ccd] = $options[:force_ccd] if $options[:force_ccd]
|
||||
|
||||
if file_object[:focal] && file_object[:ccd] && file_object[:width] && file_object[:height]
|
||||
file_object[:focal_px] = (file_object[:focal] / file_object[:ccd]) * [[file_object[:width], file_object[:height]].max.to_f, $options[:resize_to].to_f].min
|
||||
puts "#{file_object[:path_src]} – using image with ccd width: #{file_object[:ccd]} and focal length: #{file_object[:focal]}"
|
||||
file_object
|
||||
else
|
||||
if !file_object[:ccd]
|
||||
puts "no ccd width found for #{file_object[:model_id]}"
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
file_objects = file_objects.select {|file_object| file_object}
|
||||
|
||||
puts "found #{file_objects.length} usable objects"
|
||||
|
||||
def get_feature_count (bin_file_name)
|
||||
io = File.open(bin_file_name, "rb")
|
||||
feature_count = io.read(4).unpack("L")
|
||||
io.close
|
||||
|
||||
feature_count.first.to_i
|
||||
end
|
||||
|
||||
def match?(i, j, file_object_i, file_object_j, path)
|
||||
pairwise_match = "#{path}/#{i}-#{j}.txt"
|
||||
|
||||
!File.exists?(pairwise_match)
|
||||
end
|
||||
def match (i, j, file_object_i, file_object_j, path, index)
|
||||
pairwise_match = "#{path}/.#{i}-#{j}.txt"
|
||||
done_pairwise_match = "#{path}/#{i}-#{j}.txt"
|
||||
|
||||
file_object_i_key = "#{path}/../#{file_object_i[:file_basename]}.key"
|
||||
file_object_j_key = "#{path}/../#{file_object_j[:file_basename]}.key"
|
||||
|
||||
feature_count_i = get_feature_count("#{path}/../#{file_object_i[:file_basename]}.key.bin")
|
||||
feature_count_j = get_feature_count("#{path}/../#{file_object_j[:file_basename]}.key.bin")
|
||||
|
||||
`touch '#{pairwise_match}' && '#{$options[:path_bin]}/KeyMatch' '#{file_object_i_key}' '#{file_object_j_key}' '#{pairwise_match}' #{$options[:matcher_ratio]} #{$options[:matcher_threshold]}` unless File.exists?(pairwise_match)
|
||||
matches =`cat '#{pairwise_match}' | wc -l`.to_i
|
||||
|
||||
if matches > 0
|
||||
puts "%6d / %6d - %6.2f%% matches between #{file_object_i[:file_name]}, #{file_object_j[:file_name]}" % [$prog_start + index + 1, $prog_total, matches.to_f*100/([feature_count_i, feature_count_j].min)]
|
||||
end
|
||||
|
||||
FileUtils.mv(pairwise_match, done_pairwise_match)
|
||||
end
|
||||
|
||||
def get_keypoints_for_file?(file_object, path, size)
|
||||
path_matching_base_name = "#{path}/#{file_object[:file_basename]}"
|
||||
path_matching_key_bin = "#{path_matching_base_name}.key.bin"
|
||||
path_matching_key_gz = "#{path_matching_base_name}.key.gz"
|
||||
path_matching_jpg = "#{path_matching_base_name}.jpg"
|
||||
|
||||
!(File.exists?(path_matching_jpg) && File.exists?(path_matching_key_bin) && File.exists?(path_matching_key_gz))
|
||||
end
|
||||
def get_keypoints_for_file (file_object, path, size, index)
|
||||
path_matching_base_name = "#{path}/.#{file_object[:file_basename]}"
|
||||
path_matching_jpg = "#{path_matching_base_name}.jpg"
|
||||
path_matching_pgm = "#{path_matching_base_name}.pgm"
|
||||
path_matching_sift = "#{path_matching_base_name}.key.sift"
|
||||
path_matching_key = "#{path_matching_base_name}.key"
|
||||
path_matching_key_bin = "#{path_matching_base_name}.key.bin"
|
||||
path_matching_key_gz = "#{path_matching_base_name}.key.gz"
|
||||
|
||||
done_path_matching_base_name = "#{path}/#{file_object[:file_basename]}"
|
||||
done_path_matching_key_bin = "#{done_path_matching_base_name}.key.bin"
|
||||
done_path_matching_key_gz = "#{done_path_matching_base_name}.key.gz"
|
||||
done_path_matching_jpg = "#{done_path_matching_base_name}.jpg"
|
||||
|
||||
|
||||
`convert -format jpg -resize #{size}x#{size} -quality 100 '#{file_object[:path_src]}' '#{path_matching_jpg}'`
|
||||
`convert -format pgm -resize #{size}x#{size} -quality 100 '#{file_object[:path_src]}' '#{path_matching_pgm}'`
|
||||
|
||||
`'#{$options[:path_bin]}/vlsift' '#{path_matching_pgm}' -o '#{path_matching_sift}'`
|
||||
|
||||
`perl '#{$options[:path_bin]}/../convert_vlsift_to_lowesift.pl' '#{path_matching_base_name}'`
|
||||
|
||||
`gzip -f '#{path_matching_key}' && rm -f '#{path_matching_sift}' && rm -f '#{path_matching_pgm}'`
|
||||
|
||||
feature_count = get_feature_count(path_matching_key_bin)
|
||||
|
||||
puts "%6d / %6d - got #{feature_count} keypoints from #{file_object[:file_name]} @ #{size}px" % [$prog_start + index + 1, $prog_total]
|
||||
|
||||
FileUtils.mv(path_matching_key_bin , done_path_matching_key_bin )
|
||||
FileUtils.mv(path_matching_key_gz , done_path_matching_key_gz )
|
||||
FileUtils.mv(path_matching_jpg , done_path_matching_jpg )
|
||||
end
|
||||
|
||||
if file_objects.length > 0
|
||||
job_options = Hash.new
|
||||
|
||||
job_options[:path] = "#{$options[:path_base]}/__reconstruction-#{$options[:resize_to]}"
|
||||
|
||||
Dir::mkdir(job_options[:path]) unless File.directory?(job_options[:path])
|
||||
|
||||
### MATCHING
|
||||
|
||||
job_options[:path_matching] = "#{$options[:path_base]}/__pre_matching-#{$options[:match_size]}"
|
||||
job_options[:path_matchinglarge] = "#{job_options[:path]}"
|
||||
job_options[:path_matching_pairs] = "#{$options[:path_base]}/__pre_matching-#{$options[:match_size]}/_pairs"
|
||||
job_options[:path_matchinglarge_pairs] = "#{job_options[:path_matchinglarge]}/_pairs"
|
||||
|
||||
Dir::mkdir(job_options[:path_matching]) unless File.directory?(job_options[:path_matching])
|
||||
Dir::mkdir(job_options[:path_matchinglarge]) unless File.directory?(job_options[:path_matchinglarge])
|
||||
Dir::mkdir(job_options[:path_matching_pairs]) unless File.directory?(job_options[:path_matching_pairs])
|
||||
Dir::mkdir(job_options[:path_matchinglarge_pairs]) unless File.directory?(job_options[:path_matchinglarge_pairs])
|
||||
|
||||
|
||||
|
||||
puts "\n**\n** GETTING KEYPOINTS SMALL VERSION\n** #{Time.now}\n\n"
|
||||
|
||||
file_objects_todo = file_objects.select { |file_object| get_keypoints_for_file?(file_object, job_options[:path_matching], $options[:match_size]) }
|
||||
|
||||
$prog_start = (file_objects.length - file_objects_todo.length)
|
||||
$prog_total = file_objects.length
|
||||
Parallel.each_with_index(file_objects_todo) { |file_object, index| get_keypoints_for_file(file_object, job_options[:path_matching], $options[:match_size], index) }
|
||||
|
||||
puts (file_objects_todo.empty? ? "nothing to do" : "done")
|
||||
|
||||
|
||||
|
||||
puts "\n**\n** MATCHING SMALL VERSION\n** #{Time.now}\n\n"
|
||||
|
||||
match_indeces = Array.new
|
||||
|
||||
(0...file_objects.length).inject(match_indeces) { |memo, i|
|
||||
(i+1...file_objects.length).inject(memo) { |memo, j|
|
||||
memo.push([i, j])
|
||||
}
|
||||
}
|
||||
|
||||
match_indeces_todo = match_indeces.select { |i,j| match?(i, j, file_objects[i], file_objects[j], job_options[:path_matching_pairs]) }
|
||||
|
||||
$prog_start = (match_indeces.length - match_indeces_todo.length)
|
||||
$prog_total = match_indeces.length
|
||||
Parallel.each_with_index(match_indeces_todo) { |(i, j), index|
|
||||
match(i, j, file_objects[i], file_objects[j], job_options[:path_matching_pairs], index)
|
||||
}
|
||||
|
||||
puts (match_indeces_todo.empty? ? "nothing to do" : "done")
|
||||
|
||||
|
||||
|
||||
puts "\n**\n** GETTING KEYPOINTS BIG VERSION\n** #{Time.now}\n\n"
|
||||
|
||||
file_objects_todo = file_objects.select { |file_object| get_keypoints_for_file?(file_object, job_options[:path_matchinglarge], $options[:resize_to]) }
|
||||
|
||||
$prog_start = (file_objects.length - file_objects_todo.length)
|
||||
$prog_total = file_objects.length
|
||||
Parallel.each_with_index(file_objects_todo, :in_processes => 4) { |file_object, index| get_keypoints_for_file(file_object, job_options[:path_matchinglarge], $options[:resize_to], index) }
|
||||
|
||||
puts (file_objects_todo.empty? ? "nothing to do" : "done")
|
||||
|
||||
|
||||
|
||||
puts "\n**\n** MATCHING BIG VERSION\n** #{Time.now}\n\n"
|
||||
|
||||
matches_files = `ls -1 #{job_options[:path_matching_pairs]} | egrep "\.txt"`.split("\n").map {|e| (e.sub("\.txt", "").split("-")).map{|n| n.to_i} }
|
||||
matches_files = matches_files.select {|i,j| File.size?("#{job_options[:path_matching_pairs]}/#{i}-#{j}.txt") }
|
||||
|
||||
matches_files_todo = matches_files.select { |i, j| match?(i, j, file_objects[i], file_objects[j], job_options[:path_matchinglarge_pairs]) }
|
||||
|
||||
$prog_start = (matches_files.length - matches_files_todo.length)
|
||||
$prog_total = matches_files.length
|
||||
Parallel.each_with_index(matches_files_todo) { |(i, j), index| match(i, j, file_objects[i], file_objects[j], job_options[:path_matchinglarge_pairs], index) }
|
||||
|
||||
puts (matches_files_todo.empty? ? "nothing to do" : "done")
|
||||
|
||||
|
||||
|
||||
puts "\n**\n** RUNNING BUNDLER\n** #{Time.now}\n\n"
|
||||
|
||||
job_options[:path_bundle] = "#{job_options[:path]}/bundle"
|
||||
job_options[:path_pmvs] = "#{job_options[:path]}/pmvs"
|
||||
job_options[:path_pmvs_txt] = "#{job_options[:path]}/pmvs/txt"
|
||||
job_options[:path_pmvs_visualize] = "#{job_options[:path]}/pmvs/visualize"
|
||||
job_options[:path_pmvs_models] = "#{job_options[:path]}/pmvs/models"
|
||||
|
||||
job_options[:file_bundler_filelist] = "#{job_options[:path]}/_bundler_list.txt"
|
||||
job_options[:file_bundler_options] = "#{job_options[:path]}/_bundler_options.txt"
|
||||
job_options[:file_bundler_matches_init] = "#{job_options[:path]}/_bundler_matches.init.txt"
|
||||
|
||||
Dir::mkdir(job_options[:path_bundle]) unless File.directory?(job_options[:path_bundle])
|
||||
Dir::mkdir(job_options[:path_pmvs]) unless File.directory?(job_options[:path_pmvs])
|
||||
Dir::mkdir(job_options[:path_pmvs_txt]) unless File.directory?(job_options[:path_pmvs_txt])
|
||||
Dir::mkdir(job_options[:path_pmvs_visualize]) unless File.directory?(job_options[:path_pmvs_visualize])
|
||||
Dir::mkdir(job_options[:path_pmvs_models]) unless File.directory?(job_options[:path_pmvs_models])
|
||||
|
||||
# files_for_bundler = `ls -1 #{job_options[:path_matchinglarge]} | egrep "\.[jJ]{1}[pP]{1}[eE]{0,1}[gG]{1}$"`.split("\n").sort
|
||||
# files_for_bundler = file_objects.select { |file_object| files_for_bundler.include?(file_object[:file_name]) }
|
||||
|
||||
File.open(job_options[:file_bundler_filelist], 'w') do |file|
|
||||
file_objects.each { |file_object|
|
||||
file.puts "./%s 0 %0.5f" % ["#{file_object[:file_basename]}.jpg", file_object[:focal_px]]
|
||||
}
|
||||
end
|
||||
|
||||
File.open(job_options[:file_bundler_options], 'w') do |file|
|
||||
file.puts "--match_table _bundler_matches.init.txt"
|
||||
file.puts "--output bundle.out"
|
||||
file.puts "--output_all bundle_"
|
||||
file.puts "--output_dir bundle"
|
||||
file.puts "--variable_focal_length"
|
||||
file.puts "--use_focal_estimate"
|
||||
file.puts "--constrain_focal"
|
||||
file.puts "--constrain_focal_weight 0.01"
|
||||
file.puts "--estimate_distortion"
|
||||
file.puts "--run_bundle"
|
||||
end
|
||||
|
||||
File.open(job_options[:file_bundler_matches_init], 'w') do |file|
|
||||
matches_files = `ls -1 #{job_options[:path_matchinglarge_pairs]} | egrep "\.txt"`.split("\n").map {|e| (e.sub("\.txt", "").split("-")).map{|n| n.to_i} }
|
||||
matches_files = matches_files.sort
|
||||
|
||||
matches_files.each {|i,j|
|
||||
if File.size?("#{job_options[:path_matchinglarge_pairs]}/#{i}-#{j}.txt")
|
||||
file.puts "#{i} #{j}"
|
||||
file.puts File.read("#{job_options[:path_matchinglarge_pairs]}/#{i}-#{j}.txt")
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
Dir.chdir("#{job_options[:path]}")
|
||||
|
||||
system("'#{$options[:path_bin]}/bundler' '#{job_options[:file_bundler_filelist]}' --options_file '#{job_options[:file_bundler_options]}'")
|
||||
|
||||
puts "\n**\n** RUNNING BUNDLE2PMVS\n** #{Time.now}\n\n"
|
||||
system("'#{$options[:path_bin]}/Bundle2PMVS' '#{job_options[:file_bundler_filelist]}' 'bundle/bundle.out'")
|
||||
|
||||
puts "\n**\n** RUNNING RADIALUNDISTORT\n** #{Time.now}\n\n"
|
||||
system("'#{$options[:path_bin]}/RadialUndistort' '#{job_options[:file_bundler_filelist]}' 'bundle/bundle.out' 'pmvs'")
|
||||
|
||||
i = 0
|
||||
|
||||
file_objects.each { |file_object|
|
||||
if File.exist?("#{job_options[:path]}/pmvs/#{file_object[:file_basename]}.rd.jpg")
|
||||
nr = "%08d" % [i]
|
||||
|
||||
puts "#{job_options[:path]}/pmvs/#{file_object[:file_basename]}.rd.jpg", "#{job_options[:path]}/pmvs/visualize/#{nr}.jpg"
|
||||
|
||||
FileUtils.mv("#{job_options[:path]}/pmvs/#{file_object[:file_basename]}.rd.jpg", "#{job_options[:path]}/pmvs/visualize/#{nr}.jpg")
|
||||
FileUtils.mv("#{job_options[:path]}/pmvs/#{nr}.txt", "#{job_options[:path]}/pmvs/txt/#{nr}.txt")
|
||||
|
||||
i += 1
|
||||
end
|
||||
}
|
||||
|
||||
puts "\n**\n** RUNNING CMVS\n** #{Time.now}\n\n"
|
||||
system("'#{$options[:path_bin]}/cmvs' pmvs/ #{$options[:cmvs_max_images]} #{Parallel.processor_count}");
|
||||
|
||||
puts "\n**\n** GENOPTION CMVS\n** #{Time.now}\n\n"
|
||||
system("'#{$options[:path_bin]}/genOption' pmvs/ #{$options[:pmvs_level]} #{$options[:pmvs_csize]} #{$options[:pmvs_threshold]} #{$options[:pmvs_wsize]} #{$options[:pmvs_min_image_num]} #{Parallel.processor_count}");
|
||||
|
||||
puts "\n**\n** GENOPTION PMVS\n** #{Time.now}\n\n"
|
||||
system("'#{$options[:path_bin]}/pmvs2' pmvs/ option-0000");
|
||||
|
||||
end
|
||||
end
|
Ładowanie…
Reference in New Issue