|
9 | 9 | "# Install dependencies for this example\n", |
10 | 10 | "# Note: This does not include itkwidgets, itself\n", |
11 | 11 | "# The page may need to be reloaded after ipywebrtc is installed\n", |
| 12 | + "# And another note: As of this writing, ipywebrtc has not been updated to work\n", |
| 13 | + "# with JupyterLab 2 or JupyterLab 3 -- JupyterLab 1 or the Jupyter Notebook is required.\n", |
12 | 14 | "import sys\n", |
13 | | - "!{sys.executable} -m pip install itk-io ipywebrtc>=0.5.1" |
| 15 | + "!{sys.executable} -m pip install itk-io ipywebrtc" |
14 | 16 | ] |
15 | 17 | }, |
16 | 18 | { |
17 | 19 | "cell_type": "code", |
18 | | - "execution_count": 1, |
| 20 | + "execution_count": 7, |
19 | 21 | "metadata": {}, |
20 | 22 | "outputs": [], |
21 | 23 | "source": [ |
22 | 24 | "from urllib.request import urlretrieve\n", |
23 | 25 | "import os\n", |
| 26 | + "import time\n", |
24 | 27 | "\n", |
25 | 28 | "import itk\n", |
26 | 29 | "\n", |
|
31 | 34 | }, |
32 | 35 | { |
33 | 36 | "cell_type": "code", |
34 | | - "execution_count": 2, |
| 37 | + "execution_count": 3, |
35 | 38 | "metadata": {}, |
36 | 39 | "outputs": [], |
37 | 40 | "source": [ |
|
44 | 47 | }, |
45 | 48 | { |
46 | 49 | "cell_type": "code", |
47 | | - "execution_count": 3, |
| 50 | + "execution_count": 4, |
48 | 51 | "metadata": {}, |
49 | 52 | "outputs": [ |
50 | 53 | { |
51 | 54 | "data": { |
52 | 55 | "application/vnd.jupyter.widget-view+json": { |
53 | | - "model_id": "2d337065a4ba48bdaf7693d44eae7d9c", |
| 56 | + "model_id": "216f67a967bb476cafa57ef208dc6df7", |
54 | 57 | "version_major": 2, |
55 | 58 | "version_minor": 0 |
56 | 59 | }, |
57 | 60 | "text/plain": [ |
58 | | - "Viewer(annotations=False, cmap='BuRd', geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image=<it…" |
| 61 | + "Viewer(annotations=False, cmap=['BuRd'], geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image=<…" |
59 | 62 | ] |
60 | 63 | }, |
61 | 64 | "metadata": {}, |
|
71 | 74 | }, |
72 | 75 | { |
73 | 76 | "cell_type": "code", |
74 | | - "execution_count": 4, |
| 77 | + "execution_count": 5, |
75 | 78 | "metadata": {}, |
76 | 79 | "outputs": [ |
77 | 80 | { |
78 | 81 | "data": { |
79 | 82 | "application/vnd.jupyter.widget-view+json": { |
80 | | - "model_id": "19b8e9ffead7440ea807df5d810c7a16", |
| 83 | + "model_id": "045847c75ed440b4a020960e705f4378", |
81 | 84 | "version_major": 2, |
82 | 85 | "version_minor": 0 |
83 | 86 | }, |
84 | 87 | "text/plain": [ |
85 | | - "VideoRecorder(autosave=True, filename='widget_video.webm', stream=Viewer(annotations=False, cmap='BuRd', geome…" |
| 88 | + "VideoRecorder(autosave=True, filename='widget_video.webm', stream=Viewer(annotations=False, background=(0.9333…" |
86 | 89 | ] |
87 | 90 | }, |
88 | 91 | "metadata": {}, |
|
94 | 97 | "recorder" |
95 | 98 | ] |
96 | 99 | }, |
| 100 | + { |
| 101 | + "cell_type": "markdown", |
| 102 | + "metadata": {}, |
| 103 | + "source": [ |
| 104 | + "The recorder widget has button to record, playback, and download the video, but this is also possible programmatically." |
| 105 | + ] |
| 106 | + }, |
| 107 | + { |
| 108 | + "cell_type": "code", |
| 109 | + "execution_count": 9, |
| 110 | + "metadata": {}, |
| 111 | + "outputs": [], |
| 112 | + "source": [ |
| 113 | + "recorder.recording = True\n", |
| 114 | + "time.sleep(3)\n", |
| 115 | + "recorder.recording = False" |
| 116 | + ] |
| 117 | + }, |
| 118 | + { |
| 119 | + "cell_type": "code", |
| 120 | + "execution_count": 13, |
| 121 | + "metadata": {}, |
| 122 | + "outputs": [], |
| 123 | + "source": [ |
| 124 | + "# Save to a different file in a different format\n", |
| 125 | + "recorder.save('video.mp4')" |
| 126 | + ] |
| 127 | + }, |
97 | 128 | { |
98 | 129 | "cell_type": "markdown", |
99 | 130 | "metadata": {}, |
|
144 | 175 | "nbconvert_exporter": "python", |
145 | 176 | "pygments_lexer": "ipython3", |
146 | 177 | "version": "3.7.6" |
| 178 | + }, |
| 179 | + "toc": { |
| 180 | + "base_numbering": 1, |
| 181 | + "nav_menu": {}, |
| 182 | + "number_sections": false, |
| 183 | + "sideBar": false, |
| 184 | + "skip_h1_title": false, |
| 185 | + "title_cell": "Table of Contents", |
| 186 | + "title_sidebar": "Contents", |
| 187 | + "toc_cell": false, |
| 188 | + "toc_position": {}, |
| 189 | + "toc_section_display": false, |
| 190 | + "toc_window_display": false |
147 | 191 | } |
148 | 192 | }, |
149 | 193 | "nbformat": 4, |
|
0 commit comments