Add support for CAP_PROP_ORIENTATION_AUTO to AVFoundation backend#22792
Add support for CAP_PROP_ORIENTATION_AUTO to AVFoundation backend#22792asmorkalov merged 1 commit intoopencv:4.xfrom
Conversation
|
Thanks a lot for the contribution. It makes sense to extend existing FFmpeg targeted test for Apple platform too. See https://github.com/opencv/opencv/blob/4.x/modules/videoio/test/test_ffmpeg.cpp#L479. |
09b154b to
0342f9e
Compare
|
Added tests. I parametrized the ffmpeg tests by backend API, and moved them to test_orientation.cpp. I also changed an assert to check that both backends support orientation metadata. |
dbc67f2 to
d72e72b
Compare
|
The new test fails on Mac: |
|
CI platform: |
|
The tests seem to fail at the very end, when trying to read the actual frame into a mat and getting an empty mat as a result. Until that point all of the orientation metadata expectations pass. So, this issue doesn't seem to be caused by the PR changes themselves. It looks like AVFoundation simply has trouble decoding I can try uploading a new video with rotation metadata. Do you think it's worth a shot? |
|
I tried the rotated video and it works well with mplayer (ffmpeg) and vlc without hardware acceleration. VDPAU backend for VLC fails to play the video with rotation too. Not sure if it's related to rotation or very small amount of frames or some other option. Could you share very short clip with the option that could be used as test video? |
|
Pushed a new video in opencv/opencv_extra#1019 |
2c3bffe to
f0ca8bd
Compare
asmorkalov
left a comment
There was a problem hiding this comment.
Looks good to me in general!
|
@alalek Could you take a look? |
* extract rotateFrame as free function, rename to applyMetadataRotation * LegacyCapture::get() always return 0, if cap is null
f0ca8bd to
a462f49
Compare
|
opencv_extra PR is |
|
|
||
| cv::Mat tmp(height, width, CV_MAKETYPE(CV_8U, cn), data, step); | ||
| this->rotateFrame(tmp); | ||
| applyMetadataRotation(*this, tmp); |
There was a problem hiding this comment.
Apparently this PR breaks FFmpeg plugin build (with -DVIDEOIO_PLUGIN_LIST=ffmpeg option). In this mode it does not compile cap.cpp which contains applyMetadataRotation function and can not find it. Perhaps we could move this function to one of headers used by both AVFoundation and FFmpeg backends or to a separate source module and add it to the plugin compilation process.
There was a problem hiding this comment.
Should I take care of this in a separate PR or will you do it internally in the team?
There was a problem hiding this comment.
I'll try to fix it today.
This is an extension to #15499. I pulled some of the code up, so now it would be somewhat easier to add support for orientation metadata into the other backends as well.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.