mirror of
https://github.com/publiclab/image-sequencer.git
synced 2026-06-16 04:33:26 +02:00
fix blob analysis to work in node (#1589)
Co-authored-by: h <f> Co-authored-by: Harsh Khandeparkar <34770591+HarshKhandeparkar@users.noreply.github.com> Co-authored-by: Jeffrey Warren <jeff@unterbahn.com>
This commit is contained in:
@@ -10,9 +10,15 @@ module.exports = function BlobAnalysis(options, UI){
|
||||
|
||||
var step = this;
|
||||
|
||||
function extraManipulation(pixels){
|
||||
|
||||
pixels = require('./BlobAnalysis')(pixels);
|
||||
function extraManipulation(pixels, setRenderState, generateOutput){
|
||||
setRenderState(false);
|
||||
if (!options.inBrowser) {
|
||||
require('../_nomodule/gl-context')(input, callback, step, options);
|
||||
} else{
|
||||
pixels = require('./BlobAnalysis')(pixels);
|
||||
setRenderState(true);
|
||||
generateOutput();
|
||||
}
|
||||
return pixels;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,19 +15,21 @@ module.exports = function runInBrowserContext(input, callback, step, options) {
|
||||
is not available otherwise */
|
||||
page.goto('https://google.com').then(() => {
|
||||
page.addScriptTag({ path: require('path').join(__dirname, '../../../dist/image-sequencer.js') }).then(() => {
|
||||
page.evaluate((options) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
var sequencer = ImageSequencer();
|
||||
sequencer.loadImage(options.input.src);
|
||||
sequencer.addSteps(options.modOptions.step, options.modOptions);
|
||||
sequencer.run(function cb(out) {
|
||||
resolve(sequencer.steps[1].output.src);
|
||||
page.addScriptTag({path: require('path').join(__dirname, '../../../node_modules/opencv.js/opencv.js')}).then(() => {
|
||||
page.evaluate((options) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
var sequencer = ImageSequencer();
|
||||
sequencer.loadImage(options.input.src);
|
||||
sequencer.addSteps(options.modOptions.step, options.modOptions);
|
||||
sequencer.run(function cb(out) {
|
||||
resolve(sequencer.steps[1].output.src);
|
||||
});
|
||||
});
|
||||
}, obj).then(el => {
|
||||
browser.close().then(() => {
|
||||
step.output = { src: el, format: input.format };
|
||||
callback();
|
||||
});
|
||||
});
|
||||
}, obj).then(el => {
|
||||
browser.close().then(() => {
|
||||
step.output = { src: el, format: input.format };
|
||||
callback();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user