find automatically numbers in sequences
This commit is contained in:
parent
32f0542a93
commit
a9d8e372d8
@ -9,11 +9,12 @@
|
||||
# exemple ./exif_batch.sh 36077 36159
|
||||
# va assigner les données exif des photos gopro GF036077.JPG à leur assemblage assemblage_063077.jpg
|
||||
|
||||
folder="rouen/rouen_oct23"
|
||||
#folder="rouen/rouen_oct23"
|
||||
|
||||
function batch_exif_photos {
|
||||
local min=$1
|
||||
local max=$2
|
||||
local folder=$3
|
||||
local dir="/home/poule/encrypted/stockage-syncable/photos/imageries/gopro/$folder"
|
||||
|
||||
echo $(seq $min $max)
|
||||
@ -25,12 +26,12 @@ function batch_exif_photos {
|
||||
|
||||
if [ -f "$file" ] && [ -f "$file_assemblage" ]; then
|
||||
echo "set the tags in assemblage $i from GF0$filename.jpg"
|
||||
exiftool -tagsFromFile "$file" $file $file_assemblage -overwrite_original
|
||||
echo "updated the exift tags of $file_assemblage"
|
||||
# exiftool -tagsFromFile "$file" $file $file_assemblage -overwrite_original
|
||||
# echo "updated the exift tags of $file_assemblage"
|
||||
else
|
||||
echo "File $file does not exist."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
batch_exif_photos $1 $2
|
||||
batch_exif_photos $1 $2 $3
|
||||
|
@ -11,15 +11,16 @@
|
||||
function batch_exif_photos {
|
||||
# this is a WIP
|
||||
|
||||
local min=$1
|
||||
local max=$2
|
||||
local gopro_subfolder=$3
|
||||
local gopro_subfolder=$1
|
||||
|
||||
echo " création des assemblages pour le dossier $gopro_subfolder pour les photos $1 à $2"
|
||||
|
||||
echo " création des assemblages pour le dossier $gopro_subfolder"
|
||||
|
||||
archive_zfs="/home/poule/encrypted/stockage-syncable"
|
||||
node_script_hugin_folder="/home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-gopro-fusion"
|
||||
|
||||
pto_folder="$archive_zfs/www/development/html/scripts/hugin-gopro-fusion/output_pto/"
|
||||
destination_pto="$archive_zfs/photos/imageries/gopro/pto"
|
||||
destination_pto="$archive_zfs/photos/imageries/gopro/INBOX_PTO_hugin"
|
||||
# test de l'existence des dossiers
|
||||
if [ -f "$archive_zfs" ] ; then
|
||||
echo "zfs archive is not mounted"
|
||||
@ -29,13 +30,18 @@ function batch_exif_photos {
|
||||
if [ -f "$destination_pto" ] ; then
|
||||
mkdir -p "$archive_zfs/photos/imageries/gopro/INBOX_PTO_hugin"
|
||||
fi
|
||||
# move the generated pto and scripts
|
||||
mv "$pto_folder/*" "$destination_pto"
|
||||
|
||||
cd "$destination_pto"
|
||||
echo "lancement de hugin_executor_from$min_to_$max.sh"
|
||||
# bash "hugin_executor_from$min_to_$max.sh"
|
||||
echo "création de hugin_executor"
|
||||
echo " -> ts-node ${node_script_hugin_folder}/main.ts --goproSubFolder="${gopro_subfolder}" --previous_zero=''"
|
||||
ts-node $node_script_hugin_folder/main.ts --goproSubFolder="$gopro_subfolder" --previous_zero=''
|
||||
|
||||
|
||||
# echo "lancement de hugin_executor_from_${min}_to_${max}.sh"
|
||||
# echo " -> bash hugin_executor_from_${min}_to_${max}.sh"
|
||||
# echo "lancement de l'ajout d'infos GPS aux photos assemblées"
|
||||
# echo " -> bash exif_batch ${min} ${max} ${gopro_subfolder}"
|
||||
|
||||
}
|
||||
|
||||
batch_exif_photos $1 $2 $3
|
||||
batch_exif_photos $1
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
conversion de données gpx
|
||||
conversion de données exif
|
||||
utilisation:
|
||||
utilisation:
|
||||
ts-node main.ts --goproMin=80800 --goproMax=80801 --goproSubFolder="rouen_oct23"
|
||||
|
||||
**/
|
||||
@ -16,13 +16,13 @@ const moment = require("moment");
|
||||
let mini_arguments: any = minimist(process.argv.slice(2))
|
||||
// configs
|
||||
/**
|
||||
* ces trois paramètres permettent de traiter par lots des assemblages sans avoir à scanner le dossier
|
||||
* ces paramètres permettent de traiter par lots des assemblages sans avoir à scanner le dossier
|
||||
*/
|
||||
let gorpro_fusion_separated_photos_folder = 'rouen/rouen_oct23'
|
||||
let gorpro_fusion_separated_photos_folder = ''
|
||||
|
||||
let previous_zero = '0'// numéro de photo gopro minimum front et back. correspond à GF080800.JPG + GB080800.JPG
|
||||
let goproMin = '80800'// numéro de photo gopro minimum front et back. correspond à GF080800.JPG + GB080800.JPG
|
||||
let goproMax = '80866' // et maximum. correspond à GF080866.JPG + GB080866.JPG
|
||||
let goproMin = 80800// numéro de photo gopro minimum front et back. correspond à GF080800.JPG + GB080800.JPG
|
||||
let goproMax = 80801 // et maximum. correspond à GF080866.JPG + GB080866.JPG
|
||||
let addExifToolInScript = false;
|
||||
let outputStitchedFolder = '/home/poule/encrypted/stockage-syncable/photos/imageries/gopro/hugin_assemblages_script_output/'
|
||||
|
||||
@ -30,7 +30,7 @@ if (mini_arguments['addExifToolInScript']) {
|
||||
addExifToolInScript = mini_arguments['addExifToolInScript']
|
||||
}
|
||||
if (mini_arguments['previous_zero']) {
|
||||
addExifToolInScript = mini_arguments['previous_zero']
|
||||
previous_zero = mini_arguments['previous_zero']
|
||||
}
|
||||
if (mini_arguments['goproMin']) {
|
||||
goproMin = mini_arguments['goproMin']
|
||||
@ -42,7 +42,7 @@ if (mini_arguments['goproMax']) {
|
||||
goproMax = mini_arguments['goproMax']
|
||||
}
|
||||
|
||||
let hugin_batch_command = 'bash /home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-gopro-fusion/exif_batch.sh '+goproMin+' '+goproMax
|
||||
let hugin_batch_command = 'bash /home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-gopro-fusion/exif_batch.sh ' + goproMin + ' ' + goproMax
|
||||
|
||||
|
||||
let extension_photo_source = 'jpg'
|
||||
@ -50,7 +50,7 @@ extension_photo_source = 'JPG'
|
||||
|
||||
let gopro_folder = "/home/poule/encrypted/stockage-syncable/photos/imageries/gopro";
|
||||
|
||||
let dossier_pto_output = `/home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-gopro-fusion/output_pto`;
|
||||
let dossier_pto_output = `/home/poule/encrypted/stockage-syncable/photos/imageries/gopro/INBOX_PTO_hugin`;
|
||||
let absolutePath = `${gopro_folder}/${gorpro_fusion_separated_photos_folder}`;
|
||||
let folder = `${gopro_folder}/${gorpro_fusion_separated_photos_folder}`
|
||||
|
||||
@ -65,13 +65,42 @@ let dossier_assemblages_output = `${gopro_folder}/hugin_assemblages_script_outpu
|
||||
console.log('mini_arguments', mini_arguments)
|
||||
|
||||
|
||||
const path = require('path');
|
||||
|
||||
/**
|
||||
* trouver les valeux min et max de numéros de séquence gopro dans un dossier contenant des photos jpg
|
||||
* @param dirPath
|
||||
*/
|
||||
function findMinMaxNumberOfPhotos(dirPath: string): { min: number, max: number } {
|
||||
|
||||
console.log('dirPath', dirPath)
|
||||
|
||||
let minNumber: number = 0;
|
||||
let maxNumber: number = 0;
|
||||
|
||||
// Boucler sur chaque fichier JPG dans le dossier
|
||||
fs.readdirSync(dirPath).forEach(file => {
|
||||
// Vérifier si le fichier est un fichier JPG
|
||||
if (path.extname(file) === '.jpg' || path.extname(file) === '.JPG') {
|
||||
// Éxtraire le nombre du nom de fichier
|
||||
let matches:any = file.match(/(\d+)/);
|
||||
if (matches && matches.length && matches[0]) {
|
||||
let number = 1 * parseInt(matches[0]);
|
||||
|
||||
// Sauver le nombre minimal et maximal trouvé jusqu'à présent
|
||||
if (minNumber === 0 && number > 0) {
|
||||
minNumber = number;
|
||||
}
|
||||
if (number > maxNumber) {
|
||||
maxNumber = number;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function findMinMaxNumberOfPhotos(filesList: Array<string>) {
|
||||
// TODO find in folder
|
||||
return {
|
||||
min: goproMin,
|
||||
max: goproMax,
|
||||
min: minNumber,
|
||||
max: maxNumber,
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,46 +129,44 @@ function makeBashScriptHugin(minmax: any) {
|
||||
|
||||
let ptoPath = `${dossier_pto_output}/${ptoFileName}`
|
||||
scriptsContent += '\n\n# capture n°' + currentNumber
|
||||
scriptsContent += '\nif [ ! -f '+outputStitchedFolder+stitchedFileName+'.jpg ]; then \n' +
|
||||
scriptsContent += '\nif [ ! -f ' + outputStitchedFolder + stitchedFileName + '.jpg ]; then \n' +
|
||||
'hugin_executor' +
|
||||
' ' + ptoPath + ' ' +
|
||||
'--stitching ' +
|
||||
'--prefix=' + stitchedFileName +
|
||||
' -t=6'+
|
||||
' -t=6' +
|
||||
'\n' +
|
||||
'fi'
|
||||
|
||||
|
||||
|
||||
|
||||
// console.log('ptoContent', ptoContent)
|
||||
writeFile(ptoFileName, ptoContent)
|
||||
|
||||
}
|
||||
|
||||
if(addExifToolInScript){
|
||||
if (addExifToolInScript) {
|
||||
scriptsContent += '\n # complétion des données gps depuis une des photos assemblées' +
|
||||
'\n' + hugin_batch_command + '\n'
|
||||
}
|
||||
|
||||
console.log('##############\n pour lancer le script : \n', 'bash output_pto/'+'hugin_executor_from' + goproMin + '_to_' + goproMax + '.sh', '\n##############\n'
|
||||
console.log('##############\n pour lancer le script : \n', 'bash /home/poule/encrypted/stockage-syncable/photos/imageries/gopro/INBOX_PTO_hugin/hugin_executor_from_' + goproMin + '_to_' + goproMax + '.sh',
|
||||
'\n'+
|
||||
' bash /home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-gopro-fusion/exif_batch.sh '+goproMin+' '+goproMax+' '+gorpro_fusion_separated_photos_folder,
|
||||
'\n'+
|
||||
'\n##############\n'
|
||||
)
|
||||
console.log('hugin_batch_command: \n', hugin_batch_command)
|
||||
|
||||
writeFile('hugin_executor_from' + goproMin + '_to_' + goproMax + '.sh', scriptsContent)
|
||||
writeFile('hugin_executor_from_' + goproMin + '_to_' + goproMax + '.sh', scriptsContent);
|
||||
|
||||
let countPhotos = (parseInt(goproMax)) - (parseInt(goproMin));
|
||||
|
||||
console.log('la séquence', countPhotos, 'captures', (countPhotos / 60).toFixed(0), 'minutes'
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
|
||||
function makePto(absolutePath: string, currentNumber: string) {
|
||||
|
||||
let front_picture_name = absolutePath + '/GF' + currentNumber + '.'+extension_photo_source;
|
||||
let back_picture_name = absolutePath + '/GB' + currentNumber + '.'+extension_photo_source;
|
||||
let front_picture_name = absolutePath + '/GF' + currentNumber + '.' + extension_photo_source;
|
||||
let back_picture_name = absolutePath + '/GB' + currentNumber + '.' + extension_photo_source;
|
||||
|
||||
|
||||
// console.log('front_picture_name', front_picture_name)
|
||||
@ -233,7 +260,7 @@ k i1 t1 p"252 628 484 351 745 156 1008 41 1121 2 1992 4 2289 127 2571 317 2769 5
|
||||
|
||||
|
||||
function writeFile(fileName: string, fileContent: any) {
|
||||
console.log('write file', fileName)
|
||||
// console.log('write file', dossier_pto_output , fileName)
|
||||
|
||||
return fs.writeFile(
|
||||
`${dossier_pto_output}/${fileName}`,
|
||||
@ -248,9 +275,9 @@ function writeFile(fileName: string, fileContent: any) {
|
||||
}
|
||||
|
||||
let scriptsContent = '#!/bin/bash' +
|
||||
'\necho "éxécuter tous les fichiers PTO dans : '+dossier_assemblages_output+'"\n ' +
|
||||
'\necho "éxécuter tous les fichiers PTO dans : ' + dossier_assemblages_output + '"\n ' +
|
||||
'\ncd ' + dossier_assemblages_output + '\n';
|
||||
'\n pwd\n';
|
||||
'\n pwd\n';
|
||||
|
||||
|
||||
function main() {
|
||||
@ -260,6 +287,19 @@ function main() {
|
||||
})
|
||||
}
|
||||
|
||||
let minmax = findMinMaxNumberOfPhotos(folder)
|
||||
console.log('minmax', minmax)
|
||||
|
||||
goproMin = minmax.min
|
||||
goproMax = minmax.max
|
||||
|
||||
let countPhotos = ((goproMax)) - ((goproMin));
|
||||
console.log('goproMax', goproMax)
|
||||
console.log('goproMin', goproMin)
|
||||
console.log('max - min', (goproMax) - (goproMin))
|
||||
console.log('la séquence', countPhotos, 'captures', (countPhotos / 60).toFixed(0), 'minutes');
|
||||
|
||||
|
||||
// run it all
|
||||
main()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user