New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenCV: Adapt to API changes in OpenCV 4.5.2+ #639
Conversation
The former cv::Tracker API we've been using is now cv::legacy::Tracker, starting in OpenCV 4.5.1.
It's already set on the command line, if needed
Codecov Report
@@ Coverage Diff @@
## develop #639 +/- ##
===========================================
- Coverage 52.42% 52.38% -0.05%
===========================================
Files 151 151
Lines 12346 12345 -1
===========================================
- Hits 6473 6467 -6
- Misses 5873 5878 +5
Continue to review full report at Codecov.
|
Open bug report regarding the private-header issue: opencv/opencv#19260 |
Thanks @ferdnyc. I'll check the tracking_internals.hpp problem |
(FTR, as expected doing this in a MinGW shell on Windows does fix the problem...) wget 'https://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-opencv-4.5.0-2-any.pkg.tar.zst'
pacman -U ./mingw-w64-x86_64-opencv-4.5.0-2-any.pkg.tar.zst |
Merge conflicts have been detected on this PR, please resolve. |
Merge conflicts have been detected on this PR, please resolve. |
@ferdnyc The issue with headers installation seems fixed in this PR (opencv/opencv#19817) and incorporated to opencv-contrib 4.5.2 We can move forward with this PR. I merged with Develop and tested it already but I cannot push it to your fork. If you prefer I can push directly to libopenshot and make a new PR Cc: @jonoomph |
@BrennoCaldato I'll give you push access, hold on a second while I remember how to invite collaborators... 😉 |
@BrennoCaldato Invite sent. |
I'm wondering if the version check should enable the legacy tracking code starting from OpenCV version 4.5.2, and if it detects 4.5.1 either emit a fatal config error, or emit a warning and disable OpenCV in the build. 'Cause... it just ain't gonna work. (And at least MSYS2 is, last I checked, still on 4.5.1 as their latest/current packaged release, for now.) |
Yeah, in fact 4.5.2 isn't even in the MSYS2 pending queue, so far. There's a notice up about the new version, but nobody's gotten around to packaging it yet. https://packages.msys2.org/base/mingw-w64-opencv |
Totally agree. I'm still not being able to push. I have already pulled the repo and it's up to date
|
@BrennoCaldato You should've gotten a collab invite for my repo through Github, I sent it yesterday. The other option, which I feel dumb for not thinking of sooner, is to pull one of my favorite tricks and open a PR against the PR. If you were to open a PR targeting the |
Meanwhile, because I'm a masochist I'm currently working on building OpenCV 4.5.2 as a MinGW package, so I can submit an update to MSYS2. It's slow going, though, because it's building in Win10 running in a VM on my Linux box. |
Updating legacy-tracker with current develop
Done with the PR against the PR :) |
Added a message to freak out and disable OpenCV, if evil version 4.5.1 is detected. |
Hmm. I'll check on those protection rules, I thought they only applied to |
Work around a MacOS bug where bare fstream resolves to the wrong class.
Ehhhhhhxcellent. I now have a MinGW{32,64} packaged build of OpenCV 4.5.2 for which, when libopenshot [ETA: this PR's branch of libopenshot, I mean] is built with it, all of our unit tests still pass. Just have to polish up the configs and the commits, and I can open a PR to MSYS2 and get it updated there. I also have to submit a PR to opencv, because they once again released broken code in the opencv_community package. (Though minorly, this time; a new module assumes that |
Great @ferdnyc. This means we can upgrade opencv after the effect-parenting is merged |
Hahaha! So, one minor issue I discovered with the Catch2/CTest "separate executable for each class" style of unit test runners: If you actually run the unit tests on a desktop Windows machine, you get a Firewall access request for each of the... 19 unit test runners! They're treated as separate applications. Which makes me think we probably need to do something akin to the (And part of me thinks it should always start disabled, unless it's explicitly activated by means of an environment variable, a config file setting, an API call, or some other mechanism. OpenShot actually uses ...But, this is all off topic. cc: @jonoomph |
OpenCV 2.5.2 packaging update submitted as msys2/MINGW-packages#8457. OpenCV module changes not submitted, because I discovered prior (and conflicting) PR opencv/opencv_contrib#2916. So now I'm hoping to get a response from the submitter there, as to why they chose their approach vs. mine, to see whether I should push forward with my changes or abandon them and adopt the ones from that PR instead. |
I'm going to extract just he CMake code that disables OpenCV support under 4.5.1, and merge that into The rest of what's here, actually I think we're pretty good on, so maybe it can all be merged. But I want to kind of "go around the room" to get everyone's take on that one more time, before merging... and I don't want to delay the 4.5.1-mitigating stuff even that long. |
Merge conflicts have been detected on this PR, please resolve. |
Whoops! Well, it seems the newly-released Fedora 34 includes OpenCV 4.5.2, so it's definitely time to merge this one. Going to do that now. |
Seems that OpenCV 4.5.1 has massively altered the
cv::Tracker
API, with the one our code uses being moved tocv::legacy::Tracker
, and a new implementation taking its place incv::Tracker
.Why this trigger was pulled with only a revision bump from 4.5.0 to 4.5.1, I cannot for the life of me understand, but
cv::TrackerBoosted
and friends are present in 4.5.0, but suddenly gone in 4.5.1. I encountered this when trying to build on Windows 10, now that MSYS2 is packaging OpenCV 4.5.1.A function
cv::legacy::upgradeTrackingAPI()
is provided which can seemingly be used to wrap old code. But, since that function is only present in 4.5.1+, it doesn't help us with simultaneous support of OpenCV versions before and after 4.5.1.Supporting OpenCV 4.5.1, specifically, turned out to be impossible as the released code is horribly broken for the "legacy" tracking API. There are headers missing from the install that make it unusable. Fortunately, 4.5.2 is since released that corrects this.
So, this PR blocks use of OpenCV verson 4.5.1 with a warning about the problem, and adds an
OpenCVUtilities.h
header which normalizes our code to be compatible with both the previous 4.5.0-and-earlier API, as well as the new-legacy 4.5.2+, in the manner of our other*Utilities.h
headers.The CMake build will define
USE_LEGACY_TRACKER
on the build command line if the OpenCV version is greater than4.5.1
, and if that macro is defined:OPENCV_TRACKER_TYPE
is defined to becv::legacy::Tracker
OPENCV_TRACKER_NS
is defined ascv::legacy
Otherwise, they are
cv::Tracker
andcv
, respectively.The rest of the code uses
cv::Ptr<OPENCV_TRACKER_TYPE>
as the pointer type fortracker
, andOPENCV_TRACKER_NS::TrackerImplementation::create()
to instantiate trackers.Other included changes
ClipProcessingJobs
class into theopenshot
namespace, because for some reason it wasn't..h
and.cpp
files, to avoid over-including headers, and dropped some unnecessary includesusing namespace std;
fromCVTracker.cpp
, addingstd::
prefixes where needed.