jAER project on SourceForge

net.sf.jaer.stereopsis
Class StereoHardwareInterface

java.lang.Object
  extended by net.sf.jaer.stereopsis.StereoHardwareInterface
All Implemented Interfaces:
AEMonitorInterface, HardwareInterface, ReaderBufferControl, USBInterface
Direct Known Subclasses:
StereoBiasgenHardwareInterface

public class StereoHardwareInterface
extends java.lang.Object
implements AEMonitorInterface, ReaderBufferControl

A hardware interface to a stereo pair of sensors. This class merges the data from two AEMonitorInterface's to a single unified stereo stream, with events sorted by timestamp in the output packets. This class also deals with the awkwardness of the fact that you are not guarenteed to get all events in order of generation from the devices owing to buffering. Events from one source (say the left eye) are held back until it is assured there are no earlier events from the other source (the right eye).

Author:
tobi

Field Summary
protected  AEChip chip
           
 int INITIAL_CAPACITY
          Initial capacity of output buffer that is reused for outputting merged event stream
static int RESET_TIMESTAMPS_THRESHOLD_DT_US
          the two inputs have their timestamps reset when the first timestamp of each most recent packet differs by this much
 
Fields inherited from interface net.sf.jaer.hardwareinterface.usb.USBInterface
PID_THESYCON_END, PID_THESYCON_START, VID_THESYCON
 
Constructor Summary
StereoHardwareInterface(AEMonitorInterface left, AEMonitorInterface right)
           
 
Method Summary
 AEPacketRaw acquireAvailableEventsFromDriver()
          Gets available events from driver.
 void addAEListener(AEListener listener)
          add a PropertyChangeListener for new events
 void close()
          Closes the device and frees the internal device handle.
 int getAEBufferSize()
          Returns the size of the host buffer.
 AEMonitorInterface getAemonLeft()
           
 AEMonitorInterface getAemonRight()
           
 AEChip getChip()
          Sets the AEChip that this interface is acquiring events for
 short getDID()
           
 int getEstimatedEventRate()
          Returns estimate of present event rate on this interface
 AEPacketRaw getEvents()
          returns the last events acquired by AEMonitorInterface.acquireAvailableEventsFromDriver()
 int getFifoSize()
           
 int getMaxCapacity()
          Returns max capacity of this interface in events/sec
 int getNumBuffers()
           
 int getNumEventsAcquired()
          Returns the number of events acquired by the last call to AEMonitorInterface.acquireAvailableEventsFromDriver()
 short getPID()
           
 java.lang.String[] getStringDescriptors()
          return the string USB descriptors for the device.
 int getTimestampTickUs()
           
 java.lang.String getTypeName()
          get text name of interface, e.g.
 short getVID()
           
 int[] getVIDPID()
          return the USB VID/PID of the interface
 boolean isEventAcquisitionEnabled()
           
 boolean isIgnoreTimestampNonmonotonicity()
           
 boolean isOpen()
           
 void labelLeftEye(AEPacketRaw aeRaw)
          Labels events as coming from left eye
 void labelRightEye(AEPacketRaw aeRawRight)
          Labels all events in raw packet as coming from right eye
 void open()
          Opens the device driver and gets a handle to the device which is internally maintained.
 boolean overrunOccurred()
          Is true if an overrun occured in the driver the last time AEMonitorInterface.acquireAvailableEventsFromDriver() was called.
 void removeAEListener(AEListener listener)
          remove a PropertyChangeListener for new events
 void resetTimestamps()
          resets timestamps from both inputs, serially.
 void setAEBufferSize(int AEBufferSize)
          sets the host AE buffer size.
 void setAemonLeft(AEMonitorInterface aemonLeft)
           
 void setAemonRight(AEMonitorInterface aemonRight)
           
 void setChip(AEChip chip)
          Sets the AEChip that this interface is acquiring events for
 void setEventAcquisitionEnabled(boolean enable)
          sets both eyes to acquire events
 void setFifoSize(int fifoSize)
           
 void setIgnoreTimestampNonmonotonicity(boolean yes)
          If this flag is set true, then packets are returned from acquireAvailableEventsFromDriver as soon as they are delivered, regardless of any timestamp ordering problems.
 void setNumBuffers(int numBuffers)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

chip

protected AEChip chip

INITIAL_CAPACITY

public final int INITIAL_CAPACITY
Initial capacity of output buffer that is reused for outputting merged event stream

See Also:
Constant Field Values

RESET_TIMESTAMPS_THRESHOLD_DT_US

public static final int RESET_TIMESTAMPS_THRESHOLD_DT_US
the two inputs have their timestamps reset when the first timestamp of each most recent packet differs by this much

See Also:
Constant Field Values
Constructor Detail

StereoHardwareInterface

public StereoHardwareInterface(AEMonitorInterface left,
                               AEMonitorInterface right)
Method Detail

setChip

public void setChip(AEChip chip)
Description copied from interface: AEMonitorInterface
Sets the AEChip that this interface is acquiring events for

Specified by:
setChip in interface AEMonitorInterface
Parameters:
chip - the chip

getChip

public AEChip getChip()
Description copied from interface: AEMonitorInterface
Sets the AEChip that this interface is acquiring events for

Specified by:
getChip in interface AEMonitorInterface
Returns:
the chip

getAemonLeft

public AEMonitorInterface getAemonLeft()

setAemonLeft

public void setAemonLeft(AEMonitorInterface aemonLeft)

getAemonRight

public AEMonitorInterface getAemonRight()

setAemonRight

public void setAemonRight(AEMonitorInterface aemonRight)

acquireAvailableEventsFromDriver

public AEPacketRaw acquireAvailableEventsFromDriver()
                                             throws HardwareInterfaceException
Description copied from interface: AEMonitorInterface
Gets available events from driver. This call returns a reference to an AEPacket that holds the events. HardwareInterfaceException is thrown if there is an error.

Specified by:
acquireAvailableEventsFromDriver in interface AEMonitorInterface
Returns:
an AEPacketRaw of events from both devices, sorted by timestamp. As a hack (hopefully temporary), the MSB is set on the raw addresses of the events from the right device.
Throws:
HardwareInterfaceException - .

getNumEventsAcquired

public int getNumEventsAcquired()
Description copied from interface: AEMonitorInterface
Returns the number of events acquired by the last call to AEMonitorInterface.acquireAvailableEventsFromDriver()

Specified by:
getNumEventsAcquired in interface AEMonitorInterface
Returns:
number of events acquired

getEvents

public AEPacketRaw getEvents()
Description copied from interface: AEMonitorInterface
returns the last events acquired by AEMonitorInterface.acquireAvailableEventsFromDriver()

Specified by:
getEvents in interface AEMonitorInterface
Returns:
the packet of raw events

resetTimestamps

public void resetTimestamps()
resets timestamps from both inputs, serially. The hardware timestamps may be offset by an undetermined amount due to USB latency, context switching, etc. By using electrical synchronization between boards, it may be possible to synchronize perfectly, but this is device-dependent.

Specified by:
resetTimestamps in interface AEMonitorInterface

overrunOccurred

public boolean overrunOccurred()
Description copied from interface: AEMonitorInterface
Is true if an overrun occured in the driver the last time AEMonitorInterface.acquireAvailableEventsFromDriver() was called. This flag is cleared by the next AEMonitorInterface.acquireAvailableEventsFromDriver(). If there is an overrun, the events grabbed are the most ancient; events after the overrun are discarded. The timestamps continue on but will probably be lagged behind what they should be.

Specified by:
overrunOccurred in interface AEMonitorInterface
Returns:
true if either device overran the buffer

getAEBufferSize

public int getAEBufferSize()
Description copied from interface: AEMonitorInterface
Returns the size of the host buffer.

Specified by:
getAEBufferSize in interface AEMonitorInterface
Returns:
the host AE buffer size. This is for the user buffer, not the device buffer. This returns the buffer size for the left device.

setAEBufferSize

public void setAEBufferSize(int AEBufferSize)
sets the host AE buffer size. This is for the user buffer, not the device buffer.

Specified by:
setAEBufferSize in interface AEMonitorInterface
Parameters:
AEBufferSize - the size in events

getFifoSize

public int getFifoSize()
Specified by:
getFifoSize in interface ReaderBufferControl

setFifoSize

public void setFifoSize(int fifoSize)
Specified by:
setFifoSize in interface ReaderBufferControl

getNumBuffers

public int getNumBuffers()
Specified by:
getNumBuffers in interface ReaderBufferControl

setNumBuffers

public void setNumBuffers(int numBuffers)
Specified by:
setNumBuffers in interface ReaderBufferControl

setEventAcquisitionEnabled

public void setEventAcquisitionEnabled(boolean enable)
                                throws HardwareInterfaceException
sets both eyes to acquire events

Specified by:
setEventAcquisitionEnabled in interface AEMonitorInterface
Parameters:
enable - true to start, false to stop
Throws:
HardwareInterfaceException

isEventAcquisitionEnabled

public boolean isEventAcquisitionEnabled()
Specified by:
isEventAcquisitionEnabled in interface AEMonitorInterface
Returns:
true if both eyes are enabled

addAEListener

public void addAEListener(AEListener listener)
Description copied from interface: AEMonitorInterface
add a PropertyChangeListener for new events

Specified by:
addAEListener in interface AEMonitorInterface
Parameters:
listener - will be called after each AEMonitorInterface.acquireAvailableEventsFromDriver() call

removeAEListener

public void removeAEListener(AEListener listener)
Description copied from interface: AEMonitorInterface
remove a PropertyChangeListener for new events

Specified by:
removeAEListener in interface AEMonitorInterface
Parameters:
listener - to remove

getMaxCapacity

public int getMaxCapacity()
Description copied from interface: AEMonitorInterface
Returns max capacity of this interface in events/sec

Specified by:
getMaxCapacity in interface AEMonitorInterface
Returns:
max capacity in events/sec

getEstimatedEventRate

public int getEstimatedEventRate()
Description copied from interface: AEMonitorInterface
Returns estimate of present event rate on this interface

Specified by:
getEstimatedEventRate in interface AEMonitorInterface
Returns:
estimated event rate in events/sec

getTimestampTickUs

public int getTimestampTickUs()
Specified by:
getTimestampTickUs in interface AEMonitorInterface
Returns:
timestamp tick in us for this interface

getStringDescriptors

public java.lang.String[] getStringDescriptors()
Description copied from interface: USBInterface
return the string USB descriptors for the device. By USB convention, the first string is the manufactuer, the second is product, and the last is the unique serial number. The serial number may not be implemented, in which case a null string may be the third string or the length of the returned array may only be 2.

Specified by:
getStringDescriptors in interface USBInterface
Returns:
String[] of USB descriptors

getVIDPID

public int[] getVIDPID()
Description copied from interface: USBInterface
return the USB VID/PID of the interface

Specified by:
getVIDPID in interface USBInterface
Returns:
int[] of length 2 containing the Vendor ID (VID) and Product ID (PID) of the device. First element is VID, second element is PID.

getVID

public short getVID()
Specified by:
getVID in interface USBInterface
Returns:
PID (vendor ID)

getPID

public short getPID()
Specified by:
getPID in interface USBInterface
Returns:
PID (product ID)

getDID

public short getDID()
Specified by:
getDID in interface USBInterface
Returns:
DID (device ID). This is the firmware version number, not the serial number. A device may not set the firmware version number in it's descriptors. Returns 0 then. DVS128 and the USBAERmini2 do have it.

getTypeName

public java.lang.String getTypeName()
Description copied from interface: HardwareInterface
get text name of interface, e.g. "CypressFX2" or "SiLabsC8051F320"

Specified by:
getTypeName in interface HardwareInterface

close

public void close()
Description copied from interface: HardwareInterface
Closes the device and frees the internal device handle. Never throws an exception.

Specified by:
close in interface HardwareInterface

open

public void open()
          throws HardwareInterfaceException
Description copied from interface: HardwareInterface
Opens the device driver and gets a handle to the device which is internally maintained.

Specified by:
open in interface HardwareInterface
Throws:
HardwareInterfaceException - if there is a problem. Diagnostics are printeds.

isOpen

public boolean isOpen()
Specified by:
isOpen in interface HardwareInterface
Returns:
true if interface is open, false otherwise

labelRightEye

public void labelRightEye(AEPacketRaw aeRawRight)
Labels all events in raw packet as coming from right eye

Parameters:
aeRawRight -

labelLeftEye

public void labelLeftEye(AEPacketRaw aeRaw)
Labels events as coming from left eye

Parameters:
aeRaw -

isIgnoreTimestampNonmonotonicity

public boolean isIgnoreTimestampNonmonotonicity()

setIgnoreTimestampNonmonotonicity

public void setIgnoreTimestampNonmonotonicity(boolean yes)
If this flag is set true, then packets are returned from acquireAvailableEventsFromDriver as soon as they are delivered, regardless of any timestamp ordering problems. No attempt is made to ensure that the timestamps are ordered correctly. Playback of logged data will likely not work well since there is an assumption that time increases monotonically in much of jAER event processing.

Parameters:
yes - true to not order timestamps from the two interfaces.

jAER project on SourceForge