229 lines
7.2 KiB
TypeScript
229 lines
7.2 KiB
TypeScript
/**
|
|
conversion de données gpx
|
|
conversion de données exif
|
|
**/
|
|
|
|
// @ts-ignore
|
|
import * as fs from 'node:fs';
|
|
// @ts-ignore
|
|
import minimist from 'minimist';
|
|
// @ts-ignore
|
|
const moment = require("moment");
|
|
|
|
// configs
|
|
|
|
let gopro_fusion_folder = 'allez_zou_huggin'
|
|
let dossier_pto_output = `/home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-gopro-fusion/output_pto_${gopro_fusion_folder}`;
|
|
|
|
let absolutePath = `/home/poule/encrypted/stockage-syncable/photos/gopro/${gopro_fusion_folder}`;
|
|
let folder = `/home/poule/encrypted/stockage-syncable/photos/gopro/${gopro_fusion_folder}`
|
|
let subFolder = ""
|
|
|
|
let dossier_assemblages_output = '/home/poule/encrypted/stockage-syncable/photos/gopro/hugin_assemblages_script_output';
|
|
|
|
let mini_arguments: any = minimist(process.argv.slice(2))
|
|
console.log('mini_arguments', mini_arguments)
|
|
|
|
let goproMin = '015821'
|
|
let goproMax = '027265'
|
|
|
|
if (mini_arguments['folder']) {
|
|
folder = mini_arguments['folder']
|
|
}
|
|
if (mini_arguments['goproMin']) {
|
|
goproMin = mini_arguments['goproMin']
|
|
}
|
|
if (mini_arguments['goproMax']) {
|
|
goproMax = mini_arguments['goproMax']
|
|
}
|
|
|
|
function findMinMaxNumberOfPhotos(filesList: Array<string>) {
|
|
return {
|
|
min: goproMin,
|
|
max: goproMax,
|
|
}
|
|
}
|
|
|
|
function getGoproFiles(folder: string) {
|
|
console.log('getGoproFiles folder', folder)
|
|
return fs.readdirSync('' + folder)
|
|
}
|
|
|
|
function makeBashScriptHugin(minmax: any) {
|
|
|
|
console.log('makeBashScriptHugin')
|
|
// 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))
|
|
for (let ii: any = parseInt(minmax.min); ii <= parseInt(
|
|
minmax.max
|
|
); ii++) {
|
|
|
|
console.log('make PTO file : ii', ii)
|
|
// makePto(absolutePath, ii)
|
|
let currentNumber = `0${ii}`;
|
|
// let currentNumber = '080096';
|
|
let ptoContent = makePto(absolutePath, currentNumber);
|
|
let ptoFileName = `merging_${currentNumber}.pto`
|
|
let stitchedFileName = `assemblage_${currentNumber}`
|
|
|
|
let ptoPath = `${dossier_pto_output}/${ptoFileName}`
|
|
scriptsContent += '\n\n# capture n°' + currentNumber
|
|
scriptsContent += '\nhugin_executor' +
|
|
' ' + ptoPath + ' ' +
|
|
'--stitching ' +
|
|
'--prefix=' + stitchedFileName +
|
|
' -t=6'
|
|
scriptsContent += '\n # complétion des données gps depuis une des photos assemblées' +
|
|
'\nexiftool ' +
|
|
'-TagsFromFile ' +
|
|
absolutePath + '/GF' + currentNumber + '.JPG ' +
|
|
'-DateTimeOriginal ' +
|
|
'-SubSecTimeOriginal' +
|
|
' -Make="Tykayn" ' + dossier_pto_output + '/' + stitchedFileName + '.jpg ' +
|
|
'-overwrite_original ' + dossier_pto_output + '/' + stitchedFileName + '.jpg '
|
|
|
|
// console.log('ptoContent', ptoContent)
|
|
writeFile(ptoFileName, ptoContent)
|
|
|
|
}
|
|
writeFile('hugin_executor_from'+goproMin+'_to_'+goproMax+'.sh', scriptsContent)
|
|
|
|
|
|
}
|
|
|
|
function makePto(absolutePath: string, currentNumber: string) {
|
|
|
|
let front_picture_name = absolutePath + '/GF' + currentNumber + '.JPG';
|
|
let back_picture_name = absolutePath + '/GB' + currentNumber + '.JPG';
|
|
|
|
|
|
console.log('front_picture_name', front_picture_name)
|
|
console.log('back_picture_name', front_picture_name)
|
|
|
|
return `
|
|
# hugin project file
|
|
#hugin_ptoversion 2
|
|
p f2 w5662 h2831 v360 k0 E12.9717 R0 n"TIFF_m c:LZW r:CROP"
|
|
m i0
|
|
|
|
# image lines
|
|
#-hugin autoCenterCrop=1 cropFactor=3.66667
|
|
i w3104 h3000 f2 v187.621680193473 Ra0.929120004177094 Rb-2.97991991043091 Rc0.832589983940125 Rd-1.6331000328064 Re0.223350003361702 Eev12.97168 Er1 Eb1 r0 p0 y0 TrX0 TrY0 TrZ0 Tpy0 Tpp0 j0 a0 b0 c0 d0 e0 g0 t0 Va1 Vb0 Vc0 Vd0 Vx0 Vy0 S56,3048,0,3000 Vm5 n"${back_picture_name}"
|
|
#-hugin autoCenterCrop=1 cropFactor=3.66666674613953
|
|
i w3104 h3000 f2 v200.312016860549 Ra0.929120004177094 Rb-2.97991991043091 Rc0.832589983940125 Rd-1.6331000328064 Re0.223350003361702 Eev12.86747 Er1 Eb1 r-0.321229885118998 p0.498637821558678 y-179.883320935885 TrX0 TrY0 TrZ0 Tpy0 Tpp0 j0 a0 b0 c0 d0 e0 g0 t0 Va1 Vb0 Vc0 Vd0 Vx0 Vy0 S56,3048,0,3000 Vm5 n"${front_picture_name}"
|
|
|
|
|
|
# specify variables that should be optimized
|
|
v v0
|
|
v Ra0
|
|
v Rb0
|
|
v Rc0
|
|
v Rd0
|
|
v Re0
|
|
v Vb0
|
|
v Vc0
|
|
v Vd0
|
|
v v1
|
|
v Ra1
|
|
v Rb1
|
|
v Rc1
|
|
v Rd1
|
|
v Re1
|
|
v Eev1
|
|
v r1
|
|
v p1
|
|
v y1
|
|
v Vb1
|
|
v Vc1
|
|
v Vd1
|
|
v
|
|
|
|
|
|
# control points
|
|
c n0 N1 x931 y224 X2196 Y185 t0
|
|
c n0 N1 x2488.00001630569 y524.000007066704 X514.860630764196 Y399.786974637271 t0
|
|
c n0 N1 x2863.00001478066 y830.000009619205 X310 Y843 t0
|
|
c n0 N1 x2912.00000631564 y1960.00001513932 X165.422047127648 Y1942.23480647153 t0
|
|
c n0 N1 x109.000013207601 y1959.00001112345 X2860.90269812833 Y1909.02844555244 t0
|
|
c n0 N1 x866.000016448824 y2711.00000028952 X2283.94256385574 Y2796.23681774024 t0
|
|
c n0 N1 x121.000003370916 y993.000018856411 X2832.23948711881 Y1047.9747652351 t0
|
|
|
|
# masks
|
|
k i0 t1 p"252 628 484 351 745 156 1008 41 1121 2 1992 4 2289 127 2571 317 2769 515 2949 795 3050 1087 3095 1282 3105 1673 3050 1932 2938 2213 2766 2482 2610 2646 2401 2803 2179 2917 1984 2985 1879 3006 1251 3011 1079 2970 815 2860 573 2706 385 2531 231 2328 106 2080 38 1859 -5 1600 -8 1311 80 969 109 878"
|
|
k i1 t1 p"252 628 484 351 745 156 1008 41 1121 2 1992 4 2289 127 2571 317 2769 515 2949 795 3050 1087 3095 1282 3105 1673 3050 1932 2925 2205 2766 2482 2610 2646 2401 2803 2179 2917 1984 2985 1879 3006 1251 3011 1079 2970 815 2860 573 2706 385 2531 231 2328 106 2080 38 1859 -5 1600 -8 1311 80 969 109 878"
|
|
|
|
#hugin_optimizeReferenceImage 0
|
|
#hugin_blender internal
|
|
#hugin_remapper nona
|
|
#hugin_enblendOptions
|
|
#hugin_enfuseOptions
|
|
#hugin_hdrmergeOptions -m avg -c
|
|
#hugin_verdandiOptions --seam=blend
|
|
#hugin_edgeFillMode 0
|
|
#hugin_edgeFillKeepInput false
|
|
#hugin_outputLDRBlended true
|
|
#hugin_outputLDRLayers false
|
|
#hugin_outputLDRExposureRemapped false
|
|
#hugin_outputLDRExposureLayers false
|
|
#hugin_outputLDRExposureBlended false
|
|
#hugin_outputLDRStacks false
|
|
#hugin_outputLDRExposureLayersFused false
|
|
#hugin_outputHDRBlended false
|
|
#hugin_outputHDRLayers false
|
|
#hugin_outputHDRStacks false
|
|
#hugin_outputLayersCompression LZW
|
|
#hugin_outputImageType jpg
|
|
#hugin_outputImageTypeCompression LZW
|
|
#hugin_outputJPEGQuality 90
|
|
#hugin_outputImageTypeHDR exr
|
|
#hugin_outputImageTypeHDRCompression LZW
|
|
#hugin_outputStacksMinOverlap 0.7
|
|
#hugin_outputLayersExposureDiff 0.5
|
|
#hugin_outputRangeCompression 0
|
|
#hugin_optimizerMasterSwitch 6
|
|
#hugin_optimizerPhotoMasterSwitch 21
|
|
|
|
`
|
|
}
|
|
|
|
|
|
function writeFile(fileName: string, fileContent: any) {
|
|
console.log('write file', fileName)
|
|
|
|
return fs.writeFile(
|
|
`${dossier_pto_output}/${fileName}`,
|
|
fileContent,
|
|
'utf8',
|
|
(err) => {
|
|
if (err) {
|
|
console.log(`Error writing file: ${err}`)
|
|
}
|
|
}
|
|
)
|
|
}
|
|
|
|
|
|
let scriptsContent = '#!/bin/bash' +
|
|
'\n# éxécuter tous les fichiers PTO\n'+
|
|
'\ncd ' + dossier_assemblages_output + '\n';
|
|
|
|
function scriptHugin(ptoPath: string) {
|
|
scriptsContent += `hugin_executor main.pto --stitching --prefix=assemblage -t=6`
|
|
}
|
|
|
|
function main() {
|
|
|
|
let filesOfFolder = getGoproFiles(folder + subFolder)
|
|
console.log('filesOfFolder', filesOfFolder)
|
|
let minmax = findMinMaxNumberOfPhotos(filesOfFolder)
|
|
console.log('minmax', minmax)
|
|
makeBashScriptHugin(minmax)
|
|
|
|
|
|
}
|
|
|
|
// run it all
|
|
main()
|
|
|