Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #This is an automatically generated script that will generate
- #panoramas from images
- #If these locations are incorrect, execute the buildScripts script again
- #imagePath is where images are stored to be stitched together. WebPath
- #is the server location for panoramas
- imagePath=/home/jason/Pictures/Panos
- webPath=/var/www/JMCTour/panos/
- #check if specified folders exist and user input is valid
- if [ ! -d "$imagePath" ]; then
- echo ""
- Images per folder:
- find . -maxdepth 1 -type f | sort -n -t _ -k 2 | while read -r file
- do
- echo "Current image: $curImage"
- echo "Current Stop: $curStop"
- mkdir $directory
- fi
- #if current image counter is less than the number of frames to be stitched
- #together, move current file to current stop directory
- if [[ $curImage -le $1 ]]; then
- mv $file $directory
- curImage=$((curImage+1))
- fi
- #if current image counter equals the number of frames to be stitched,
- #reset image counter and increment stop counter
- if [[ $curImage -eq $1 ]]; then
- curStop=$((curStop+1))
- curImage=0
- fi
- done
- #get the individual directories in the image storage folder
- dirlist=$(find . -mindepth 1 -maxdepth 1 -type d \( ! -name completed\)| sort -n)
- for dir in $dirlist
- do
- cd
- echo "Downsizing $(ls *.JPG| wc -l) images
- "
- curTime=$(date +"%T")
- echo "Current directory: $dir"
- #find all the JPG files
- fileList=$(find . -type f -name "*.JPG")
- #convert them to lower resolution
- for i in $fileList
- do
- echo "Converting $i to 1600 pixels wide" >> "$imagePath/$dir/log.txt"
- #convert $i -geometry 1600x $i
- done
- #stitch the panorama together
- ################################################################
- #Generate project file
- echo "Building project file" >> "$imagePath/$dir/log.txt"
- match-n-shift -o project.pto *.JPG >> "$imagePath/$dir/log.txt"
- #Find control points and ignore clouds
- echo "Searching for Control Points" >> "$imagePath/$dir/log.txt"
- cpfind -o project.pto --multirow project.pto >> "$imagePath/$dir/log.txt"
- ptoclean -v --output project.pto project.pto >> "$imagePath/$dir/log.txt"
- #Clean up control points
- echo "Cleanin gup points" >> "$imagePath/$dir/log.txt"
- cpclean -o project.pto project.pto >> "$imagePath/$dir/log.txt"
- #Find vertical lines
- echo "Verical Line Search" >> "$imagePath/$dir/log.txt"
- linefind -o project.pto project.pto >> "$imagePath/$dir/log.txt"
- #optimize position, straighten, photometric optimization and output projection
- echo "Optimizing, Straigntening File" >> "$imagePath/$dir/log.txt"
- autooptimiser -a -m -l -s -o project.pto project.pto >> "$imagePath/$dir/log.txt"
- #Calculate crop and size
- pano_modify --canvas=AUTO -o project.pto project.pto >> "$imagePath/$dir/log.txt"
- #Generate stitch makefile
- echo "Generating makefile"
- pto2mk -o project.mk -p pano project.pto >> "$imagePath/$dir/log.txt"
- make -j 4 -f project.mk all >> "$imagePath/$dir/log.txt"
- echo "Panorama Done\n" >> "$imagePath/$dir/log.txt"
- #Downsize and convert panorama
- #######################################################################
- image="pano.tif"
- #convert pano to jpg and get count of images in photo folder
- mogrify -format jpg $image >> "$imagePath/$dir/log.txt"
- num=$(ls -l "$webPath/photos" | wc -l)
- prefix=$((num+1))
- #convert full size pano to 1000 pixels high and rename with prefix number
- #move to /photos folder
- convert pano.jpg -geometry x1000 "$prefix-pano.jpg" >> "$imagePath/$dir/log.txt"
- mv "$prefix-pano.jpg" "$webPath/photos" >> "$imagePath/$dir/log.txt"
- #convert full size pano to 600 pixels wide and rename with prefix number
- #move to /thumbs folder
- convert pano.jpg -geometry 600x "$prefix-pano.jpg" >> "$imagePath/$dir/log.txt"
- mv "$prefix-pano.jpg" "$webPath/thumbs" >> "$imagePath/$dir/log.txt"
- #cleanup
- rm *.tif >> "$imagePath/$dir/log.txt"
- done
- #rinse and repeat
- for dir in $dirlist
- do
- mv $dir "completed"
- done
- cd ../
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement