Beispiel #1
0
# ==========================
#
# Let's start to use Lightmetrica by rendering a blank image.
# We first import the ``lightmetrica`` module, where we use ``lm`` as an alias of ``lightmetrica`` for simplicity.
#
# .. note::
#     Although we recommend to use Python API to organize the experiments, similar APIs can be accessible from C++. See `example directory`_ for the detail.
#
#     .. _example directory: https://github.com/hi2p-perim/lightmetrica-v3/tree/master/example
#
# .. note::
#     ``lmenv`` is a simple module to configure Lightmetrica envrionment from a specified file. Here we load ``.lmenv``. You want to create your own ``.lmenv`` file if you want to execute examples or tests by yourself. For detail, please refer to :ref:`executing_functional_tests`.
# -

import lmenv
lmenv.load('.lmenv')

import lightmetrica as lm

# + {"nbsphinx": "hidden"}
if not lm.Release:
    lm.debug.attach_to_debugger()

# + {"raw_mimetype": "text/restructuredtext", "active": ""}
# Lightmetrica offers an extension for the Jupyter notebook to support logging or interactive progress reporting inside the notebook. The extension can be loaded by a line magic command as below.
# -

# %load_ext lightmetrica_jupyter

# + {"raw_mimetype": "text/restructuredtext", "active": ""}
# After importing the module, you can initialize the framwork by calling :cpp:func:`lm::init` function. You can pass various arguments to configure the framework to the function, but here we keep it empty so that everything is configured to be default.
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# + {"raw_mimetype": "text/restructuredtext", "active": ""}
# .. _example_raycast:
#
# Raycasting a scene with OBJ models
# =======================================
#
# This example demonstrates how to render a scene with OBJ models using raycasting.
# -

import lmenv
env = lmenv.load('.lmenv')

import os
import numpy as np
import imageio
# %matplotlib inline
import matplotlib.pyplot as plt
import lightmetrica as lm
# %load_ext lightmetrica_jupyter

# + {"nbsphinx": "hidden"}
if not lm.Release:
    lm.debug.attach_to_debugger()
# -

lm.init()