Compile opencv modules in C++ mode, detect OpenCV4 pkgconfig
OpenCV has not supported compiling in C mode for quite some time, and even the remaining C API calls should be compiled in C++ mode. With OpenCV 4, compiling in C mode is no longer possible.
Compile the wrapper in C++ mode, and port the face detection example from the removed C API to its C++ equivalent.
Detect OpenCV 4 pkgconfig, and try fall back to OpenCV 3 when not found.
Tested with OpenCV 4.5.2 and 3.4.10.
This MR updates the code two work with current OpenCV versions. It does not change the behavior or the design of this module.
See #22016
Merge request reports
Activity
Thanks
Thanks for your contribution!
When all of the following conditions are fulfilled, your MergeRequest will be reviewed by the Team:
- the check pipeline passes
- the MR is considered as 'mergeable' by gitlab
You can find more details about the acceptance process here.
added 18 commits
-
ca6ad168...8a0834af - 15 commits from branch
videolan:master
- 2a89fc34 - Compile opencv modules in C++ mode
- 3096335c - Port OpenCV facedetect example to C++ API
- 57e9942b - Also detect OpenCV 4 via pkgconfig
Toggle commit list-
ca6ad168...8a0834af - 15 commits from branch
161 161 * We don't need to set up video formats for this filter as it not 162 162 * actually using a picture_t. 163 163 */ 164 p_sys->p_opencv = vlc_object_create( p_filter, sizeof(filter_t) ); 164 p_sys->p_opencv = static_cast<filter_t*>( vlc_object_create( p_filter, sizeof(filter_t) ) ); @Courmisch - please clarify.
There are no reasons to use
filter_t
here. The original developer was ostensibly just being lazy. Now this results what is at best a pair of very ugly casts.The thing is, this MR provides for C++ on both sides. Then, there not even reasons to use VLC C callbacks. You can just use a virtual class.
- Resolved by Rémi Denis-Courmont
added MRStatus::NotCompliant label
added 17 commits
-
57e9942b...1b500f00 - 14 commits from branch
videolan:master
- 05dc4cfb - Compile opencv modules in C++ mode
- 659187fd - Port OpenCV facedetect example to C++ API
- cd8e7875 - Also detect OpenCV 4 via pkgconfig
Toggle commit list-
57e9942b...1b500f00 - 14 commits from branch
added MRStatus::InReview label and removed MRStatus::NotCompliant label
- Resolved by Steve Lhomme
- Resolved by Steve Lhomme
- Resolved by Steve Lhomme
- Resolved by StefanBruens
- Resolved by Steve Lhomme
- Resolved by Steve Lhomme
- Resolved by Steve Lhomme
- Resolved by StefanBruens
- Resolved by StefanBruens
Since you use an
std::vector
, you either need to define a custom allocator that will track memory allocation failures or use try/catch on every function manipulating the vector size. Otherwise the C++ exception will unwind in the C code. I don't know OpenCV well and I don't know if it applies there too or if you can pass your custom allocator to OpenCV, but I guess the same applies here unfortunately. :/