WaitForAll sync node
This commit is contained in:
41
src/nodes/WaitForAll.ts
Normal file
41
src/nodes/WaitForAll.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import {ImageVar} from './io/AbstractIOSet';
|
||||||
|
import Node from "./Node";
|
||||||
|
import {waitForMedia} from "../utils";
|
||||||
|
|
||||||
|
const inputs = {
|
||||||
|
image0: {
|
||||||
|
type: 'Image'
|
||||||
|
} as ImageVar,
|
||||||
|
image1: {
|
||||||
|
type: 'Image'
|
||||||
|
} as ImageVar,
|
||||||
|
}
|
||||||
|
|
||||||
|
const outputs = {
|
||||||
|
image0: {
|
||||||
|
type: 'Image'
|
||||||
|
} as ImageVar,
|
||||||
|
image1: {
|
||||||
|
type: 'Image'
|
||||||
|
} as ImageVar,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class WaitForAll extends Node<typeof inputs, typeof outputs> {
|
||||||
|
constructor(options = {}) {
|
||||||
|
super('WaitForAll', inputs, outputs);
|
||||||
|
}
|
||||||
|
|
||||||
|
async _update() {
|
||||||
|
if (!(this.in.image0.value && this.in.image1.value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
waitForMedia(this.in.image0.value),
|
||||||
|
waitForMedia(this.in.image1.value)
|
||||||
|
])
|
||||||
|
|
||||||
|
this.out.image0.value = this.in.image0.value;
|
||||||
|
this.out.image1.value = this.in.image1.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,3 +33,4 @@ export {default as FaceFeaturePosition} from './AI/FaceFeaturePosition';
|
|||||||
export {default as Eval} from './Eval';
|
export {default as Eval} from './Eval';
|
||||||
export {default as QRCodeDetector} from './QRCodeDetector';
|
export {default as QRCodeDetector} from './QRCodeDetector';
|
||||||
export {default as MarkerDetector} from './MarkerDetector';
|
export {default as MarkerDetector} from './MarkerDetector';
|
||||||
|
export {default as WaitForAll} from './WaitForAll';
|
||||||
|
|||||||
Reference in New Issue
Block a user