Loading data/etc/input/Android.bp +12 −3 Original line number Diff line number Diff line Loading @@ -3,12 +3,21 @@ package { } filegroup { name: "motion_predictor_model.fb", srcs: ["motion_predictor_model.fb"], name: "motion_predictor_model", srcs: [ "motion_predictor_model.tflite", "motion_predictor_config.xml", ], } prebuilt_etc { name: "motion_predictor_model_prebuilt", filename_from_src: true, src: "motion_predictor_model.fb", src: "motion_predictor_model.tflite", } prebuilt_etc { name: "motion_predictor_model_config", filename_from_src: true, src: "motion_predictor_config.xml", } data/etc/input/motion_predictor_config.xml 0 → 100644 +20 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2023 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <motion-predictor> <!-- The time interval (ns) between the model's predictions. --> <prediction-interval>4166666</prediction-interval> <!-- 4.167 ms = ~240 Hz --> </motion-predictor> data/etc/input/motion_predictor_model.fb→data/etc/input/motion_predictor_model.tflite (33.3 KiB) File moved. View file include/input/TfLiteMotionPredictor.h +8 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <android-base/mapped_file.h> #include <input/RingBuffer.h> #include <utils/Timers.h> #include <tensorflow/lite/core/api/error_reporter.h> #include <tensorflow/lite/interpreter.h> Loading Loading @@ -109,6 +110,9 @@ public: // 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; } // Executes the model. // Returns true if the model successfully executed and the output tensors can be read. bool invoke(); Loading @@ -127,7 +131,8 @@ public: std::span<const float> outputPressure() const; private: explicit TfLiteMotionPredictorModel(std::unique_ptr<android::base::MappedFile> model); explicit TfLiteMotionPredictorModel(std::unique_ptr<android::base::MappedFile> model, nsecs_t predictionInterval); void allocateTensors(); void attachInputTensors(); Loading @@ -148,6 +153,8 @@ private: std::unique_ptr<tflite::FlatBufferModel> mModel; std::unique_ptr<tflite::Interpreter> mInterpreter; tflite::SignatureRunner* mRunner = nullptr; const nsecs_t mPredictionInterval = 0; }; } // namespace android libs/input/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -215,6 +215,7 @@ cc_library { "libcutils", "liblog", "libPlatformProperties", "libtinyxml2", "libvintf", ], Loading Loading @@ -271,6 +272,7 @@ cc_library { required: [ "motion_predictor_model_prebuilt", "motion_predictor_model_config", ], }, host: { Loading Loading
data/etc/input/Android.bp +12 −3 Original line number Diff line number Diff line Loading @@ -3,12 +3,21 @@ package { } filegroup { name: "motion_predictor_model.fb", srcs: ["motion_predictor_model.fb"], name: "motion_predictor_model", srcs: [ "motion_predictor_model.tflite", "motion_predictor_config.xml", ], } prebuilt_etc { name: "motion_predictor_model_prebuilt", filename_from_src: true, src: "motion_predictor_model.fb", src: "motion_predictor_model.tflite", } prebuilt_etc { name: "motion_predictor_model_config", filename_from_src: true, src: "motion_predictor_config.xml", }
data/etc/input/motion_predictor_config.xml 0 → 100644 +20 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2023 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <motion-predictor> <!-- The time interval (ns) between the model's predictions. --> <prediction-interval>4166666</prediction-interval> <!-- 4.167 ms = ~240 Hz --> </motion-predictor>
data/etc/input/motion_predictor_model.fb→data/etc/input/motion_predictor_model.tflite (33.3 KiB) File moved. View file
include/input/TfLiteMotionPredictor.h +8 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <android-base/mapped_file.h> #include <input/RingBuffer.h> #include <utils/Timers.h> #include <tensorflow/lite/core/api/error_reporter.h> #include <tensorflow/lite/interpreter.h> Loading Loading @@ -109,6 +110,9 @@ public: // 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; } // Executes the model. // Returns true if the model successfully executed and the output tensors can be read. bool invoke(); Loading @@ -127,7 +131,8 @@ public: std::span<const float> outputPressure() const; private: explicit TfLiteMotionPredictorModel(std::unique_ptr<android::base::MappedFile> model); explicit TfLiteMotionPredictorModel(std::unique_ptr<android::base::MappedFile> model, nsecs_t predictionInterval); void allocateTensors(); void attachInputTensors(); Loading @@ -148,6 +153,8 @@ private: std::unique_ptr<tflite::FlatBufferModel> mModel; std::unique_ptr<tflite::Interpreter> mInterpreter; tflite::SignatureRunner* mRunner = nullptr; const nsecs_t mPredictionInterval = 0; }; } // namespace android
libs/input/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -215,6 +215,7 @@ cc_library { "libcutils", "liblog", "libPlatformProperties", "libtinyxml2", "libvintf", ], Loading Loading @@ -271,6 +272,7 @@ cc_library { required: [ "motion_predictor_model_prebuilt", "motion_predictor_model_config", ], }, host: { Loading