Even more modularization. Working on using locals vs. globals in the new internal functions as best as at all possible.
parent
369d928368
commit
054d282ba6
44
convmlv.sh
44
convmlv.sh
|
@ -1,7 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
VERSION="2.1.0a1" #Version string.
|
||||
INPUT_ARGS=$(echo "$@") #The original input argument string.
|
||||
#desc: Main file - uses convmlv components as needed.
|
||||
|
||||
#~ The MIT License (MIT)
|
||||
|
||||
|
@ -25,6 +24,9 @@ INPUT_ARGS=$(echo "$@") #The original input argument string.
|
|||
#~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
#~ SOFTWARE.
|
||||
|
||||
VERSION="2.1.0a2" #Version string.
|
||||
INPUT_ARGS=$(echo "$@") #The original input argument string.
|
||||
|
||||
if [ $# == 0 ]; then #No given arguments.
|
||||
echo -e "\033[0;31m\033[1mNo arguments given.\033[0m\n\tType 'convmlv -h/--help' to see help page, or 'convmlv -v/--version' for current version string."
|
||||
fi
|
||||
|
@ -214,6 +216,8 @@ source "$SRC_PATH/helpers/utility.sh"
|
|||
source "$SRC_PATH/core/parsing.sh"
|
||||
source "$SRC_PATH/helpers/error.sh"
|
||||
source "$SRC_PATH/core/develop.sh"
|
||||
source "$SRC_PATH/core/proc.sh"
|
||||
source "$SRC_PATH/imgProcessing/imgMath.sh"
|
||||
|
||||
|
||||
#OPTION PARSING FROM CONFIG AND CLI - same as at bottom of develop().
|
||||
|
@ -259,7 +263,41 @@ case "$PROGRAM" in
|
|||
;;
|
||||
develop)
|
||||
checkDeps #Check static dependencies.
|
||||
develop #Do the development step, using the globals that exist.
|
||||
|
||||
ARG_INC=0
|
||||
for ARG in "${FILE_ARGS_ARRAY[@]}"; do #Go through FILE_ARGS_ARRAY array, copied from parsed $@ because $@ is going to be changing on 'set --'
|
||||
#Check the argument
|
||||
fReturn=$(checkArg "$ARG")
|
||||
if [[ $fReturn = "false" ]]; then continue; fi
|
||||
|
||||
#Evaluate local configuration file for file-specific blocks.
|
||||
parseConf "$LCONFIG" true
|
||||
|
||||
#Do the development step, using the globals that exist.
|
||||
develop "$ARG"
|
||||
|
||||
#RESET ARGS & REPARSE OPTIONS - same as in convmlv.sh.
|
||||
#Big parse/reparse, making sure global, local, command line options all override each other correctly.
|
||||
set -- $INPUT_ARGS #Reset the argument input for reparsing.
|
||||
setDefaults #Hard set/reset all the lovely globals.
|
||||
OPTIND=1 #Reset argument parsing.
|
||||
|
||||
parseConf "$GCONFIG" false #Parse global config file.
|
||||
|
||||
parseArgs "$@" #First, parse all cli args. We only need the -C flag, but that forces us to just parse everything.
|
||||
shift $((OPTIND-1)) #Shift past all of the options to the file arguments.
|
||||
|
||||
parseConf "$LCONFIG" false #Parse local config file.
|
||||
set -- $INPUT_ARGS #Reset $@ for cli option reparsing.
|
||||
OPTIND=1 #To reset argument parsing, we must set OPTIND to 1.
|
||||
|
||||
parseArgs "$@" #Reparse cli to overwrite local config options.
|
||||
shift $((OPTIND-1)) #Shift past all of the options to the file arguments.
|
||||
OPTIND=1 #Reset argument index.
|
||||
|
||||
#Decrement the arguments that are left.
|
||||
let ARG_INC++
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
1264
src/core/develop.sh
1264
src/core/develop.sh
File diff suppressed because it is too large
Load Diff
|
@ -1,3 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
#desc: All config and command line parsing happens here.
|
||||
|
||||
parseConf() {
|
||||
file=$1 #The File to Parse
|
||||
|
|
|
@ -0,0 +1,247 @@
|
|||
#!/bin/bash
|
||||
|
||||
#desc: The bulk image processing operations; from dcraw, to ffmpeg, to parallel functions.
|
||||
|
||||
dcrawOpt() {
|
||||
#usage: dcrawOpt | >>ppm data
|
||||
#desc: Find, develop, and splay raw DNG data as ppm, ready to be processed.
|
||||
|
||||
find "${TMP}" -maxdepth 1 -iname "*.dng" -print0 | sort -z | tr -d "\n" | xargs -0 \
|
||||
$DCRAW -c -q $DEMO_MODE $FOUR_COLOR -k $BLACK_LEVEL $SATPOINT $BADPIXELS $WHITE -H $HIGHLIGHT_MODE -g $GAMMA $WAVE_NOISE -o $SPACE $DEPTH
|
||||
} #Is prepared to pipe all the files in TMP outwards.
|
||||
|
||||
dcrawImg() { #
|
||||
#usage: dcrawImg | >>ppm data
|
||||
#desc: Find and splay image sequence data as ppm, ready to be processed by ffmpeg.
|
||||
#note: Not working well. IM has trouble keeping itself linear. Kinda slow b/c ppm conversion, even if it worked...
|
||||
|
||||
find "${SEQ}" -maxdepth 1 -iname "*.${IMG_FMT}" -print0 | sort -z | xargs -0 -I {} convert '{}' -set colorspace sRGB -colorspace RGB ppm:-
|
||||
} #Finds all images, prints to stdout, without any operations, using convert. ppm conversion is inevitably slow, however...
|
||||
|
||||
mov_main() {
|
||||
#usage: >>ppm data | mov_main
|
||||
#desc: Creates the primary, high quality movie MOV file from input ppm data.
|
||||
|
||||
ffmpeg -f image2pipe -vcodec ppm -r $FPS -i pipe:0 \
|
||||
-loglevel panic -stats $SOUND -vcodec prores_ks -pix_fmt rgb48be -n -r $FPS -profile:v 4444 -alpha_bits 0 -vendor ap4h $V_FILTERS $SOUND_ACTION "${VID}_hq.mov"
|
||||
} #-loglevel panic -stats
|
||||
|
||||
mov_prox() {
|
||||
#usage: >>ppm data | mov_prox
|
||||
#desc: Creates the lower quality movie MP4 file from input ppm data.
|
||||
|
||||
ffmpeg -f image2pipe -vcodec ppm -r $FPS -i pipe:0 \
|
||||
-loglevel panic -stats $SOUND -c:v libx264 -n -r $FPS -preset fast $V_FILTERS_PROX -crf 23 -c:a mp3 "${VID}_lq.mp4"
|
||||
} #The option -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" fixes when x264 is unhappy about non-2 divisible dimensions.
|
||||
|
||||
mov_main_img() {
|
||||
#usage: mov_main_img
|
||||
#desc: Creates the primary, high quality movie MOV file from the image sequence.
|
||||
|
||||
ffmpeg -start_number $FRAME_START -loglevel panic -stats -f image2 -i ${SEQ}/${TRUNC_ARG}_%06d.${IMG_FMT} $SOUND -vcodec prores_ks \
|
||||
-pix_fmt rgb48le -n -r $FPS -profile:v 4444 -alpha_bits 0 -vendor ap4h $V_FILTERS $SOUND_ACTION "${VID}_hq.mov"
|
||||
}
|
||||
|
||||
mov_prox_img() {
|
||||
#usage: mov_prox_img
|
||||
#desc: Creates the lower quality movie MP4 file from the image sequence.
|
||||
|
||||
ffmpeg -start_number $FRAME_START -loglevel panic -stats -f image2 -i ${SEQ}/${TRUNC_ARG}_%06d.${IMG_FMT} $V_FILTERS_PROX $SOUND -c:v libx264 \
|
||||
-n -r $FPS -preset veryfast -crf 21 -c:a mp3 -b:a 320k "${VID}_lq.mp4"
|
||||
}
|
||||
|
||||
#PARALLEL FUNCTIONS
|
||||
|
||||
dng_par() {
|
||||
#usage: dng_par 1${} (frame range) 2$MLV_DUMP 3$REAL_MLV 4$DARK_PROC 5$no_data 6$smooth 7$TMP 8$FRAME_END 9$TRUNC_ARG 10$FRAME_START
|
||||
#arglength: Takes 10 args.
|
||||
#desc: Called by xargs; is capable of dumping DNGs with the mlv_dump backend in parallel by being run in a subshell.
|
||||
#note: Unfortunately, this means the entire relevant environment needs to be passed along too.
|
||||
|
||||
range=$1
|
||||
firstFrame=false
|
||||
if [[ $range == "0-0" ]]; then #mlv_dump can't handle 0-0, so we develop 0-1.
|
||||
range="0-1"
|
||||
firstFrame=true
|
||||
fi
|
||||
|
||||
tmpOut=${7}/${range} #Each output will number from 0, so give each its own folder.
|
||||
mkdir -p $tmpOut
|
||||
|
||||
start=$(echo "$range" | cut -d'-' -f1)
|
||||
end=$(echo "$range" | cut -d'-' -f2) #Get start and end frames from the frame range
|
||||
|
||||
$2 $3 $4 -o "${tmpOut}/${9}_" -f ${range} $6 --dng --batch | { #mlv_dump command. Uses frame range.
|
||||
lastCur=0
|
||||
while IFS= read -r line; do
|
||||
output=$(echo $line | grep -Po 'V.*A' | cut -d':' -f2 | cut -d$' ' -f1) #Hacked my way to the important bit.
|
||||
if [[ $output == "" ]]; then continue; fi #If there's no important bit, don't print.
|
||||
|
||||
cur=$(echo "$output" | cut -d'/' -f1) #Current frame.
|
||||
if [[ $cur == $lastCur ]] || [[ $cur -gt $end ]] || [[ $cur -lt $start ]]; then continue; fi #Turns out, it goes through all the frames, even if cutting the frame range. So, clamp it!
|
||||
|
||||
lastCur=$cur #It likes to repeat itself.
|
||||
echo -e "\033[2K\rMLV to DNG: Frame $(echo "${cur} + ${10}" | bc)/${8}\c" #Print out beautiful progress bar, in parallel!
|
||||
done
|
||||
|
||||
} #Progress Bar
|
||||
if [[ $firstFrame == true ]]; then #If 0-0.
|
||||
rm $(printf "${tmpOut}/${9}_%06d.dng" 1) 2>/dev/null #Remove frame #1, leaving us only with frame #0.
|
||||
mv $tmpOut "${7}/0-0" #Move back to 0-0, as if that's how it was developed all along.
|
||||
fi
|
||||
}
|
||||
|
||||
export -f dng_par #Export to run in subshell.
|
||||
|
||||
iso_par() {
|
||||
#usage: inc_iso 1${} 2$CR_HDR 3$TMP 4$FRAME_END 5$oldFiles 6$CHROMA_SMOOTH.
|
||||
#arglength: Takes 6 args.
|
||||
#desc: Called by xargs; is capable of processing Dual ISO DNGs in parallel by being run in a subshell.
|
||||
#note: Progress bar is thread safe. Experiment gone right :).
|
||||
#note: Unfortunately, this means the entire relevant environment needs to be passed along too.
|
||||
|
||||
count=$(echo "$(echo $(echo $1 | rev | cut -d "_" -f 1 | rev | cut -d "." -f 1 | grep "[0-9]") | bc) + 1" | bc) #Get count from filename.
|
||||
|
||||
$2 $1 $6 >/dev/null 2>/dev/null #The LQ option, --mean23, is completely unusable in my opinion.
|
||||
|
||||
name=$(basename "$1")
|
||||
mv "${3}/${name%.*}.dng" $5 #Move away original dngs.
|
||||
mv "${3}/${name%.*}.DNG" "${3}/${name%.*}.dng" #Rename *.DNG to *.dng.
|
||||
|
||||
echo -e "\033[2K\rDual ISO Development: Frame ${count}/${4}\c"
|
||||
}
|
||||
|
||||
export -f iso_par #Must expose function to subprocess.
|
||||
|
||||
img_par() {
|
||||
#usage: img_par 1${} 2$DEMO_MODE 3$FOUR_COLOR 4$BADPIXELS 5$WHITE 6$HIGHLIGHT_MODE 7$GAMMA 8$WAVE_NOISE 9$DEPTH 10$SEQ 11$TRUNC_ARG 12$IMG_FMT 13$FRAME_END 14$DEPTH_OUT 15$COMPRESS 16$isJPG 17$PROXY_SCALE 18$PROXY 19$BLACK_LEVEL 20$SPACE 21$SATPOINT 22$DCRAW 23$FFMPEG_FILTERS
|
||||
#arglength: Takes 22 arguments.
|
||||
#desc: Called by xargs; is capable of developing images in parallel by being run in a subshell.
|
||||
#note: Unfortunately, this means the entire relevantenvironment needs to be passed along too.
|
||||
|
||||
count=$(echo $(echo $1 | rev | cut -d "_" -f 1 | rev | cut -d "." -f 1 | grep "[0-9]") | bc) #Instead of count from file, count from name!
|
||||
DCRAW=${22}
|
||||
|
||||
DPXHACK=""
|
||||
if [[ ${12^^} == "DPX" && ( ${23} == false ) ]]; then DPXHACK="-colorspace sRGB"; else DPXHACK=""; fi
|
||||
#Trust me, I've tried everything else; but this sRGB transform works. Must be an IM bug. Keep an eye on it!
|
||||
#The sRGB curve is only applied if going to DPX while DPX is the target image format. Aka. At the end; not in the middle.
|
||||
|
||||
if [ ${16} == true ]; then
|
||||
$DCRAW -c -q $2 $3 $4 $5 -H $6 -k ${19} ${21} -g $7 $8 -o ${20} $9 $1 | \
|
||||
tee >(convert ${14} - -set colorspace RGB ${DPXHACK} ${15} $(printf "${10}/${11}_%06d.${12}" ${count})) | \
|
||||
convert - -set colorspace XYZ -quality 80 -colorspace sRGB -resize ${17} $(printf "${18}/${11}_%06d.jpg" ${count})
|
||||
#JPGs don't get ffmpeg filters applied. They simply can't handle it.
|
||||
echo -e "\033[2K\rDNG to ${12^^}/JPG: Frame ${count^^}/${13}\c"
|
||||
else
|
||||
$DCRAW -c -q $2 $3 $4 $5 -H $6 -k ${19} ${21} -g $7 $8 -o ${20} $9 $1 | \
|
||||
convert ${14} - -set colorspace RGB ${DPXHACK} ${15} $(printf "${10}/${11}_%06d.${12}" ${count})
|
||||
echo -e "\033[2K\rDNG to ${12^^}: Frame ${count^^}/${13}\c"
|
||||
fi
|
||||
}
|
||||
|
||||
export -f img_par #Need to export the function for it to be used in child functions.
|
||||
|
||||
#~ See http://www.imagemagick.org/discourse-server/viewtopic.php?t=21161
|
||||
|
||||
|
||||
conv_par() {
|
||||
#usage: conv_par 1${} 2$TRUNC_ARG 3$outFolder 4$fromFMT 5$iccProf 6$toFMT 7$DEPTH_OUT 8$compress 9$FRAME_END 10$IMG_FMT
|
||||
#arglength: Takes 10 arguments.
|
||||
#desc: Called by xargs; is capable of converting images in parallel by being run in a subshell. Automatically applies the DPX hack.
|
||||
#note: Unfortunately, this means the entire relevant environment needs to be passed along too.
|
||||
|
||||
count=$(echo $(echo $1 | rev | cut -d "_" -f 1 | rev | cut -d "." -f 1 | grep "[0-9]") | bc) #Get count from filename.
|
||||
|
||||
echo -e "\033[2K\rMiddle-step: ${4^^} to ${6^^}, Frame ${count^^}/${9}\c"
|
||||
|
||||
DPXHACK=""
|
||||
if [[ ${6^^} == "DPX" && ${10^^} == ${6^^} ]]; then DPXHACK="-colorspace sRGB"; else DPXHACK=""; fi
|
||||
#Trust me, I've tried everything else; but this sRGB transform works. Must be an IM bug. Keep an eye on it!
|
||||
#The sRGB curve is only applied if going to DPX while DPX is the target image format. Aka. At the end; not in the middle.
|
||||
|
||||
convert ${7} ${1} ${5} $8 -set colorspace RGB ${DPXHACK} "${3}/$(printf "${2}_%06d" ${count}).${6}"
|
||||
}
|
||||
|
||||
export -f conv_par
|
||||
|
||||
|
||||
#PRACTICAL PARALLEL FUNCTIONS
|
||||
|
||||
iProc() {
|
||||
#usage: iProc
|
||||
#desc: Develop the sequence from the current global settings.
|
||||
|
||||
#Define hardcoded compression based on IMG_FMT
|
||||
local COMPRESS=""
|
||||
if [ $isCOMPRESS == true ]; then
|
||||
case ${IMG_FMT} in
|
||||
exr)
|
||||
COMPRESS="-compress piz"
|
||||
;;
|
||||
tiff)
|
||||
COMPRESS="-compress zip"
|
||||
;;
|
||||
png)
|
||||
COMPRESS="-quality 0"
|
||||
;;
|
||||
dpx)
|
||||
COMPRESS="-compress rle"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
#Convert all the actual DNGs to IMG_FMT, in parallel.
|
||||
find "${TMP}" -maxdepth 1 -name '*.dng' -print0 | sort -z | xargs -0 -I {} -P $THREADS -n 1 \
|
||||
bash -c "img_par '{}' '$DEMO_MODE' '$FOUR_COLOR' '$BADPIXELS' '$WHITE' '$HIGHLIGHT_MODE' '$GAMMA' '$WAVE_NOISE' '$DEPTH' \
|
||||
'$SEQ' '$TRUNC_ARG' '$IMG_FMT' '$FRAME_END' '$DEPTH_OUT' '$COMPRESS' '$isJPG' '$PROXY_SCALE' '$PROXY' '$BLACK_LEVEL' '$SPACE' '$SATPOINT' '$DCRAW' '$FFMPEG_FILTERS'"
|
||||
|
||||
# Removed | cut -d '' -f $FRAME_RANGE , as this happens when creating the DNGs in the first place.
|
||||
|
||||
if [ $isJPG == true ]; then #Make it print "Frame $FRAMES / $FRAMES" as the last output.
|
||||
echo -e "\033[2K\rDNG to ${IMG_FMT^^}/JPG: Frame ${FRAME_END}/${FRAME_END}\c"
|
||||
else
|
||||
echo -e "\033[2K\rDNG to ${IMG_FMT^^}: Frame ${FRAME_END}/${FRAME_END}\c"
|
||||
fi
|
||||
|
||||
echo -e "\n"
|
||||
}
|
||||
|
||||
tConvert() {
|
||||
#usage: tConvert 1$inFolder 2$outFolder 3$fromFMT 4$toFMT
|
||||
#desc: Convert an image sequence from fromFMT to toFMT, with i/o inFolder and outFolder.
|
||||
#note: optional icc profile. Wouldn't suggest using it right now...
|
||||
|
||||
inFolder=$1
|
||||
outFolder=$2
|
||||
fromFMT=$3
|
||||
toFMT=$4
|
||||
iccProf=$5
|
||||
|
||||
if [[ ! -z $iccProf ]]; then iccProf="+profile icm -profile $iccProf"; fi
|
||||
|
||||
compress=""
|
||||
if [[ ${IMG_FMT^^} == ${toFMT^^} ]]; then compress=${COMPRESS}; fi
|
||||
|
||||
find $inFolder -iname "*.${fromFMT}" -print0 | sort -z | xargs -0 -I {} -P $THREADS -n 1 \
|
||||
bash -c "conv_par '{}' '$TRUNC_ARG' '$outFolder' '$fromFMT' '$iccProf' '$toFMT' '$DEPTH_OUT' '$compress' '$FRAME_END' '$IMG_FMT'"
|
||||
|
||||
echo ""
|
||||
}
|
||||
|
||||
applyFilters() {
|
||||
#usage: applyFilters IO <FMT>
|
||||
#desc: Applies all ffmpeg filters to the given IO sequence of FMT format.
|
||||
#note: If FMT isn't defined, IMG_FMT is automatically used.
|
||||
#note: Ideally, this would be all we need. But alas, ffmpeg + exr is broken. So there's a custom middle step for that scenario.
|
||||
|
||||
IO=$1
|
||||
FMT=$2
|
||||
|
||||
if [[ -z $FMT ]]; then FMT="${IMG_FMT}"; fi
|
||||
|
||||
ffmpeg -start_number $FRAME_START -f image2 -i "${IO}/${TRUNC_ARG}_%06d.${FMT}" -loglevel panic -stats $V_FILTERS \
|
||||
-pix_fmt rgb48be -start_number $FRAME_START "${tmpFiltered}/${TRUNC_ARG}_%06d.${FMT}"
|
||||
|
||||
tConvert "$tmpFiltered" "$IO" "$FMT" "$FMT" # "/home/sofus/subhome/src/convmlv/color/lin_xyz--srgb_srgb.icc" - profile application didn't work...
|
||||
}
|
|
@ -1,3 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#desc: Kinda standalone TODO list.
|
||||
|
||||
less -R << EOF
|
||||
|
||||
TODO:
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#desc: The help function lives here, as well as helper functions thereof.
|
||||
|
||||
help() {
|
||||
less -R << EOF
|
||||
Usage:
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
#desc: Error checking and consequence functions.
|
||||
|
||||
invOption() {
|
||||
str=$1
|
||||
|
@ -13,50 +16,55 @@ invOption() {
|
|||
}
|
||||
|
||||
checkArg() {
|
||||
#stderr is for printing; stdout is for return values.
|
||||
#usage: checkArg arg
|
||||
#desc: Checks the argument to see if it's a valid MLV, RAW, or DNG sequence.
|
||||
#return: 'false' if not valid, 'true' if it is.
|
||||
#print (stderr): Error stuff.
|
||||
|
||||
argBase="$(basename "$ARG")"
|
||||
argExt="${argBase##*.}"
|
||||
argTrunc="${argBase%.*}"
|
||||
local arg="$1"
|
||||
|
||||
local argBase="$(basename "$arg")"
|
||||
local argExt="${argBase##*.}"
|
||||
local argTrunc="${argBase%.*}"
|
||||
local cont
|
||||
|
||||
#Argument Checks
|
||||
if [ ! -f $ARG ] && [ ! -d $ARG ]; then
|
||||
nFound "File" "${ARG}" "Skipping File"
|
||||
echo "skip" >&1; return
|
||||
if [ ! -f $arg ] && [ ! -d $arg ]; then
|
||||
nFound "File" "${arg}" "Skipping File"
|
||||
echo "false" >&1; return
|
||||
fi
|
||||
|
||||
if [[ ! -d $ARG && ! ( $argExt == "MLV" || $argExt == "mlv" || $argExt == "RAW" || $argExt == "raw" ) ]]; then
|
||||
echo -e "\033[0;31m\033[1mFile ${ARG} has invalid extension!\033[0m\n" >&2
|
||||
echo "skip" >&1; return
|
||||
if [[ ! -d $arg && ! ( $argExt == "MLV" || $argExt == "mlv" || $argExt == "RAW" || $argExt == "raw" ) ]]; then
|
||||
error "File ${arg} has invalid extension!\n" >&2
|
||||
echo "false" >&1; return
|
||||
fi
|
||||
|
||||
if [[ ( ( ! -f $ARG ) && $(ls -1 ${ARG%/}/*.[Dd][Nn][Gg] 2>/dev/null | wc -l) == 0 ) && ( `folderName ${ARG}` != $argTrunc ) ]]; then
|
||||
echo -e "\033[0;31m\033[1mFolder ${ARG} contains no DNG files!\033[0m\n" >&2
|
||||
echo "skip" >&1; return
|
||||
if [[ ( ( ! -f $arg ) && $(ls -1 ${arg%/}/*.[Dd][Nn][Gg] 2>/dev/null | wc -l) == 0 ) && ( `folderName ${arg}` != $argTrunc ) ]]; then
|
||||
error "Folder ${arg} contains no DNG files!" >&2
|
||||
echo "false" >&1; return
|
||||
fi
|
||||
|
||||
if [ ! -d $ARG ] && [[ $(echo $(wc -c ${ARG} | xargs | cut -d " " -f1) / 1000 | bc) -lt 1000 ]]; then #Check that the file is not too small.
|
||||
if [ ! -d $arg ] && [[ $(echo $(wc -c ${arg} | xargs | cut -d " " -f1) / 1000 | bc) -lt 1000 ]]; then #Check that the file is not too small.
|
||||
cont=false
|
||||
while true; do
|
||||
#xargs easily trims the cut statement, which has a leading whitespace on Mac.
|
||||
read -p "${ARG} is unusually small at $(echo "$(echo "$(wc -c ${ARG})" | xargs | cut -d$' ' -f1) / 1000" | bc)KB. Continue, skip, remove, or quit? [c/s/r/q] " csr
|
||||
read -p "${arg} is unusually small at $(echo "$(echo "$(wc -c ${arg})" | xargs | cut -d$' ' -f1) / 1000" | bc)KB. Continue, skip, remove, or quit? [c/s/r/q] " csr
|
||||
case $csr in
|
||||
[Cc]* ) "\n\033[0;31m\033[1mContinuing.\033[0m\n"; break
|
||||
[Cc]* ) error "\nContinuing.\n"; break
|
||||
;;
|
||||
[Ss]* ) echo -e "\n\033[0;31m\033[1mSkipping.\033[0m\n"; cont=true; break
|
||||
[Ss]* ) error "\nSkipping.\n"; cont=true; break
|
||||
;;
|
||||
[Rr]* ) echo -e "\n\033[0;31m\033[1mRemoving ${ARG}.\033[0m\n"; cont=true; rm $ARG; break
|
||||
[Rr]* ) error "\nRemoving ${arg}.\n"; cont=true; rm $arg; break
|
||||
;;
|
||||
[Qq]* ) echo -e "\n\033[0;31m\033[1mQuitting.\033[0m\n"; isExit=true; break
|
||||
[Qq]* ) error "\nQuitting.\n"; isExit=true; break
|
||||
;;
|
||||
* ) echo -e "\033[0;31m\033[1mPlease answer continue, skip, or remove.\033[0m\n"
|
||||
* ) error "Please answer continue, skip, or remove.\n"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $cont == true ]; then
|
||||
echo "skip" >&1; return
|
||||
echo "false" >&1; return
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -1,7 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
#desc: Text formatting functions.
|
||||
|
||||
bold() {
|
||||
echo -e "\033[1m${1}\033[0m"
|
||||
}
|
||||
|
||||
selected() {
|
||||
echo -e "$(bold "\033[32m${1}\033[0m")"
|
||||
}
|
||||
|
||||
error() {
|
||||
echo -e "$(bold "\033[31m${1}\033[0m")"
|
||||
}
|
||||
|
||||
formArg() {
|
||||
#usage: formArg item selection
|
||||
#desc: Formats ARG values prettily; param can be "selected" or "deselected".
|
||||
#return: Formatted path.
|
||||
local item="$1"
|
||||
local selection="$2"
|
||||
|
||||
local itemBase=$(basename $item)
|
||||
local itemExt=".${itemBase##*.}" #Dot must be in here.
|
||||
if [[ "${itemExt}" == ".${itemBase}" ]]; then itemExt=""; fi #This means the input is a folder, which has no extension.
|
||||
|
||||
local itemDir=$(dirname "$item")
|
||||
|
||||
if [[ $selection == "selected" ]]; then
|
||||
echo -e "${itemDir}/$(selected "${itemBase%.*}")${itemExt}"
|
||||
elif [[ $selection == "deselected" ]]; then
|
||||
echo -e "${itemDir}/$(bold ${itemBase%.*})${itemExt}"
|
||||
fi
|
||||
}
|
||||
|
||||
cVal() {
|
||||
#usage: cVal value
|
||||
#desc: Formats config file values, as bolded grey.
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#desc: Platform-specific functions.
|
||||
|
||||
getThreads() {
|
||||
local threads=4 #4 threads by default
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#desc: Portable utility functions that could live in their own library.
|
||||
|
||||
nFound() { #Prints: ${type} ${name} not found! ${exec_instr}.\n\t${down_instr} to stderr.
|
||||
type=$1
|
||||
name="$2"
|
||||
|
@ -12,6 +16,11 @@ nFound() { #Prints: ${type} ${name} not found! ${exec_instr}.\n\t${down_instr} t
|
|||
}
|
||||
|
||||
mkdirS() {
|
||||
#usage: mkdirS path; if [ $? -eq 1 ]; then return 1; fi
|
||||
#desc: A function that allows the user to decide whether to overwrite an existing directory.
|
||||
#note: The user must use return codes to provide the return from develop().
|
||||
#return: Exit code 1 denotes that we must continue.
|
||||
|
||||
path=$1
|
||||
cleanup=$2
|
||||
cont=false
|
||||
|
@ -22,11 +31,11 @@ mkdirS() {
|
|||
case $ynq in
|
||||
[Yy]* ) echo -e ""; rm -rf $path; mkdir -p $path >/dev/null 2>/dev/null; break
|
||||
;;
|
||||
[Nn]* ) echo -e "\n\033[0;31m\033[1mDirectory ${path} won't be created.\033[0m\n"; cont=true; `$cleanup`; break
|
||||
[Nn]* ) error "\nDirectory ${path} won't be created.\n"; cont=true; `$cleanup`; break
|
||||
;;
|
||||
[Qq]* ) echo -e "\n\033[0;31m\033[1mHalting execution. Directory ${path} won't be created.\033[0m\n"; `$cleanup`; exit 1;
|
||||
[Qq]* ) error "\nHalting execution. Directory ${path} won't be created.\n"; `$cleanup`; exit 1;
|
||||
;;
|
||||
* ) echo -e "\033[0;31m\033[1mPlease answer yes or no.\033[0m\n"
|
||||
* ) error "Please answer yes or no, or quit.\n"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
@ -35,8 +44,7 @@ mkdirS() {
|
|||
fi
|
||||
|
||||
if [ $cont == true ]; then
|
||||
let ARGNUM--
|
||||
continue
|
||||
return 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
@ -50,3 +58,26 @@ joinArgs() {
|
|||
#Joins the arguments of the input array using commas.
|
||||
local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"
|
||||
}
|
||||
|
||||
runSim() {
|
||||
# Command: cat $PIPE | cmd1 & cmdOrig | tee $PIPE | cmd2
|
||||
|
||||
# cat $PIPE | cmd1 - gives output of pipe live. Pipes it into cmd1. Nothing yet; just setup.
|
||||
# & - runs the next part in the background.
|
||||
# cmdOrig | tee $PIPE | cmd2 - cmdOrig pipes into the tee, which splits it back into the previous pipe, piping on to cmd2!
|
||||
|
||||
# End Result: Output of cmdOrig is piped into cmd1 and cmd2, which execute, both printing to stdout.
|
||||
|
||||
cmdOrig=$1
|
||||
cmd1=$2
|
||||
cmd2=$3
|
||||
|
||||
#~ echo $cmdOrig $cmd1 $cmd2
|
||||
#~ echo $($cmdOrig)
|
||||
|
||||
PIPE="${TMP}/pipe_vid" # $(date +%s%N | cut -b1-13)"
|
||||
mkfifo $PIPE 2>/dev/null
|
||||
|
||||
cat $PIPE | $cmd1 & $cmdOrig | tee $PIPE | $cmd2 #The magic of simultaneous execution ^_^
|
||||
#~ cat $PIPE | tr 'e' 'a' & echo 'hello' | tee $PIPE | tr 'e' 'o' #The magic of simultaneous execution ^_^
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
#desc: Math for bash regarding image operations. So that we don't have to hop over to python!
|
||||
|
||||
normToOne() {
|
||||
wBal=$1
|
||||
|
||||
max=0.0
|
||||
for mult in $wBal; do
|
||||
if [ $(echo " $mult > $max" | bc) -eq 1 ]; then
|
||||
max=$mult
|
||||
fi
|
||||
done
|
||||
|
||||
for mult in $wBal; do
|
||||
echo -e "$(echo "scale=6; x=${mult} / ${max}; if(x<1) print 0; x" | bc -l) \c" #BC is bae.
|
||||
done
|
||||
}
|
||||
|
||||
getGreen() {
|
||||
wBal=$1
|
||||
|
||||
i=0
|
||||
for mult in $wBal; do
|
||||
if [ $i -eq 1 ]; then
|
||||
echo -e "${mult}"
|
||||
fi
|
||||
let i++
|
||||
done
|
||||
}
|
|
@ -1,3 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#desc: Calibration frame code.
|
||||
|
||||
mkDarkframe() {
|
||||
echo -e "\n\033[1m\033[0;32m\033[1mAveraging Darkframe File\033[0m: ${ARG}"
|
||||
$MLV_DUMP -o $DARK_OUT ${FILE_ARGS_ARRAY[0]} 2>/dev/null 1>/dev/null
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#desc: Functions dealing with getting and printing footage (ARG) settings.
|
||||
|
||||
prntSet() {
|
||||
cat << EOF
|
||||
$(bold CameraName): ${CAM_NAME}
|
||||
|
@ -74,6 +78,23 @@ dngSet() { #Set as many options as the RAW spec will allow. Grey out the rest.
|
|||
rm $dataDNG
|
||||
}
|
||||
|
||||
reuseSet() {
|
||||
local dng_loc="$1"
|
||||
|
||||
FPS=`cat ${dng_loc}/../settings.txt | grep "FPS" | cut -d $" " -f2`
|
||||
|
||||
CAM_NAME=`cat ${dng_loc}/../settings.txt | grep "CameraName" | cut -d $" " -f2`
|
||||
FRAMES=`cat ${dng_loc}/../settings.txt | grep "Frames" | cut -d $" " -f2` #Grab FRAMES from previous run.
|
||||
RES_IN=`cat ${dng_loc}/../settings.txt | grep "Resolution" | cut -d $" " -f2`
|
||||
ISO=`cat ${dng_loc}/../settings.txt | grep "ISO" | cut -d $" " -f2`
|
||||
APERTURE=`cat ${dng_loc}/../settings.txt | grep "Aperture" | cut -d $" " -f2`
|
||||
LEN_FOCAL=`cat ${dng_loc}/../settings.txt | grep "FocalLength" | cut -d $" " -f2`
|
||||
SHUTTER=`cat ${dng_loc}/../settings.txt | grep "ShutterSpeed" | cut -d $" " -f2`
|
||||
REC_DATE=`cat ${dng_loc}/../settings.txt | grep "RecordingDate" | cut -d $" " -f2`
|
||||
REC_TIME=`cat ${dng_loc}/../settings.txt | grep "RecordingTime" | cut -d $" " -f2`
|
||||
KELVIN=`cat ${dng_loc}/../settings.txt | grep "WBKelvin" | cut -d $" " -f2`
|
||||
}
|
||||
|
||||
printFileSettings() {
|
||||
ARG="${FILE_ARGS_ARRAY[0]}"
|
||||
checkArg
|
||||
|
|
Loading…
Reference in New Issue