Project import generated by Copybara.
GitOrigin-RevId: e9b30181bd6a75481835643d6f48c1c05730ff87
This commit is contained in:
@@ -144,11 +144,9 @@ namespace autoflip {
|
||||
// renderer.
|
||||
for (int i = 0; i < num_scene_frames; i++) {
|
||||
const int left = -(scene_frame_xforms[i].at<float>(0, 2));
|
||||
const int right = left + crop_width;
|
||||
const int top = top_static_border_size;
|
||||
const int bottom = frame_height_ - bottom_static_border_size;
|
||||
crop_from_location->push_back(
|
||||
cv::Rect(left, top, right - left, bottom - top));
|
||||
const int top =
|
||||
top_static_border_size - (scene_frame_xforms[i].at<float>(1, 2));
|
||||
crop_from_location->push_back(cv::Rect(left, top, crop_width, crop_height));
|
||||
}
|
||||
|
||||
// If no cropped_frames is passed in, return directly.
|
||||
|
||||
@@ -201,5 +201,29 @@ TEST(SceneCropperTest, CropFramesWorksWithPriorFocusPointFrames) {
|
||||
}
|
||||
}
|
||||
|
||||
// Checks that crop_from_locations gets the correct results.
|
||||
TEST(SceneCropperTest, CropFromLocation) {
|
||||
CameraMotionOptions options;
|
||||
options.mutable_polynomial_path_solver()->set_prior_frame_buffer_size(30);
|
||||
SceneCropper scene_cropper(options, kSceneWidth, kSceneHeight);
|
||||
std::vector<cv::Mat> cropped_frames;
|
||||
std::vector<cv::Rect> crop_from_locations;
|
||||
const auto& scene_frames = GetDefaultSceneFrames();
|
||||
MP_EXPECT_OK(scene_cropper.CropFrames(
|
||||
GetDefaultSceneKeyFrameCropSummary(), GetTimestamps(scene_frames.size()),
|
||||
GetIsKeyframe(scene_frames.size()), scene_frames,
|
||||
GetDefaultFocusPointFrames(), GetFocusPointFrames(3), 0, 0, false,
|
||||
&crop_from_locations, &cropped_frames));
|
||||
EXPECT_EQ(cropped_frames.size(), kNumSceneFrames);
|
||||
for (int i = 0; i < kNumSceneFrames; ++i) {
|
||||
EXPECT_EQ(cropped_frames[i].rows, kCropHeight);
|
||||
EXPECT_EQ(cropped_frames[i].cols, kCropWidth);
|
||||
}
|
||||
for (int i = 0; i < kNumSceneFrames; ++i) {
|
||||
EXPECT_EQ(crop_from_locations[i].height, kCropHeight);
|
||||
EXPECT_EQ(crop_from_locations[i].width, kCropWidth);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace autoflip
|
||||
} // namespace mediapipe
|
||||
|
||||
Reference in New Issue
Block a user