org.android.activityminer.app.recognizer
Class RecognizerHelper<T extends Enum<T> & Dimensions>

Package class diagram package RecognizerHelper
java.lang.Object
  extended by org.android.activityminer.app.recognizer.RecognizerHelper<T>
Type Parameters:
T - the enumeration type for the dimensions
All Implemented Interfaces:
EventObserver<FeatureVector>, ActivatableComponent

public class RecognizerHelper<T extends Enum<T> & Dimensions>
extends Object
implements EventObserver<FeatureVector>, ActivatableComponent

The recognition component.


Field Summary
private  ActivatableComponent activationDelegation
          activatable component implementation to delegate to
private  android.support.v4.util.LongSparseArray<String> cId2NameMapping
          The class identifier to name mapping
private  Classifier classifier
          The classifier.
private  Context context
          The context.
private  GenericObservableCutoutCreator<T,Double> cutoutCreator
          The cut-out creator.
private  AbstractFeatureExtractor<T> featureExtractor
          The feature extractor component.
private  PredictionResult lastPrediction
          The last prediction
private  ObservableSensorScanner<T,Double> sensorScanner
          The observable sensor scanner.
private  PowerManager.WakeLock wakeLock
          The wake lock.
 
Constructor Summary
private RecognizerHelper(Context context, Classifier classifier, AbstractFeatureExtractor<T> featureExtractor, ObservableSensorScanner<T,Double> sensorScanner, RuntimeConfiguration config, android.support.v4.util.LongSparseArray<String> cId2NameMapping)
          Constructor
 
Method Summary
private  void acquireWakeLock()
          Does acquire the wake lock
static RecognizerHelper<?> createHelper(Context context, String modelName)
          Builder method for the helper instance
 void doTerminate()
          Method to stop activity recognition.
 boolean isActive()
          Test method for the actiation state.
protected  void onActivationStateChange(boolean active)
           
 void onEvent(ObservableEventSource<? extends FeatureVector> eventSource, FeatureVector featureVector)
           
private  void releaseWakeLock()
          Does release the wake lock
 void setActivationState(boolean active)
          Method to set the activation state of the component
protected  void storePredictionInfo(double certainty, String predictedClass, Long timeStamp)
          Does store the prediction to database
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

private final Context context
The context.


activationDelegation

private final ActivatableComponent activationDelegation
activatable component implementation to delegate to


wakeLock

private final PowerManager.WakeLock wakeLock
The wake lock.


featureExtractor

private final AbstractFeatureExtractor<T extends Enum<T> & Dimensions> featureExtractor
The feature extractor component.


cutoutCreator

private final GenericObservableCutoutCreator<T extends Enum<T> & Dimensions,Double> cutoutCreator
The cut-out creator.


sensorScanner

private final ObservableSensorScanner<T extends Enum<T> & Dimensions,Double> sensorScanner
The observable sensor scanner.


classifier

private final Classifier classifier
The classifier.


cId2NameMapping

private final android.support.v4.util.LongSparseArray<String> cId2NameMapping
The class identifier to name mapping


lastPrediction

private PredictionResult lastPrediction
The last prediction

Constructor Detail

RecognizerHelper

private RecognizerHelper(Context context,
                         Classifier classifier,
                         AbstractFeatureExtractor<T> featureExtractor,
                         ObservableSensorScanner<T,Double> sensorScanner,
                         RuntimeConfiguration config,
                         android.support.v4.util.LongSparseArray<String> cId2NameMapping)
Constructor

Parameters:
context - the context
classifier - the classifier
featureExtractor - the feature extractor
sensorScanner - the sensor scanner
config - the runtime configuration
cId2NameMapping - the class identifier to name mapping
Method Detail

onActivationStateChange

protected final void onActivationStateChange(boolean active)
Parameters:
active -

releaseWakeLock

private final void releaseWakeLock()
Does release the wake lock


acquireWakeLock

private final void acquireWakeLock()
Does acquire the wake lock


doTerminate

public final void doTerminate()
Method to stop activity recognition.


onEvent

public void onEvent(ObservableEventSource<? extends FeatureVector> eventSource,
                    FeatureVector featureVector)
Specified by:
onEvent in interface EventObserver<FeatureVector>

storePredictionInfo

protected void storePredictionInfo(double certainty,
                                   String predictedClass,
                                   Long timeStamp)
Does store the prediction to database

Parameters:
certainty - the certainty
predictedClass - the predicted class
timeStamp - the time stamp

createHelper

public static final RecognizerHelper<?> createHelper(Context context,
                                                     String modelName)
Builder method for the helper instance

Parameters:
context - the application context
modelName - the model name
Returns:
the created helper instance or null in case of an invalid model

setActivationState

public void setActivationState(boolean active)
Description copied from interface: ActivatableComponent
Method to set the activation state of the component

Specified by:
setActivationState in interface ActivatableComponent
Parameters:
active - the activation sate flag

isActive

public boolean isActive()
Description copied from interface: ActivatableComponent
Test method for the actiation state.

Specified by:
isActive in interface ActivatableComponent
Returns:
true if active, false otherwise