Project import generated by Copybara.

GitOrigin-RevId: d4a11282d20fe4d2e137f9032cf349750030dcb9
This commit is contained in:
MediaPipe Team
2021-11-03 17:27:30 -07:00
committed by jqtang
parent 1faeaae7e5
commit d4bb35fe5a
72 changed files with 1089 additions and 336 deletions
@@ -282,8 +282,12 @@ absl::Status KinematicPathSolver::UpdatePixelsPerDegree(
absl::Status KinematicPathSolver::UpdateMinMaxLocation(const int min_location,
const int max_location) {
RET_CHECK(initialized_)
<< "UpdateMinMaxLocation called before first observation added.";
if (!initialized_) {
max_location_ = max_location;
min_location_ = min_location;
return absl::OkStatus();
}
double prior_distance = max_location_ - min_location_;
double updated_distance = max_location - min_location;
double scale_change = updated_distance / prior_distance;
@@ -435,6 +435,23 @@ TEST(KinematicPathSolverTest, PassBorderTest) {
EXPECT_FLOAT_EQ(state, 404.56668);
}
TEST(KinematicPathSolverTest, PassUpdateUpdateMinMaxLocationIfUninitialized) {
KinematicOptions options;
options.set_min_motion_to_reframe(2.0);
options.set_max_velocity(1000);
KinematicPathSolver solver(options, 0, 1000, 1000.0 / kWidthFieldOfView);
MP_EXPECT_OK(solver.UpdateMinMaxLocation(0, 500));
}
TEST(KinematicPathSolverTest, PassUpdateUpdateMinMaxLocationIfInitialized) {
KinematicOptions options;
options.set_min_motion_to_reframe(2.0);
options.set_max_velocity(1000);
KinematicPathSolver solver(options, 0, 1000, 1000.0 / kWidthFieldOfView);
MP_ASSERT_OK(solver.AddObservation(500, kMicroSecInSec * 0));
MP_EXPECT_OK(solver.UpdateMinMaxLocation(0, 500));
}
} // namespace
} // namespace autoflip
} // namespace mediapipe