public class RangeFeatureDetector extends FeatureDetectorAdapter
The RangeFeatureDetector used a RangeFinder to locate objects (known as features when mapping). This class is unable to identify the feature and merely reports the range and angle to the object.
You can also have the scan identify the object (such as a camera using facial recognition to identify a person). One possibility to implement this is to extend RangeFeatureDetector and add a camera to the constructor. When the FeatureDetector range scanner detects an object, take a picture and look for a face in the image. This is then reported as an extended class of RangeFeature called PersonFeature, which has a getPerson() method containing information on the object that was detected.
To create a more complex FeatureDetector, extend this class and override the FeatureDetector.scan()
method.
It is possible to add more complex functionality in this method, such as only returning a "hit" if the scanner detects
an object in the same location twice in a row. This type of filtering could also take place in the FeatureListener
method, although then single FeatureDetector.scan()
calls will not contain the filtering.
Constructor and Description |
---|
RangeFeatureDetector(RangeFinder rf,
float maxDistance,
int delay)
This constructor allows you to specify the sensor, the maximum distance to report a
detection, and the delay between scanning the sensor.
|
RangeFeatureDetector(RangeFinder rf,
float maxDistance,
int delay,
double angle)
This constructor allows you to specify the sensor, the maximum distance to report a
detection, the delay between scanning the sensor, and the angle the sensor is pointed.
|
Modifier and Type | Method and Description |
---|---|
float |
getMaxDistance()
Returns the maximum distance the FeatureDetector will return for detected objects.
|
Feature |
scan()
Performs a single scan for an object and returns the results.
|
void |
setMaxDistance(float distance)
Sets the maximum distance to register detected objects from the range finder.
|
void |
setPoseProvider(PoseProvider pp) |
addListener, enableDetection, getDelay, isEnabled, notifyListeners, setDelay
public RangeFeatureDetector(RangeFinder rf, float maxDistance, int delay)
rf
- The range finder sensor. e.g. UltrasonicSensormaxDistance
- The upper limit of distance it will report. e.g. 40 cm.delay
- The interval range finder checks for objects. e.g. 250 ms.public RangeFeatureDetector(RangeFinder rf, float maxDistance, int delay, double angle)
rf
- The range finder sensor. e.g. UltrasonicSensormaxDistance
- The upper limit of distance it will report. e.g. 40 cm.delay
- The interval range finder checks for objects. e.g. 250 ms.angle
- The angle, in degrees, the range sensor is pointed. (0 = forward, +ve = left, -ve = right)public void setPoseProvider(PoseProvider pp)
public void setMaxDistance(float distance)
distance
- The maximum distance. e.g. 40 cm.public float getMaxDistance()
public Feature scan()
FeatureDetector
Performs a single scan for an object and returns the results. If an object is not detected, this method returns null.
Warning: Make sure to check for a null object before trying to read data from the returned Feature object, otherwise your code will throw a null pointer exception.
scan
in interface FeatureDetector
scan
in class FeatureDetectorAdapter