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:
Rishabh Shukla
2022-01-26 04:35:32 +05:30
committed by GitHub
parent 28b648361b
commit 287d7e2be1
2 changed files with 23 additions and 15 deletions
+9 -3
View File
@@ -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;
}
+14 -12
View File
@@ -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();
});
});
});