> ## Documentation Index
> Fetch the complete documentation index at: https://docs.generalrobotics.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# OpticalExpansion 

The `OpticalExpansion` class provides core functionality for this module.

<Tabs>
  <Tab title="License">
    This code is licensed under the MIT License.
  </Tab>

  <Tab title="Source">
    [https://github.com/gengshan-y/expansion](https://github.com/gengshan-y/expansion)
  </Tab>
</Tabs>

<ResponseField name="class OpticalExpansion()">
  <ResponseField name="use_local" type="boolean" default="True">
    If True, inference call is run on the local VM, else offloaded onto GRID-Cortex. Defaults to False.
  </ResponseField>
</ResponseField>

<ResponseField name="def run()">
  <ResponseField name="rgbimage" type="np.ndarray" required="True">
    Routes inference to GRID-Cortex if available; otherwise, uses local inference.

    Args:
    rgbimage (np.ndarray): The input RGB image.

    Returns:
    dict: The output containing TTC, occupancy, logarithmic motion in depth, and optical flow.
  </ResponseField>

  <ResponseField name="Returns" type="np.ndarray">
    The predicted output.
  </ResponseField>
</ResponseField>

<RequestExample>
  ```python Inference Call theme={null}
  from grid.model.perception.ttc.optexp import OpticalExpansion
  car = AirGenCar()

  # We will be capturing an image from the AirGen simulator 
  # and run model inference on it.

  img =  car.getImage("front_center", "rgb").data

  model = OpticalExpansion(use_local = False)
  result = model.run(rgbimage=img)
  print(result.shape)
  ```
</RequestExample>
