Tracker property access fails with SEGFAULT on ARM, but works in X86_64

asked 2020-05-27 08:23:22 -0600

Rok gravatar image

updated 2020-05-27 09:53:23 -0600

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!

Problem is only with mosse.

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.";
    }
}
edit retag flag offensive close merge delete

Comments

You can't used code from machine to ARM using linux. You will have to used g++ on linux when using Raspberry pi.

supra56 gravatar imagesupra56 ( 2020-05-28 03:53:11 -0600 )edit

This code will work on Raspberry too Tracker::create Or better one better one

supra56 gravatar imagesupra56 ( 2020-05-28 04:05:10 -0600 )edit
1

I compiled on Raspberry of course.. I also tried version 3.4.10 ad works properly on raspberry, there must a bug since version 4+

Rok gravatar imageRok ( 2020-05-28 10:59:00 -0600 )edit