WaitForAll sync node

This commit is contained in:
Michal Kolář
2024-03-20 15:45:45 +01:00
committed by Stanislav Fifik
parent a3210f7ef7
commit da24d62d61
2 changed files with 42 additions and 0 deletions

41
src/nodes/WaitForAll.ts Normal file
View 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;
}
}

View File

@@ -33,3 +33,4 @@ export {default as FaceFeaturePosition} from './AI/FaceFeaturePosition';
export {default as Eval} from './Eval';
export {default as QRCodeDetector} from './QRCodeDetector';
export {default as MarkerDetector} from './MarkerDetector';
export {default as WaitForAll} from './WaitForAll';