Merge pull request #22089 from tailsu:sd/fix-displaymatrix-orientation

This commit is contained in:
Alexander Alekhin 2022-06-13 18:17:08 +00:00
commit b19683eb41
2 changed files with 6 additions and 1 deletions

View File

@ -1840,7 +1840,7 @@ void CvCapture_FFMPEG::get_rotation_angle()
data = av_stream_get_side_data(video_st, AV_PKT_DATA_DISPLAYMATRIX, NULL); data = av_stream_get_side_data(video_st, AV_PKT_DATA_DISPLAYMATRIX, NULL);
if (data) if (data)
{ {
rotation_angle = cvRound(av_display_rotation_get((const int32_t*)data)); rotation_angle = -cvRound(av_display_rotation_get((const int32_t*)data));
if (rotation_angle < 0) if (rotation_angle < 0)
rotation_angle += 360; rotation_angle += 360;
} }

View File

@ -413,6 +413,11 @@ TEST(videoio, mp4_orientation_meta_auto)
EXPECT_NO_THROW(cap.open(video_file, CAP_FFMPEG)); EXPECT_NO_THROW(cap.open(video_file, CAP_FFMPEG));
ASSERT_TRUE(cap.isOpened()) << "Can't open the video: " << video_file << " with backend " << CAP_FFMPEG << std::endl; ASSERT_TRUE(cap.isOpened()) << "Can't open the video: " << video_file << " with backend " << CAP_FFMPEG << std::endl;
#ifndef _WIN32 // TODO: FFmpeg wrapper update
// related issue: https://github.com/opencv/opencv/issues/22088
EXPECT_EQ(90, cap.get(CAP_PROP_ORIENTATION_META));
#endif
cap.set(CAP_PROP_ORIENTATION_AUTO, true); cap.set(CAP_PROP_ORIENTATION_AUTO, true);
if (cap.get(CAP_PROP_ORIENTATION_AUTO) == 0) if (cap.get(CAP_PROP_ORIENTATION_AUTO) == 0)
throw SkipTestException("FFmpeg frame rotation metadata is not supported"); throw SkipTestException("FFmpeg frame rotation metadata is not supported");