-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[api]: Fix invalid parameter encoding; Handle error on PixInsight scr…
…ipts
- Loading branch information
Showing
11 changed files
with
1,125 additions
and
1,082 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,74 @@ | ||
function decodeParams(hex) { | ||
let decoded = '' | ||
const buffer = new Uint8Array(hex.length / 4) | ||
|
||
for (let i = 0; i < hex.length; i += 2) { | ||
decoded += String.fromCharCode(parseInt(hex.substr(i, 2), 16)) | ||
for (let i = 0; i < hex.length; i += 4) { | ||
buffer[i / 4] = parseInt(hex.substr(i, 4), 16) | ||
} | ||
|
||
return JSON.parse(decoded) | ||
return JSON.parse(String.fromCharCode.apply(null, buffer)) | ||
} | ||
|
||
function abe() { | ||
const input = decodeParams(jsArguments[0]) | ||
const data = { | ||
success: true, | ||
errorMessage: null, | ||
outputImage: null, | ||
} | ||
|
||
const targetPath = input.targetPath | ||
const outputPath = input.outputPath | ||
const statusPath = input.statusPath | ||
try { | ||
const input = decodeParams(jsArguments[0]) | ||
|
||
console.writeln("targetPath=" + targetPath) | ||
console.writeln("outputPath=" + outputPath) | ||
console.writeln("statusPath=" + statusPath) | ||
const targetPath = input.targetPath | ||
const outputPath = input.outputPath | ||
const statusPath = input.statusPath | ||
|
||
const window = ImageWindow.open(targetPath)[0] | ||
console.writeln("targetPath=" + targetPath) | ||
console.writeln("outputPath=" + outputPath) | ||
console.writeln("statusPath=" + statusPath) | ||
|
||
const P = new AutomaticBackgroundExtractor | ||
P.tolerance = 1.000 | ||
P.deviation = 0.800 | ||
P.unbalance = 1.800 | ||
P.minBoxFraction = 0.050 | ||
P.maxBackground = 1.0000 | ||
P.minBackground = 0.0000 | ||
P.useBrightnessLimits = false | ||
P.polyDegree = 4 | ||
P.boxSize = 5 | ||
P.boxSeparation = 5 | ||
P.modelImageSampleFormat = AutomaticBackgroundExtractor.prototype.f32 | ||
P.abeDownsample = 2.00 | ||
P.writeSampleBoxes = false | ||
P.justTrySamples = false | ||
P.targetCorrection = AutomaticBackgroundExtractor.prototype.Subtract | ||
P.normalize = true | ||
P.discardModel = true | ||
P.replaceTarget = true | ||
P.correctedImageId = "" | ||
P.correctedImageSampleFormat = AutomaticBackgroundExtractor.prototype.SameAsTarget | ||
P.verboseCoefficients = false | ||
P.compareModel = false | ||
P.compareFactor = 10.00 | ||
const window = ImageWindow.open(targetPath)[0] | ||
|
||
P.executeOn(window.mainView) | ||
const P = new AutomaticBackgroundExtractor | ||
P.tolerance = 1.000 | ||
P.deviation = 0.800 | ||
P.unbalance = 1.800 | ||
P.minBoxFraction = 0.050 | ||
P.maxBackground = 1.0000 | ||
P.minBackground = 0.0000 | ||
P.useBrightnessLimits = false | ||
P.polyDegree = 4 | ||
P.boxSize = 5 | ||
P.boxSeparation = 5 | ||
P.modelImageSampleFormat = AutomaticBackgroundExtractor.prototype.f32 | ||
P.abeDownsample = 2.00 | ||
P.writeSampleBoxes = false | ||
P.justTrySamples = false | ||
P.targetCorrection = AutomaticBackgroundExtractor.prototype.Subtract | ||
P.normalize = true | ||
P.discardModel = true | ||
P.replaceTarget = true | ||
P.correctedImageId = "" | ||
P.correctedImageSampleFormat = AutomaticBackgroundExtractor.prototype.SameAsTarget | ||
P.verboseCoefficients = false | ||
P.compareModel = false | ||
P.compareFactor = 10.00 | ||
|
||
window.saveAs(outputPath, false, false, false, false) | ||
P.executeOn(window.mainView) | ||
|
||
window.forceClose() | ||
window.saveAs(outputPath, false, false, false, false) | ||
|
||
console.writeln("abe finished") | ||
window.forceClose() | ||
|
||
const json = { | ||
outputImage: outputPath, | ||
} | ||
data.outputImage = outputPath | ||
|
||
File.writeTextFile(statusPath, "@" + JSON.stringify(json) + "#") | ||
console.writeln("abe finished") | ||
} catch (e) { | ||
data.success = false | ||
data.errorMessage = e.message | ||
console.writeln(data.errorMessage) | ||
} finally { | ||
File.writeTextFile(statusPath, "@" + JSON.stringify(data) + "#") | ||
} | ||
} | ||
|
||
abe() |
Oops, something went wrong.