Update motion prediction model.
Input events with no movement (r = 0) are now included in the buffer
so that the model can accurately determine when the input device has
become stationary, and a noise floor is added to prevent spurious
predictions when this happens.
Benchmark results:
Old:
timeRecordAndPredict_mean (ns): 17990
timeRecordAndPredict_median (ns): 18024
timeRecordAndPredict_min (ns): 17606
timeRecordAndPredict_standardDeviation: 345
New:
timeRecordAndPredict_mean (ns): 38394
timeRecordAndPredict_median (ns): 38476
timeRecordAndPredict_min (ns): 38083
timeRecordAndPredict_standardDeviation: 187
Bug: 288354672
PiperOrigin-RevId: 549064247
Test: predictions are visible in the motionprediction test app
Test: atest CtsInputTestCases
Test: atest MotionPredictorBenchmark MotionPredictorTest
Test: atest --host libinput_tests
Change-Id: I6c3917591323d7117c4ee2e91abf6c6004178f19
diff --git a/include/input/TfLiteMotionPredictor.h b/include/input/TfLiteMotionPredictor.h
index fbd6026..2edc138 100644
--- a/include/input/TfLiteMotionPredictor.h
+++ b/include/input/TfLiteMotionPredictor.h
@@ -99,6 +99,14 @@
// A TFLite model for generating motion predictions.
class TfLiteMotionPredictorModel {
public:
+ struct Config {
+ // The time between predictions.
+ nsecs_t predictionInterval = 0;
+ // The noise floor for predictions.
+ // Distances (r) less than this should be discarded as noise.
+ float distanceNoiseFloor = 0;
+ };
+
// Creates a model from an encoded Flatbuffer model.
static std::unique_ptr<TfLiteMotionPredictorModel> create();
@@ -110,8 +118,7 @@
// Returns the length of the model's output buffers.
size_t outputLength() const;
- // Returns the time interval between predictions.
- nsecs_t predictionInterval() const { return mPredictionInterval; }
+ const Config& config() const { return mConfig; }
// Executes the model.
// Returns true if the model successfully executed and the output tensors can be read.
@@ -132,7 +139,7 @@
private:
explicit TfLiteMotionPredictorModel(std::unique_ptr<android::base::MappedFile> model,
- nsecs_t predictionInterval);
+ Config config);
void allocateTensors();
void attachInputTensors();
@@ -154,7 +161,7 @@
std::unique_ptr<tflite::Interpreter> mInterpreter;
tflite::SignatureRunner* mRunner = nullptr;
- const nsecs_t mPredictionInterval = 0;
+ const Config mConfig = {};
};
} // namespace android