/
simple_node.py
35 lines (29 loc) · 905 Bytes
/
simple_node.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Example of a simple node (backend)"""
import cv2
import numpy as np
from boxes import RootNode
class SimpleNode(RootNode):
"""A simple node that draws
a circle with a specific color
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.size = self.param["size"]
self.color = self.color_reversed(self.param["picker"])
def out_frame(self):
frame = self.get_frame(0)
if self.disabled:
return frame
height, width, channels = frame.shape
cv2.circle(
frame,
(np.int32(width * 0.5), np.int32(height * 0.5)),
self.size,
self.color,
-1,
)
return frame
def update(self, param):
self.disabled = param["disabled"]
self.size = param["size"]
self.color = self.color_reversed(param["picker"])