From c00b62f20fa8fb41e2542a839614d008a7f67710 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Thu, 21 Dec 2023 22:08:39 +0100 Subject: [PATCH] up script --- hugin-gopro-fusion/find_min_max.ts | 51 ++++++++++++++++++------------ hugin-gopro-fusion/main.ts | 34 ++++++++++++++++---- 2 files changed, 59 insertions(+), 26 deletions(-) diff --git a/hugin-gopro-fusion/find_min_max.ts b/hugin-gopro-fusion/find_min_max.ts index 6976f566..bd2c807b 100644 --- a/hugin-gopro-fusion/find_min_max.ts +++ b/hugin-gopro-fusion/find_min_max.ts @@ -11,6 +11,8 @@ let enable_batch_move_assembled_files = false; let should_exec_geovisio_upload = false; +const reallyMoveFiles = false; + let folder = `/home/poule/encrypted/stockage-syncable/photos/imageries/gopro/INBOX_a_assembler/` let subfolder = `` @@ -41,7 +43,7 @@ function findMinMaxNumberOfPhotos(dirPath: string): { min: number, max: number } if (matches && matches.length && matches[0]) { let number = parseInt(matches[0]); - if (previousFileName + 1 !== number) { + if ((previousFileName + 1) !== number) { console.log('saut de nombre / séquence à ', previousFileName, number) } // Sauver le nombre minimal et maximal trouvé jusqu'à présent @@ -65,10 +67,18 @@ function findMinMaxNumberOfPhotos(dirPath: string): { min: number, max: number } let result = findMinMaxNumberOfPhotos(folder + subfolder) console.log('result', result) -console.log("script :\n", ` -ts-node /home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-gopro-fusion/main.ts --goproSubFolder=INBOX_a_assembler/${subfolder} -bash /home/poule/encrypted/stockage-syncable/photos/imageries/gopro/INBOX_PTO_hugin/hugin_executor_from_${result.min}_to_${result.max}.sh -bash /home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-gopro-fusion/exif_batch.sh ${result.min} ${result.max} INBOX_a_assembler/${subfolder} +console.log("script à lancer:\n", ` + # création des fichiers d'assemblage PTO et du script d'exécution en batch + ts-node /home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-gopro-fusion/main.ts --goproSubFolder=INBOX_a_assembler/${subfolder} + + # invocation de l'éxécution de la séquence d'assemblage + bash /home/poule/encrypted/stockage-syncable/photos/imageries/gopro/INBOX_PTO_hugin/hugin_executor_from_${result.min}_to_${result.max}.sh + + # application des informations exif + bash /home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-gopro-fusion/exif_batch.sh ${result.min} ${result.max} INBOX_a_assembler/${subfolder} + + # envoi vers panoramax + geovisio_cli upload --api-url https://panoramax.openstreetmap.fr /home/poule/encrypted/stockage-syncable/photos/imageries/gopro/PANORAMAX_envois_todo/${subfolder} `) @@ -77,8 +87,6 @@ const envois_todo_panoramax = '/home/poule/encrypted/stockage-syncable/photos/im const startNumber = result.min; const endNumber = result.max; -// const startNumber = 1; -// const endNumber = 5; function renameFile(fileName: string): void { const filePath = path.join(hugin_assemblages_script_output_path, fileName); @@ -87,20 +95,24 @@ function renameFile(fileName: string): void { const newFileName = `assemblage_0${startNumber}.jpg`; const newFilePath = path.join(envois_todo_panoramax, newFileName); - console.log('rename: ', filePath, newFilePath) + // console.log('rename: ', filePath, newFilePath) - - fs.renameSync(filePath, newFilePath); + if (reallyMoveFiles) { + fs.renameSync(filePath, newFilePath); + } } else { console.log('ce fichier est inexistant', filePath) } + console.log('fin de déplacement des fichiers assemblés') } function createDirectory(folderName: string): void { console.log('createDirectory', folderName) if (!fs.existsSync(folderName)) { - fs.mkdirSync(folderName); + fs.mkdirSync(folderName, { recursive: true }); + }else{ + console.log('folder already existing', folderName) } } @@ -127,20 +139,11 @@ function batch_move_assembled_files(startNumber: number, endNumber: number) { for (let i = startNumber; i <= endNumber; i++) { const fileName = `assemblage_0${i}.jpg`; - console.log('fileName', fileName) renameFile(fileName); } } -console.log(' déplacer les assemblages dans ' + envois_todo_panoramax, startNumber, endNumber) - -createDirectory(envois_todo_panoramax); - -if (enable_batch_move_assembled_files) { - - batch_move_assembled_files(startNumber, endNumber) -} function executeCommand(command: string, folderName: string): void { @@ -171,3 +174,11 @@ if (should_exec_geovisio_upload) { } console.log("exécuter geovisio upload") + +createDirectory(envois_todo_panoramax); + +if (enable_batch_move_assembled_files) { + + console.log(' déplacer les assemblages dans ' + envois_todo_panoramax, startNumber, endNumber) + batch_move_assembled_files(startNumber, endNumber) +} diff --git a/hugin-gopro-fusion/main.ts b/hugin-gopro-fusion/main.ts index 7d128906..d0206a51 100644 --- a/hugin-gopro-fusion/main.ts +++ b/hugin-gopro-fusion/main.ts @@ -120,16 +120,23 @@ function findMinMaxNumberOfPhotos(dirPath: string): { min: number, max: number } function makeBashScriptHugin(minmax: any) { - console.log('makeBashScriptHugin') + let count_pto_made_files =0; // in each increment of a pair of photos, build a pto referencing absolute paths // write the pto in output - console.log('parseInt(minmax.min)', parseInt(minmax.min)) + console.log('makeBashScriptHugin: parseInt(minmax.min)', parseInt(minmax.min)) + + console.log('makeBashScriptHugin: gopro_fusion_separated_photos_folder', gopro_fusion_separated_photos_folder) + + + if (!disable_pto_write) { + console.log('makeBashScriptHugin: début de l\'écriture des fichiers PTO') + } + for (let ii: any = parseInt(minmax.min); ii <= parseInt( minmax.max ); ii++) { let currentNumber = `${previous_zero}${ii}`; - // let currentNumber = '080096'; let ptoContent = makePto(absolutePath, currentNumber); let ptoFileName = `merging_${currentNumber}.pto` let stitchedFileName = `assemblage_${currentNumber}` @@ -145,20 +152,30 @@ function makeBashScriptHugin(minmax: any) { '--stitching ' + '--prefix=' + stitchedFileName + '\n' + + // ' else' + + // '\n' + + // ' echo "le fichier assemblé '+stitchedFileName+' manque mais le fichier de caméra gopro front n\'existe pas."' + + '\n' + + // ' else' + + // '\n' + + // ' echo "le fichier assemblé '+stitchedFileName+' existe déjà"' + + '\n' + ' fi' + '\n' + 'fi' if (!disable_pto_write) { - - // console.log('ptoContent', ptoContent) writeFile(ptoFileName, ptoContent) + count_pto_made_files++; }else{ console.log('l écriture de fichiers PTO a été désactivée') } } + if (!disable_pto_write) { + console.log('fin de l\'écriture des '+count_pto_made_files+' fichiers PTO') + } let hugin_batch_command = 'bash /home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-gopro-fusion/exif_batch.sh ' + goproMin + ' ' + goproMax @@ -182,7 +199,12 @@ function makeBashScriptHugin(minmax: any) { } -function makePto(absolutePath: string, currentNumber: string) { +/** + * génère un fichier pto sous forme de String + * @param absolutePath + * @param currentNumber + */ +function makePto(absolutePath: string, currentNumber: string):string { let front_picture_name = absolutePath + '/GF' + currentNumber + '.' + extension_photo_source; let back_picture_name = absolutePath + '/GB' + currentNumber + '.' + extension_photo_source;