index.html

DIY 360 degree video


About my DIY 360 degree camcorder

Video rig and related stitching problems

360 video recording and synchronisation

Audio.

Auto vs Manual White Balance.

360 degree video assembling.

Preparing series of images.

Geometric template.

Shrinking images.

Stitching images to 360 video frames.

RAM disk as a working directory.

Coverting frames to a 360 video and publishing.

Multiblend on my Linux box

Software



Google+ Youtube 360Cities





Stitching frames of a 360 video.

  # cd to the working dir
  cd ~/home_/500_dir
  
  najm=10000000000000000 ;
  for line in $( ls -d ./R* ) ; do
	najv=0 ;
	for line1 in $( ls ./$line | grep png | sed '1,$ s/ime_\(.*\)\.png/\1/' ) ; do
		if [[ $line1 -gt $najv ]] ; then 
			najv=$line1 ;
		fi	
	done
	if [[ $najv -lt $najm ]] ; then
		najm=$najv ;
	fi
  done
  
  # echo the maximum frame number available
  echo $najm ;
    
  # using the GPU
  # string 'out' is the prefix of partial temporary images
  nona -g -o out -m TIFF_m ./_base.pto
  
  # string 'out' is the prefix of partial temporary images
  # on a system without dedicated GPU - it's very slow ...
  nona -o out -m TIFF_m ./_base.pto 
  
    
  # nona and enblend examples 
  # string 'out' is the prefix of partial temporary images
  # 'img' is a directory for compiled 360 frames
  # names and locations of input images must be defined in the _base.pto
  # working sub-directory OUT_1 must be created 
  # the _base.pto file is on the directory 'hscript'
  
  # requirements
  
  which enblend-mp #( ... also multiblend, enblend)
  
  /usr/bin/enblend-mp
  /usr/bin/enblend
  /usr/bin/multiblend
  
  cd ~/home_/500_dir
  
  # working directory
  mkdir OUT_1
  cd OUT_1
  pwd
  
  /home/oo/home_/500_dir/OUT_1
  
  # _base.pto is on the directory 'hscript'
  ls ~/home_/500_dir/hscript/ | grep _base.pto
  
  _base.pto
  
  # directory for panoramas is named 'img'
  ls ~/home_/500_dir | grep img
  
  img
  
  # basic combination of nona + enblend on a single core, without GPU
  nona -o out -m TIFF_m ../hscript/_base.pto
  enblend -o ../img/name_of_the_frame.tif ./out*.tif
  
  # blending with the enblend-mp
  nona -o out -m TIFF_m ../hscript/_base.pto
  enblend-mp -o ../img/name_of_the_frame.tif ./out*.tif
  
  # blending with the enblend-mp + GPU
  nona -g -o out -m TIFF_m ../hscript/_base.pto
  enblend-mp --gpu -o ../img/name_of_the_frame.tif ./out*.tif
  
  # blending with the multiblend on a single core + a nona using GPU
  # I'm using this combination
  nona -g -o out -m TIFF_m ../hscript/_base.pto
  multiblend -o ../img/name_of_the_frame.tif ./out*.tif
    
  # requirements
  
  cd ~/home_/500_dir
  ls
  
  aaa R01 R02 R03 R04 R05 R06 R07 R08 R09 R10 hscript img OUT_1
  
  ls ./hscript
  
  _base.pto
  
  # generic _base.pto with strings 'ime_R' as samples for the 'sed' stream editor
  cat hscript/_base.pto | grep ime_R
  
  ...ime_R01...
  ...ime_R02...
  ...
  ...ime_R10...
    
  # This script is free software, and can be used, modified and
  # distributed under the terms of the GPL License: http://www.gnu.org/licenses/gpl.html .
  
  # basic loop to compile 360 frames
  # it's a Korn Shell Script, 'ksh ./aaa'
  # it's working only in the ksh shell
  
  # go home first
  cd ~/home_/500_dir
  
  # detect the maximum usable frame number
  najm=10000000000000000 ;
  for line in $( ls -d ./R* ) ; do
	najv=0 ;
	for line1 in $( ls ./$line | grep png | sed '1,$ s/ime_\(.*\)\.png/\1/' ) ; do
		if [[ $line1 -gt $najv ]] ; then 
			najv=$line1 ;
		fi	
	done
	if [[ $najv -lt $najm ]] ; then
		najm=$najv ;
	fi
  done
  echo $najm ;
  
  # step into the working dir
  cd ./OUT_1/ ;

  # loop
  i=1 ;
  while [[ $i -le $najm ]] ; do
  
	# editing the generic _base.pto in every loop
	cp ../hscript/_base.pto ./ ;
	for line in $( ls -d ../R* ) ; do
		line=$( echo $line | sed '1,$ s/\.\.\///' ) ;
		ukz="" ;
		ukz="sed -i '1,$ s/ime_$line\.png/\.\.\/$line\/ime_$i\.png/g' ./_base.pto" ;
		#echo $ukz ;
		eval $ukz ;
	done
	
	# assembling a panorama
	# my favorite combination of nona on GPU and multiblend
	echo $i" ("$najm")"
	nona -g -o out -m TIFF_m ./_base.pto
	multiblend -o ../img/stc_$i.tif ./out*.tif
	
	# cleaning the working place
	rm ./_base.pto
	rm ./out*.tif

	i=$(( $i+1 )) ;
  done
    
  # This script is free software, and can be used, modified and
  # distributed under the terms of the GPL License: http://www.gnu.org/licenses/gpl.html .
  
  # my loop to compile 360 frames
  # it's a Korn Shell Script, 'ksh ./aaa'
  # it's working only in the ksh shell
  
  # go home first
  cd ~/home_/500_dir
  
  # detect the maximum usable frame number
  najm=10000000000000000 ;
  for line in $( ls -d ./R* ) ; do
	najv=0 ;
	for line1 in $( ls ./$line | grep png | sed '1,$ s/ime_\(.*\)\.png/\1/' ) ; do
		if [[ $line1 -gt $najv ]] ; then 
			najv=$line1 ;
		fi	
	done
	if [[ $najv -lt $najm ]] ; then
		najm=$najv ;
	fi
  done
  echo $najm ;

  # number of CPU cores
  npr=6 ;

  # create working directories
  j=1 ;
  while [[ $j -le $npr ]] ; do
	  rm -r ./OUT_$j ;
	  mkdir ./OUT_$j ;
	  j=$(( $j+1 )) ;
  done

  # main loop
  i=1 ;
  while [[ $i -le $najm ]] ; do
  
	  # loop to utilise all CPU cores
	  j=1 ;
	  while [[ $j -le $npr ]] ; do
		  cd ./OUT_$j ;
		  
		  # editing the generic _base.pto in every loop
		  cp ../hscript/_base.pto ./ ;
		  for line in $( ls -d ../R* ) ; do
			  line=$( echo $line | sed '1,$ s/\.\.\///' ) ;
			  ukz="" ;
			  ukz="sed -i '1,$ s/ime_$line\.png/\.\.\/$line\/ime_$i\.png/g' ./_base.pto" ;
			  #echo $ukz ;
			  eval $ukz ;
		  done
		  
		  # run compiling of panoramic frame in the background
		  ( echo $i" ("$najm")" ; nona -g -o out -m TIFF_m ./_base.pto ; multiblend -o ../img/stc_$i.tif ./out*.tif ; rm ./_base.pto ; rm ./out*.tif) & # nona + GPU and multiblend
		  #( echo $i" ("$najm")" ; nona -g -o out -m TIFF_m ./_base.pto ; enblend-mp --gpu -o ../img/stc_$i.tif ./out*.tif ; rm ./_base.pto ; rm ./out*.tif) & # nona + GPU , enblend-mp + GPU
		  #( echo $i" ("$najm")" ; nona -o out -m TIFF_m ./_base.pto ; enblend -o ../img/stc_$i.tif ./out*.tif ; rm ./_base.pto ; rm ./out*.tif) & # nona and enblend
		  #( echo $i" ("$najm")" ; nona -o out -m TIFF_m ./_base.pto ; enblend-mp -o ../img/stc_$i.tif ./out*.tif ; rm ./_base.pto ; rm ./out*.tif) & # nona and enblend-mp
		  
		  cd .. ;
		  j=$(( $j+1 )) ;
		  i=$(( $i+1 )) ;
	  done

	  # wait background processes to stop
	  wait ;
	  # move compiled panoramas to a storage in a background
	  mv -v ./img/*.tif ./pic/ &
  done
    


Top of Page