Closed seantronsen closed 5 months ago
The farther I get into my vision class, the more the need for a tool like this starts to develop. Honestly, setting this up wouldn't even be that hard, really it's just that I don't have the time to do it this weekend because of the homework (most likely).
All this should require is modifying the Animator
class such that it has methods which can reset, pause/play, go back one frame (tick), and go forward one tick.
There are some additional nuances, like should we require the user to write their own buttons for this sort of thing? Also, should we provide a reverse feature?
One thing I'm hung up on is that I'm not sure if it would be wise to provide a slider that lets the user go back to a specific point. At least, I'm not sure if that should fall under the scope of this class specifically. It seems out of scope since not everything will function off a set number of frames and more importantly, it unnecessarily increases the complexity of the linking behavior requested in #22
I plan to leave reverse
out for now since it would require some simplifying assumptions, namely abuse of integer arithmetic. However, underflow behavior likely isn't the best thing to use since it will skip to an arbitrary position in the sequence for each underflow.
As for the buttons, I don't think it would be unreasonable to provide our own little "animation control bar" widget that can wire into a specific animator.
Alright, so I've added onto the Animator
class such that it now has basic controls (excluding reverse) and also created a new control bar class for the animator AnimatorControlBar
which is housed in the same source file.
Results appear as follows:
def demo_3d_prototype():
def callback(animation_tick, sigma, **_):
gaussian = cv2.getGaussianKernel(20, sigma=sigma)
gaussian = gaussian * gaussian.T # pyright: ignore
return gaussian * ((animation_tick % 500) + 1) * 10
viewer = PlotViewer()
animator = Animator(fps=60, contents=Plot3DPane(callback))
d3plot = animator.animation_content
control_bar = AnimatorControlBar(animator=animator)
t_sigma = ParameterTrackbar("sigma", 1, 25, init=5)
viewer.add_panes(d3plot, control_bar, t_sigma)
viewer.run()
Functionality available as of commit: 7643c84
Closing.
The current implementation does not allow users to control output meaningfully. There are no controls and the animation just runs on until the end of time.