From bf5185f122d4858c209becde3a6f750b0f1dc3c0 Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Sat, 11 Jan 2020 11:08:37 -0800 Subject: [PATCH] Project import generated by Copybara. GitOrigin-RevId: 72933af9ce469acd89cbf41898dcc06c65df7c8a --- mediapipe/docs/autoflip.md | 8 +++----- mediapipe/examples/desktop/autoflip/README.md | 4 +--- mediapipe/util/sequence/media_sequence.cc | 12 ++++++++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/mediapipe/docs/autoflip.md b/mediapipe/docs/autoflip.md index 30546330..ac4199d0 100644 --- a/mediapipe/docs/autoflip.md +++ b/mediapipe/docs/autoflip.md @@ -24,13 +24,11 @@ bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 mediapipe/examples/desktop/a ```bash GLOG_logtostderr=1 bazel-bin/mediapipe/examples/desktop/autoflip/run_autoflip \ --calculator_graph_config_file=mediapipe/examples/desktop/autoflip/autoflip_graph.pbtxt \ - --input_side_packets=input_video_path=/absolute/path/to/the/local/video/file,\ - output_video_path=/absolute/path/to/save/the/output/video/file,\ - aspect_ratio=9:16 + --input_side_packets=input_video_path=/absolute/path/to/the/local/video/file,output_video_path=/absolute/path/to/save/the/output/video/file,aspect_ratio=1:1 ``` Use the `aspect_ratio` flag to provide the output aspect ratio. The format -should be `weight:height`, where the `weight` and `height` are two positive +should be `width:height`, where the `width` and `height` are two positive integers. AutoFlip supports both landscape-to-portrait and portrait-to-landscape conversions. The pipeline internally compares the target aspect ratio against the original one, and determines the correct conversion automatically. @@ -278,7 +276,7 @@ the required features cannot be all covered (for example, when they are too spread out in the video), AutoFlip will apply a padding effect to cover as much salient content as possible. See an illustration below. -![graph is_required](images/autoflip_is_required.gif){width="600"} +![graph is_required](images/autoflip_is_required.gif) ### Stable vs Tracking Camera Motion diff --git a/mediapipe/examples/desktop/autoflip/README.md b/mediapipe/examples/desktop/autoflip/README.md index 4bf4315b..250fcf4b 100644 --- a/mediapipe/examples/desktop/autoflip/README.md +++ b/mediapipe/examples/desktop/autoflip/README.md @@ -17,9 +17,7 @@ GLOG_logtostderr=1 bazel-bin/mediapipe/examples/desktop/autoflip/run_autoflip \ --calculator_graph_config_file=mediapipe/examples/desktop/autoflip/autoflip_graph.pbtxt \ - --input_side_packets=input_video_path=/absolute/path/to/the/local/video/file,\ - output_video_path=/absolute/path/to/save/the/output/video/file,\ - aspect_ratio=width:height + --input_side_packets=input_video_path=/absolute/path/to/the/local/video/file,output_video_path=/absolute/path/to/save/the/output/video/file,aspect_ratio=width:height ``` 3. View the cropped video. diff --git a/mediapipe/util/sequence/media_sequence.cc b/mediapipe/util/sequence/media_sequence.cc index 9f00be3c..9fa78723 100644 --- a/mediapipe/util/sequence/media_sequence.cc +++ b/mediapipe/util/sequence/media_sequence.cc @@ -217,6 +217,18 @@ float TimestampsToRate(int64 first_timestamp, int64 second_timestamp) { sequence); } } + if (GetPointSize(prefix, *sequence) > 0) { + std::string x_key = merge_prefix(prefix, kRegionPointXKey); + auto* region_feature_list = MutableFeatureList(x_key, sequence); + RET_CHECK_EQ(num_bboxes, region_feature_list->feature_size()) + << "Expected number of BBox timestamps and boxes to match."; + ClearBBoxNumRegions(prefix, sequence); + for (int i = 0; i < num_bboxes; ++i) { + AddBBoxNumRegions( + prefix, region_feature_list->feature(i).float_list().value_size(), + sequence); + } + } // Collect which timestamps currently match to which indices in timestamps. // skip empty timestamps. // Requires sorted indices.