Merge pull request #61 from ccpandhare/modules

Added FisheyeGl Module
This commit is contained in:
Chinmay Pandhare
2017-07-29 22:30:30 +05:30
committed by GitHub
6 changed files with 749 additions and 122 deletions

File diff suppressed because one or more lines are too long

View File

@@ -47,3 +47,24 @@ where `options` is an object with the property `colormap`. `options.colormap` ca
* "fastie" : [[0, [255, 255, 255], [0, 0, 0]], [0.167, [0, 0, 0], [255, 255, 255]], [0.33, [255, 255, 255], [0, 0, 0]], [0.5, [0, 0, 0], [140, 140, 255]], [0.55, [140, 140, 255], [0, 255, 0]], [0.63, [0, 255, 0], [255, 255, 0]], [0.75, [255, 255, 0], [255, 0, 0]], [0.95, [255, 0, 0], [255, 0, 255]]]
* A custom array.
## FisheyeGl (fisheye-gl)
This module is used for correcting Fisheye or Lens Distortion
#### Usage
```js
sequencer.loadImage('PATH')
.addSteps('fisheye-gl',options)
.run()
```
where `options` is an object with the following properties:
* a : a correction (0 to 4; default 1)
* b : b correction (0 to 4; default 1)
* Fx : x correction (0 to 4; default 1)
* Fy : y correction (0 to 4; default 1)
* scale : The ratio to which the original image is to be scaled (0 to 20; default 1.5)
* x : Field of View x (0 to 2; default 1)
* y : Field of View y (0 to 2; default 1)

View File

@@ -21,6 +21,7 @@
},
"dependencies": {
"bootstrap": "~3.2.0",
"fisheyegl": "^0.1.2",
"font-awesome": "~4.5.0",
"jquery": "~2",
"urify": "^2.1.0"

View File

@@ -7,6 +7,7 @@ function AddStep(ref, image, name, o) {
o.selector = o_.selector || 'ismod-' + name;
o.container = o_.container || ref.options.selector;
o.image = image;
o.inBrowser = ref.options.inBrowser;
o.step = {
name: o.name,

View File

@@ -8,5 +8,6 @@ module.exports = {
'do-nothing-pix': require('./modules/DoNothingPix/Module.js'),
'invert': require('./modules/Invert/Module'),
'crop': require('./modules/Crop/Module'),
'segmented-colormap': require('./modules/SegmentedColormap/Module')
'segmented-colormap': require('./modules/SegmentedColormap/Module'),
'fisheye-gl': require('./modules/FisheyeGl/Module')
}

View File

@@ -0,0 +1,55 @@
/*
* Creates Fisheye Effect
*/
module.exports = function DoNothing(options,UI) {
options = options || {};
options.title = "Fisheye GL";
var output;
UI.onSetup(options.step);
require('fisheyegl');
function draw(input,callback) {
UI.onDraw(options.step);
const step = this;
if (!options.inBrowser) { // This module is only for browser
this.output = input;
callback();
}
else {
if (!document.querySelector('#image-sequencer-canvas')) {
var canvas = document.createElement('canvas');
canvas.style.display = "none";
canvas.setAttribute('id','image-sequencer-canvas');
document.body.append(canvas);
}
else var canvas = document.querySelector('#image-sequencer-canvas');
distorter = FisheyeGl({
selector: "#image-sequencer-canvas"
});
distorter.lens.a = options.a || distorter.lens.a;
distorter.lens.b = options.b || distorter.lens.b;
distorter.lens.Fx = options.Fx || distorter.lens.Fx;
distorter.lens.Fy = options.Fy || distorter.lens.Fy;
distorter.lens.scale = options.scale || distorter.lens.scale;
distorter.fov.x = options.x || distorter.fov.x;
distorter.fov.y = options.y || distorter.fov.y;
distorter.setImage(input.src,function(){
step.output = {src: canvas.toDataURL(), format: input.format};
options.step.output = step.output.src;
callback();
UI.onComplete(options.step);
});
}
}
return {
options: options,
draw: draw,
output: output,
UI: UI
}
}