[source]

USBDevice

pyaer.device.USBDevice()

Base class for all USB devices.

This class is the base of DVS128, DAVIS240, DAVIS346 and DYNAPSE.


open

open(device_type, device_id=1, bus_number_restrict=0, dev_address_restrict=0, serial_number='')

Open USB deivce.

Arguments

  • device_type: int
    Device type:
    libcaer.CAER_DEVICE_DVS128, libcaer.CAER_DEVICE_EDVS, libcaer.CAER_DEVICE_DAVIS, libcaer.CAER_DEVICE_DAVIS_FX2, libcaer.CAER_DEVICE_DAVIS_FX3, libcaer.CAER_DEVICE_DAVIS_RPI, libcaer.CAER_DEVICE_DYNAPSE.
  • device_id: int
    a unique ID to identify the device from others. Will be used as the source for EventPackets being generate from its data.
    default is 1.
  • bus_number_restrict: int
    restrict the search for viable devices to only this USB bus number.
    default is 0.
  • dev_address_restrict: int
    restrict the search for viable devices to only this USB device address.
    default is 0.
  • serial_number: str
    restrict the search for viable devices to only devices which do possess the given Serial Number in their USB SerialNumber descriptor.
    default is ""

data_start

data_start()

Start data transmission.

Returns

  • flag: bool
    Return True if the data transmission is initialized successfully. Otherwise False.

data_stop

data_stop()

Stop data transmission.

This method stops the data transmission only. Note that this method does not destroy the respective device handle.


close

close()

Close USB device.

This method closes an opened USB device if the respective handle is not None.


shutdown

shutdown()

Shutdown device.

This method is a combination of data_stop and close. This is a preferred way of shutting down a device.


obtain_device_info

obtain_device_info(handle)

Obtain device handle.

This abstract method should be implemented in all derived classes. This method collects the general information about the USB device such as the width and height of the camera or the serial number of the device.

Arguments

  • handle: caerDeviceHandle
    a valid device handle that can be used with the other libcaer functions, or None on error.

send_default_config

send_default_config()

Send default configuration.

Each type of devices has a set of default configurations (e.g. bias) that are pre-defined in the libcaer library. Note that the default configuration might not be suitable for your needs.

Returns

  • flag: bool
    return True if the default config is set successfully, False otherwise.

set_data_exchange_blocking

set_data_exchange_blocking(exchange_blocking=True)

Set data exchange blocking.

Arguments

  • exchange_blocking: bool
    whether to start all the data producer modules on the device (DVS, APS, Mux, ...) automatically when starting the data transfer thread with caerDeviceDataStart() or not. If disabled, be aware you will have to start the right modules manually, which can be useful if you need precise control over which ones are running at any time.
    The default is True.

set_config

set_config(mod_addr, param_addr, param)

Set configuration.

The main function of setting configurations (e.g., bias).

Arguments

  • mod_addr: int
    a module address, used to specify which configuration module one wants to update. Negative addresses are used for host-side configuration, while positive addresses (including zero) are used for device-side configuration.
  • param_addr: int
    a parameter address, to select a specific parameter to update from this particular configuration module. Only positive numbers (including zero) are allowed.
  • param: int or bool
    a configuration parameter's new value.

Returns

  • flag: bool
    returns True if the config is set successfully, False otherwise.

get_config

get_config(mod_addr, param_addr)

Get Configuration.

Arguments

  • mod_addr: int
    a module address, used to specify which configuration module one wants to update. Negative addresses are used for host-side configuration, while positive addresses (including zero) are used for device-side configuration.
  • param_addr: int
    a parameter address, to select a specific parameter to update from this particular configuration module. Only positive numbers (including zero) are allowed.

Returns

  • param: int or bool
    a configuration parameter's new value. Returns None if the handle is not valid.

get_event

get_event()

Get Event.

This abstract method should be implemented in all derived classes. This method returns a packet of events according to the type of the sensor.


get_packet_container

get_packet_container()

Get event packet container.

Returns

  • packet_container: caerEventPacketContainer
    a container that consists of event packets.
  • packet_number: int
    number of event packet in the container.

get_packet_header

get_packet_header(packet_container, idx)

Get a single packet header.

Arguments

  • packet_container: caerEventPacketContainer
    the event packet container
  • idx: int
    the index of the packet header

Returns

  • packet_header: caerEventPacketHeader
    the header that represents a event packet
  • packet_type: caerEventPacketType
    the type of the event packet

get_event_packet

get_event_packet(packet_header, packet_type)

Get event packet from packet header.

Arguments

  • packet_header: caerEventPacketHeader
    the header that represents a event packet.
  • packet_type: caerEventPacketType
    the type of the event packet, can be one of the following: libcaer.POLARITY_EVENT, libcaer.SPECIAL_EVENT, libcaer.FRAME_EVENT, libcaer.IMU6_EVENT, libcaer.SPIKE_EVENT

Returns

  • num_events: int
    number of events, return None if there is no events.
  • event_packet: caerEventPacket
    a packet of events that are ready to be read.

get_polarity_event

get_polarity_event(packet_header)

Get a packet of polarity event.

Arguments

  • packet_header: caerEventPacketHeader
    the header that represents a event packet

Returns

  • events: numpy.ndarray
    a 2-D array that has the shape of (N, 4) where N is the number of events in the event packet. Each row in the array represents a single polarity event. The first number is the timestamp. The second number is the X position of the event. The third number is the Y position of the event. The fourth number represents the polarity of the event (positive or negative).
  • num_events: int
    number of the polarity events available in the packet.

get_special_event

get_special_event(packet_header)

Get a packet of special event.

Arguments

  • packet_header: caerEventPacketHeader
    the header that represents a event packet

Returns

  • events: numpy.ndarray
    a 2-D array that has the shape of (N, 2) where N is the number of events in the event packet. Each row in the array represents a single special event. The first value is the timestamp of the event. The second value is the special event data.
  • num_events: int
    number of the special events in the packet.

get_frame_event

get_frame_event(packet_header)

Get a packet of frame event.

Arguments

  • packet_header: caerEventPacketHeader
    the header that represents a event packet

Returns

  • frame_mat: numpy.ndarray
    a 2-D array that has the shape of (height, width). The height and width of the APS frame is determined by the specific DAVIS device (e.g., DAVIS240 will have a 180x240 APS frame.
  • frame_ts: int
    the APS frame timestamp.

get_imu6_event

get_imu6_event(packet_header)

Get IMU6 event.

Arguments

  • packet_header: caerEventPacketHeader the header that represents a event packet

Returns

  • events: numpy.ndarray
    a 2-D array that has the shape of (N, 8) where N is the number of IMU6 events in the packet. Each row of the array consists a single IMU6 event. The first value is the timestamp of the event. The next three values are accelerations on the X, Y, and Z axes. The next three values are angular velocity on the X, Y and Z axes. The last value is the temperature in Celsius scale.
  • num_events: int
    number of the IMU6 events.

get_imu9_event

get_imu9_event(packet_header)

Get IMU9 event.

Arguments

  • packet_header: caerEventPacketHeader the header that represents a event packet

Returns

  • events: numpy.ndarray
    a 2-D array that has the shape of (N, 11) where N is the number of IMU9 events in the packet. Each row of the array consists a single IMU9 event. The first value is the timestamp of the event. The next three values are accelerations on the X, Y, and Z axes. The next three values are angular velocity on the X, Y and Z axes. The next three values are X, Y, Z axis compass heading. The last value is the temperature in Celsius scale.
  • num_events: int
    number of the IMU9 events.

get_spike_event

get_spike_event(packet_header)

Get Spike Event.

Arguments

  • packet_header: caerEventPacketHeader the header that represents a event packet

Returns

  • events: numpy.ndarray
    a 2-D array that has the shape of (N, 4) where N is the number of spike events in the packet. Each row of the array has a single spike event. The first value is the timestamp of the event. The second value is the neuron ID. The third value is the chip ID. The last value is the source core ID.
  • num_events: int
    the number of the spike events.