Skip to content

compute_flow

Alexandre Marcireau edited this page May 24, 2019 · 13 revisions

In header "../third_party/tarsier/source/compute_flow.hpp"

Adapted from Asynchronous frameless event-based optical flow, Bensoman et al.

tarsier::compute_flow evaluates the optical flow.

namespace tarsier {
    template <typename Event, typename Flow, typename EventToFlow, typename HandleFlow>
    class compute_flow {
        public:
        compute_flow(
            uint16_t width,
            uint16_t height,
            uint16_t spatial_window,
            uint64_t temporal_window,
            std::size_t minimum_number_of_events,
            EventToFlow event_to_flow,
            HandleFlow handle_flow);

        /// operator() handles an event.
        virtual void operator()(Event event);
    };
}
  • Event is the input type. It must have at least the properties t, x and y.
  • Flow is the output type.
  • The expression event_to_flow(event, vx, vy), where event is an Event object and vx and vy are floats, must be valid and return a Flow object.
  • The expression handle_flow(flow), where flow is a Flow object, must be valid.
  • width and height are the maximum x and y coordinates plus one (if x is in the integer range [0, 319], width must be 320).
  • spatial_window is the radius used to select event that participate in a flow computation (if spatial_window is 2, a 5 x 5 pixel area is used).
  • temporal_window is the oldest an event can be to participate in a flow computation.

Event and Flow must be specified when using make_compute_flow:

struct event {
    uint64_t t;
    uint16_t x;
    uint16_t y;
};

struct flow {
    uint16_t x;
    uint16_t y;
    float vx;
    float vy;
};

auto compute_flow = tarsier::make_compute_flow<event, flow>(
    320,
    240,
    2,
    1e6,
    [](event event, float vx, float vy) -> flow {
        return {event.x, event.y, vx, vy};
    },
    [](flow flow) {
        // do something with flow
    });
Clone this wiki locally