Skip to content

Commit 3dd5f34

Browse files
committed
update blocks to track bdsim changes
1 parent 5f2f251 commit 3dd5f34

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

machinevisiontoolbox/blocks/camera.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ def __init__(self, camera=None, args={}, **blockargs):
6262
raise ValueError("camera is not defined")
6363

6464
super().__init__(**blockargs)
65-
self.type = "camera"
6665

6766
self.camera = camera
6867

69-
def output(self, t=None):
70-
return [self.camera.project_point(self.inputs[0], pose=self.inputs[1])]
68+
def output(self, t, inports, x):
69+
return [self.camera.project_point(inports[0], pose=inports[1])]
7170

7271

7372
# ------------------------------------------------------------------------ #
@@ -119,16 +118,15 @@ def __init__(self, camera, depth=1, depthest=False, **blockargs):
119118
raise ValueError("camera is not defined")
120119

121120
super().__init__(**blockargs)
122-
self.type = "visjac_p"
123121

124122
self.camera = camera
125123
self.depthest = depthest
126124
self.depth = depth
127125

128-
def output(self, t=None):
126+
def output(self, t, inports, x):
129127
# do depth estimation here
130128

131-
J = self.camera.visjac_p(self.inputs[0], self.depth)
129+
J = self.camera.visjac_p(inports[0], self.depth)
132130
return [J]
133131

134132

@@ -176,14 +174,13 @@ def __init__(self, camera, P, frame="world", method="iterative", **blockargs):
176174
raise ValueError("camera is not defined")
177175

178176
super().__init__(**blockargs)
179-
self.type = "estpose_p"
180177

181178
self.camera = camera
182179
self.P = P
183180
self.method = method
184181

185-
def output(self, t=None):
186-
p = self.inputs[0]
182+
def output(self, t, inports, x):
183+
p = inports[0]
187184
T = self.camera.estpose(self.P, p, method=self.method)
188185
return [T]
189186

@@ -297,14 +294,16 @@ def __init__(
297294
# TODO, wire width
298295
# inherit names from wires, block needs to be able to introspect
299296

300-
def start(self, state=None):
297+
def start(self, simstate):
298+
super().start(simstate)
299+
301300
# init the arrays that hold the data
302301
self.u_data = []
303302
self.v_data = []
304303
self.t_data = []
305304

306305
# create the figures
307-
self.fig = self.create_figure(state)
306+
self.fig = self.create_figure(simstate)
308307
self.ax = self.fig.add_subplot(111)
309308
self.camera._init_imageplane(ax=self.ax)
310309

@@ -330,12 +329,10 @@ def start(self, state=None):
330329
state.watchlist.append(plug)
331330
state.watchnamelist.append(str(plug))
332331

333-
super().start()
334-
335-
def step(self, state=None):
332+
def step(self, t, inports):
336333
# inputs are set
337-
self.t_data.append(state.t)
338-
u, v = self.inputs[0]
334+
self.t_data.append(t)
335+
u, v = inports[0]
339336

340337
if self.retain:
341338
self.u_data.append(u)
@@ -346,7 +343,4 @@ def step(self, state=None):
346343

347344
self.line.set_data(self.u_data, self.v_data)
348345

349-
if self.bd.runtime.options.animation:
350-
self.fig.canvas.flush_events()
351-
352-
super().step(state=state)
346+
super().step(t, inports)

0 commit comments

Comments
 (0)