I have Jupyter Notebook tutorials that I used Matplotlibe and ipywidgets(interact) to display video with NumPy 3D format.
class JupyterDisplay():
def __init__(self, video, median_filter_flag=False, color='gray', imgSizex=5, imgSizey=5, IntSlider_width='500px'):
self.color = color
self.video = video
self.imgSizex = imgSizex
self.imgSizey = imgSizey
self.median_filter_flag = median_filter_flag
interact(self.display, frame=widgets.IntSlider(min=0, max=self.video.shape[0] - 1, step=1, value=10,
layout=Layout(width=IntSlider_width),
readout_format='10', continuous_update=False,
description='Frame:'))
def display(self, frame):
fig = plt.figure(figsize=(self.imgSizex, self.imgSizey))
ax = fig.add_axes([0, 0, 1, 1])
if self.median_filter_flag:
frame_v = median_filter(self.video[int(frame), :, :], 3)
else:
frame_v = self.video[int(frame), :, :]
myplot = ax.imshow(frame_v, cmap=self.color)
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
plt.colorbar(myplot, cax=cax)
plt.show()
I want to create an HTML version from tutorials with sphinx make HTML. But the video is not visualized in the HTML version. What is the best way to display dynamic video in the HTML version?
I can create the mp4 from videos, but in this case, I need to have a conditional Jupyter cell to only run this part of the code when making HTML Sphinx used. Can you inform me how I should define this conditional cell?