Hi, I'm trying to port my application to a raspberry pi 4, but had no luck with trackers. I basically use a tracker as a class member. While this works on my Ubuntu machine, it causes a segmentation fault in raspberry. I reproduced the problem with this minimal working example (it does not make any sense, but depict exactly my problem). I'm using OpenCV 4.3.0 with support for INFERENCE ENGINE for both (in the raspberry I built it using the docker as indicated in the documentation). Segmentation fault occurs when I try to access the tracker properties (getDefaultName).. I cannot understand why this works on my computer and fails on the raspberry!
main.cpp
#include <iostream>
#include "person.h"
using namespace std;
int main()
{
cout << "Hello";
person p;
p.createTracker("mosse");
cout << p.tracker->getDefaultName();
return 0;
}
person.h
#ifndef PERSON_H
#define PERSON_H
#include <opencv2/core/core.hpp>
#include <opencv2/tracking/tracker.hpp>
class person
{
public:
person();
cv::Ptr<cv::Tracker> tracker;
void createTracker(std::string type);
};
#endif // PERSON_H
person.cpp
#include "person.h"
person::person()
{
}
void person::createTracker(std::string type)
{
if(type== "mosse") {
tracker = cv::TrackerMOSSE::create();
} else if(type == "csrt")
tracker = cv::TrackerCSRT::create();
else if(type == "kcf")
tracker = cv::TrackerKCF::create();
else if(type == "tld")
tracker = cv::TrackerTLD::create();
else {
std::cout << "Tracking type not specified! This should not happen.";
}
}