OpenCV: Adapt to API changes in OpenCV 4.5.2+ (#639)

* CVTracker: Handle API changes in OpenCV
The former cv::Tracker API we've been using is now cv::legacy::Tracker,
starting in OpenCV 4.5.1.

* CVTracker: Move some includes, add std:: prefixes

* Move ClipProcessingJobs into openshot NS

* OpenCV 4.5.1 message and auto-disabling

* Add fstream includes, explicit std:: namespace
Work around a MacOS bug where bare fstream resolves to the wrong class.

Co-authored-by: Brenno <brenno.caldato@gmail.com>
Co-authored-by: Brenno A. C. Caldato <BrennoCaldato@users.noreply.github.com>
This commit is contained in:
Frank Dana
2021-05-04 07:33:47 -04:00
committed by GitHub
parent aa57219eb9
commit 813c5175ca
13 changed files with 144 additions and 55 deletions

View File

@@ -28,8 +28,14 @@
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string>
#include <memory>
#include <fstream>
#include <iostream>
#include "effects/Tracker.h"
#include "Exceptions.h"
#include <google/protobuf/util/time_util.h>
using namespace std;
@@ -104,14 +110,16 @@ std::shared_ptr<Frame> Tracker::GetFrame(std::shared_ptr<Frame> frame, int64_t f
// Load protobuf data file
bool Tracker::LoadTrackedData(std::string inputFilePath){
using std::ios;
// Create tracker message
pb_tracker::Tracker trackerMessage;
{
// Read the existing tracker message.
fstream input(inputFilePath, ios::in | ios::binary);
std::fstream input(inputFilePath, ios::in | ios::binary);
if (!trackerMessage.ParseFromIstream(&input)) {
cerr << "Failed to parse protobuf message." << endl;
std::cerr << "Failed to parse protobuf message." << std::endl;
return false;
}
}
@@ -202,7 +210,7 @@ void Tracker::SetJsonValue(const Json::Value root) {
protobuf_data_path = (root["protobuf_data_path"].asString());
if(!LoadTrackedData(protobuf_data_path)){
std::cout<<"Invalid protobuf data path";
std::cerr << "Invalid protobuf data path\n";
protobuf_data_path = "";
}
}