'Using OpenCV Old Interface with OpenCV4 Library

I have an old C++ project which uses OpenCV 2.4.9, but I need to use some features from OpenCV4, so I want to upgrade My OpenCV library to version 4.

I don't want to change the old existing code. So, is there a way to upgrade to OpenCV4 but still using old OpenCV 2.4.9 interface?

cv::BackgroundSubtractorMOG2 and cv::MSER are used which their interfaces have changed.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source