Skip to content

Commit

Permalink
Update blueprint examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed May 3, 2023
1 parent 16db753 commit 0944f72
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 13 deletions.
73 changes: 60 additions & 13 deletions examples/python/blueprint/blueprint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Run one of these 3"
"## Run one of these 4"
]
},
{
Expand All @@ -45,7 +45,9 @@
"# No blueprint control... set_panel doesn't work\n",
"rr.init(\"Space\")\n",
"rr.start_web_viewer_server()\n",
"out = rr.memory_recording()"
"out = rr.memory_recording()\n",
"\n",
"ENABLE_HEURISTICS = False"
]
},
{
Expand All @@ -57,7 +59,9 @@
"# Blueprint control, but no default view\n",
"rr.init(\"Space\", init_logging=True, init_blueprint=True)\n",
"rr.start_web_viewer_server()\n",
"out = rr.memory_recording()"
"out = rr.memory_recording()\n",
"\n",
"ENABLE_HEURISTICS = False"
]
},
{
Expand All @@ -69,7 +73,24 @@
"# Blueprint control on top of existing auto\n",
"rr.init(\"Space\", init_logging=True, init_blueprint=True, append_blueprint=True)\n",
"rr.start_web_viewer_server()\n",
"out = rr.memory_recording()"
"out = rr.memory_recording()\n",
"\n",
"ENABLE_HEURISTICS = False"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Blueprint control on top of manual auto (for notebooks this is almost identical to the above)\n",
"rr.init(\"Space\", init_logging=True, init_blueprint=True)\n",
"rr.start_web_viewer_server()\n",
"\n",
"ENABLE_HEURISTICS = True\n",
"# We can't do this here, we need to do it AFTER we reset the memory recording\n",
"#rr.enable_heuristics()"
]
},
{
Expand All @@ -86,8 +107,12 @@
"metadata": {},
"outputs": [],
"source": [
"# This resets the Recording AND the blueprint\n",
"out = rr.memory_recording()\n",
"\n",
"if ENABLE_HEURISTICS:\n",
" rr.enable_heuristics()\n",
"\n",
"# TODO: make this one call\n",
"rr.set_panel(\"blueprint_panel\", expanded=False)\n",
"rr.set_panel(\"selection_panel\", expanded=False)\n",
Expand All @@ -96,17 +121,39 @@
"image = cv2.imread('truck.jpg', cv2.IMREAD_COLOR)\n",
"image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n",
"\n",
"scale_percent = 100 # percent of original size\n",
"width = int(image.shape[1] * scale_percent / 100)\n",
"height = int(image.shape[0] * scale_percent / 100)\n",
"dim = (width, height)\n",
" \n",
"# resize image\n",
"resized = cv2.resize(image, dim, interpolation = cv2.INTER_AREA)\n",
"\n",
"rr.log_image('truck', resized)\n",
"rr.log_image('truck', image)\n",
"out"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"flipped = cv2.flip(image, 1)\n",
"rr.log_image('flipped', flipped)\n",
"out"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# TODO: how do we reset *just* the blueprint in this context?\n",
"# out = rr.memory_recording()\n",
"rr.add_space_view(\"composite\", \"/\", [\"truck\",\"flipped\"])\n",
"out"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
5 changes: 5 additions & 0 deletions examples/python/blueprint/blueprint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import time

import rerun as rr

Expand All @@ -9,12 +10,16 @@ def main() -> None:
"--init-logging", action="store_true", help="'Accidentally initialize the logging stream as well'"
)
parser.add_argument("--append", action="store_true", help="Append to the blueprint instead of overwriting it")
parser.add_argument("--enable-heuristics", action="store_true", help="Enable heuristics for the blueprint")

args = parser.parse_args()

rr.init("Space", init_blueprint=True, init_logging=args.init_logging, append_blueprint=args.append)
rr.connect()

if args.enable_heuristics:
rr.enable_heuristics()

rr.add_space_view("earth-centric", "transforms3d/sun/planet", ["transforms3d/sun", "transforms3d/sun/planet"])


Expand Down

0 comments on commit 0944f72

Please sign in to comment.