OpticalExpansion

class grid.model.perception.ttc.optexp.OpticalExpansion(*args, **kwargs)

Optical Expansion model for Time to Collision (TTC) estimation.

This class implements a model that estimates the time to collision for each pixel in an RGB image by leveraging optical flow and disparity.

Credits:

https://github.com/gengshan-y/expansion

License:

This code is licensed under the MIT License.

__init__(fac=1, maxdisp=128)
Return type:

None

run(rgbimage)

Uses optical expansion to predict pixel-wise time to collision given an RGB image, relative to the previous. If this is the first image being passed, initializes the routine and returns nothing.

Parameters:

rgbimage (np.ndarray) -- Input RGB image

Returns:

2D image representing pixel-wise time to collision. occ (np.ndarray): 2D image representing pixel-wise occupancy. logmid (np.ndarray): 2D image representing logarithmic motion in depth. flow (np.ndarray): 2D image representing pixel-wise optical flow.

Return type:

ttc (np.ndarray)

Example

>>> optexp = OpticalExpansion()
>>> optexp.run(image1)
>>> ttc, occ, logmid, flow = optexp.run(image2)