Internal change

PiperOrigin-RevId: 523632081
This commit is contained in:
MediaPipe Team 2023-04-12 01:23:17 -07:00 committed by Copybara-Service
parent a7c6910625
commit 2eefc862c2
7 changed files with 38 additions and 37 deletions

View File

@ -6,7 +6,7 @@ namespace mediapipe {
namespace autoflip {
namespace {
int Median(const std::deque<std::pair<uint64, int>>& positions_raw) {
int Median(const std::deque<std::pair<uint64_t, int>>& positions_raw) {
std::deque<int> positions;
for (const auto& position : positions_raw) {
positions.push_back(position.second);
@ -31,7 +31,7 @@ bool KinematicPathSolver::IsMotionTooSmall(double delta_degs) {
void KinematicPathSolver::ClearHistory() { raw_positions_at_time_.clear(); }
absl::Status KinematicPathSolver::PredictMotionState(int position,
const uint64 time_us,
const uint64_t time_us,
bool* state) {
if (!initialized_) {
*state = false;
@ -41,10 +41,10 @@ absl::Status KinematicPathSolver::PredictMotionState(int position,
auto raw_positions_at_time_copy = raw_positions_at_time_;
raw_positions_at_time_copy.push_front(
std::pair<uint64, int>(time_us, position));
std::pair<uint64_t, int>(time_us, position));
while (raw_positions_at_time_copy.size() > 1) {
if (static_cast<int64>(raw_positions_at_time_copy.back().first) <
static_cast<int64>(time_us) - options_.filtering_time_window_us()) {
if (static_cast<int64_t>(raw_positions_at_time_copy.back().first) <
static_cast<int64_t>(time_us) - options_.filtering_time_window_us()) {
raw_positions_at_time_copy.pop_back();
} else {
break;
@ -78,7 +78,7 @@ absl::Status KinematicPathSolver::PredictMotionState(int position,
}
absl::Status KinematicPathSolver::AddObservation(int position,
const uint64 time_us) {
const uint64_t time_us) {
if (!initialized_) {
if (position < min_location_) {
current_position_px_ = min_location_;
@ -92,7 +92,7 @@ absl::Status KinematicPathSolver::AddObservation(int position,
motion_state_ = false;
mean_delta_t_ = -1;
raw_positions_at_time_.push_front(
std::pair<uint64, int>(time_us, position));
std::pair<uint64_t, int>(time_us, position));
current_time_ = time_us;
initialized_ = true;
current_velocity_deg_per_s_ = 0;
@ -131,10 +131,11 @@ absl::Status KinematicPathSolver::AddObservation(int position,
RET_CHECK(current_time_ < time_us)
<< "Observation added before a prior observations.";
raw_positions_at_time_.push_front(std::pair<uint64, int>(time_us, position));
raw_positions_at_time_.push_front(
std::pair<uint64_t, int>(time_us, position));
while (raw_positions_at_time_.size() > 1) {
if (static_cast<int64>(raw_positions_at_time_.back().first) <
static_cast<int64>(time_us) - options_.filtering_time_window_us()) {
if (static_cast<int64_t>(raw_positions_at_time_.back().first) <
static_cast<int64_t>(time_us) - options_.filtering_time_window_us()) {
raw_positions_at_time_.pop_back();
} else {
break;
@ -220,7 +221,7 @@ absl::Status KinematicPathSolver::AddObservation(int position,
return UpdatePrediction(time_us);
}
absl::Status KinematicPathSolver::UpdatePrediction(const int64 time_us) {
absl::Status KinematicPathSolver::UpdatePrediction(const int64_t time_us) {
RET_CHECK(current_time_ < time_us)
<< "Prediction time added before a prior observation or prediction.";

View File

@ -20,7 +20,7 @@
#include "mediapipe/framework/port/status.h"
#include "mediapipe/framework/port/status_matchers.h"
constexpr int64 kMicroSecInSec = 1000000;
constexpr int64_t kMicroSecInSec = 1000000;
constexpr float kWidthFieldOfView = 60;
namespace mediapipe {
@ -43,7 +43,7 @@ TEST(KinematicPathSolverTest, FailNotInitializedState) {
TEST(KinematicPathSolverTest, FailNotInitializedPrediction) {
KinematicOptions options;
KinematicPathSolver solver(options, 0, 1000, 1000.0 / kWidthFieldOfView);
int64 timestamp = 0;
int64_t timestamp = 0;
EXPECT_FALSE(solver.UpdatePrediction(timestamp).ok());
}

View File

@ -39,8 +39,8 @@ using ::testing::HasSubstr;
const int kNumKeyFrames = 5;
const int kNumSceneFrames = 30;
const int64 kKeyFrameTimestampDiff = 1e6 / kNumKeyFrames;
const int64 kSceneFrameTimestampDiff = 1e6 / kNumSceneFrames;
const int64_t kKeyFrameTimestampDiff = 1e6 / kNumKeyFrames;
const int64_t kSceneFrameTimestampDiff = 1e6 / kNumSceneFrames;
// Default time span of a scene in seconds.
const double kSceneTimeSpanSec = 1.0;
@ -66,8 +66,8 @@ Rect MakeRect(const int x, const int y, const int width, const int height) {
// Returns default values for scene frame timestamps. Populates timestamps using
// the default spacing kSceneFrameTimestampDiff starting from 0.
std::vector<int64> GetDefaultSceneFrameTimestamps() {
std::vector<int64> scene_frame_timestamps(kNumSceneFrames);
std::vector<int64_t> GetDefaultSceneFrameTimestamps() {
std::vector<int64_t> scene_frame_timestamps(kNumSceneFrames);
for (int i = 0; i < kNumSceneFrames; ++i) {
scene_frame_timestamps[i] = kSceneFrameTimestampDiff * i;
}
@ -426,7 +426,7 @@ TEST(SceneCameraMotionAnalyzerTest,
SceneCameraMotionAnalyzerOptions options;
TestableSceneCameraMotionAnalyzer analyzer(options);
SceneCameraMotion camera_motion;
std::vector<int64> scene_frame_timestamps(0);
std::vector<int64_t> scene_frame_timestamps(0);
std::vector<FocusPointFrame> focus_point_frames;
const auto status = analyzer.PopulateFocusPointFrames(
@ -624,7 +624,7 @@ TEST(SceneCameraMotionAnalyzerTest, PopulateFocusPointFramesSweeping) {
55, 65, 75, 85, 95};
const std::vector<float> positions_y = {50, 50, 50, 50, 50,
50, 50, 50, 50, 50};
std::vector<int64> scene_frame_timestamps(num_frames);
std::vector<int64_t> scene_frame_timestamps(num_frames);
std::iota(scene_frame_timestamps.begin(), scene_frame_timestamps.end(), 0);
std::vector<FocusPointFrame> focus_point_frames;
@ -691,7 +691,7 @@ TEST(SceneCameraMotionAnalyzerTest,
// Aligns timestamps of scene frames with key frames.
scene_summary.mutable_key_frame_compact_infos(0)->set_timestamp_ms(10);
scene_summary.mutable_key_frame_compact_infos(1)->set_timestamp_ms(20);
std::vector<int64> scene_frame_timestamps = {10, 20};
std::vector<int64_t> scene_frame_timestamps = {10, 20};
std::vector<FocusPointFrame> focus_point_frames;
MP_EXPECT_OK(analyzer.PopulateFocusPointFrames(scene_summary, camera_motion,

View File

@ -31,7 +31,7 @@ namespace autoflip {
absl::Status SceneCropper::ProcessKinematicPathSolver(
const SceneKeyFrameCropSummary& scene_summary,
const std::vector<int64>& scene_timestamps,
const std::vector<int64_t>& scene_timestamps,
const std::vector<bool>& is_key_frames,
const std::vector<FocusPointFrame>& focus_point_frames,
const bool continue_last_scene, std::vector<cv::Mat>* all_xforms) {
@ -82,7 +82,7 @@ absl::Status SceneCropper::ProcessKinematicPathSolver(
absl::Status SceneCropper::CropFrames(
const SceneKeyFrameCropSummary& scene_summary,
const std::vector<int64>& scene_timestamps,
const std::vector<int64_t>& scene_timestamps,
const std::vector<bool>& is_key_frames,
const std::vector<cv::Mat>& scene_frames_or_empty,
const std::vector<FocusPointFrame>& focus_point_frames,

View File

@ -71,8 +71,8 @@ std::vector<FocusPointFrame> GetDefaultFocusPointFrames() {
return GetFocusPointFrames(kNumSceneFrames);
}
std::vector<int64> GetTimestamps(const int num_frames) {
std::vector<int64> timestamps;
std::vector<int64_t> GetTimestamps(const int num_frames) {
std::vector<int64_t> timestamps;
for (int i = 0; i < num_frames; ++i) {
timestamps.push_back(i * 100000);
}

View File

@ -89,7 +89,7 @@ void RectUnion(const Rect& rect_to_add, Rect* rect) {
rect->set_height(y2 - y1);
}
absl::Status PackKeyFrameInfo(const int64 frame_timestamp_ms,
absl::Status PackKeyFrameInfo(const int64_t frame_timestamp_ms,
const DetectionSet& detections,
const int original_frame_width,
const int original_frame_height,
@ -378,7 +378,7 @@ absl::Status ComputeSceneStaticBordersSize(
absl::Status FindSolidBackgroundColor(
const std::vector<StaticFeatures>& static_features,
const std::vector<int64>& static_features_timestamps,
const std::vector<int64_t>& static_features_timestamps,
const double min_fraction_solid_background_color,
bool* has_solid_background,
PiecewiseLinearFunction* background_color_l_function,
@ -395,7 +395,7 @@ absl::Status FindSolidBackgroundColor(
if (static_features[i].has_solid_background()) {
solid_background_frames++;
const auto& color = static_features[i].solid_background();
const int64 timestamp = static_features_timestamps[i];
const int64_t timestamp = static_features_timestamps[i];
// BorderDetectionCalculator sets color assuming the input frame is
// BGR, but in reality we have RGB, so we need to revert it here.
// TODO remove this custom logic in BorderDetectionCalculator,

View File

@ -31,12 +31,12 @@ namespace {
using ::testing::HasSubstr;
const int64 kTimestamp = 0;
const int64_t kTimestamp = 0;
const int kOriginalWidth = 100;
const int kOriginalHeight = 100;
const double kTargetAspectRatio = 1.5;
const int kNumKeyFrames = 5;
const int64 kKeyFrameTimestampDiff = 1e6 / kNumKeyFrames;
const int64_t kKeyFrameTimestampDiff = 1e6 / kNumKeyFrames;
const int kTargetWidth = 50;
const int kTargetHeight = 50;
@ -874,7 +874,7 @@ TEST(UtilTest, ComputeSceneStaticBordersSizeHasBorders) {
// Checks that FindSolidBackgroundColor checks output not null.
TEST(UtilTest, FindSolidBackgroundColorChecksOutputNotNull) {
std::vector<StaticFeatures> static_features;
std::vector<int64> static_features_timestamps;
std::vector<int64_t> static_features_timestamps;
const double min_fraction_solid_background_color = 0.8;
bool has_solid_background_color;
PiecewiseLinearFunction l_function, a_function, b_function;
@ -903,7 +903,7 @@ TEST(UtilTest, FindSolidBackgroundColorReturnsTrue) {
color->set_r(255);
color->set_g(255);
color->set_b(255);
std::vector<int64> static_features_timestamps(1);
std::vector<int64_t> static_features_timestamps(1);
static_features_timestamps[0] = 0;
const double min_fraction_solid_background_color = 0.8;
bool has_solid_background_color;
@ -920,7 +920,7 @@ TEST(UtilTest, FindSolidBackgroundColorReturnsTrue) {
// background color.
TEST(UtilTest, FindSolidBackgroundColorReturnsFalse) {
std::vector<StaticFeatures> static_features(1);
std::vector<int64> static_features_timestamps(1);
std::vector<int64_t> static_features_timestamps(1);
static_features_timestamps[0] = 0;
const double min_fraction_solid_background_color = 0.8;
bool has_solid_background_color;
@ -935,12 +935,12 @@ TEST(UtilTest, FindSolidBackgroundColorReturnsFalse) {
// Checks that FindSolidBackgroundColor sets the interpolation functions.
TEST(UtilTest, FindSolidBackgroundColorSetsInterpolationFunctions) {
const uint8 rgb1[] = {255, 255, 0}; // cyan in bgr
const uint8_t rgb1[] = {255, 255, 0}; // cyan in bgr
const double lab1[] = {91.1133, -48.0938, -14.125};
const int64 time1 = 0;
const uint8 rgb2[] = {255, 0, 255}; // magenta in bgr
const int64_t time1 = 0;
const uint8_t rgb2[] = {255, 0, 255}; // magenta in bgr
const double lab2[] = {60.321, 98.2344, -60.8281};
const int64 time2 = 2000;
const int64_t time2 = 2000;
std::vector<StaticFeatures> static_features(2);
auto* color1 = static_features[0].mutable_solid_background();
color1->set_r(rgb1[0]);
@ -950,7 +950,7 @@ TEST(UtilTest, FindSolidBackgroundColorSetsInterpolationFunctions) {
color2->set_r(rgb2[0]);
color2->set_g(rgb2[1]);
color2->set_b(rgb2[2]);
std::vector<int64> static_features_timestamps(2);
std::vector<int64_t> static_features_timestamps(2);
static_features_timestamps[0] = time1;
static_features_timestamps[1] = time2;
const double min_fraction_solid_background_color = 0.8;