Fixed bug in ObjectDetection effect

The bug made Openshot crash if two or more ObjectDetection effects were added to the any clip on the timeline.
The bug was solved by removing the static int kf_count variable from KalmanTracker. This variable was being incremented even if the ObjectDetection effect was removed from the clip, that caused the wrong Tracked Objects indexes to be added to the trackedObjects map.
This commit is contained in:
Brenno
2021-01-30 17:43:02 -03:00
parent fd88a60bb1
commit b875b4d255
3 changed files with 5 additions and 11 deletions

View File

@@ -7,8 +7,6 @@
using namespace std;
using namespace cv;
int KalmanTracker::kf_count = 0;
// initialize Kalman filter
void KalmanTracker::init_kf(
StateType stateMat)

View File

@@ -21,18 +21,16 @@ public:
m_hits = 0;
m_hit_streak = 0;
m_age = 0;
m_id = kf_count;
//kf_count++;
m_id = 0;
}
KalmanTracker(StateType initRect, float confidence, int classId) : confidence(confidence), classId(classId)
KalmanTracker(StateType initRect, float confidence, int classId, int objectId) : confidence(confidence), classId(classId)
{
init_kf(initRect);
m_time_since_update = 0;
m_hits = 0;
m_hit_streak = 0;
m_age = 0;
m_id = kf_count;
kf_count++;
m_id = objectId;
}
~KalmanTracker()
@@ -47,8 +45,6 @@ public:
StateType get_state();
StateType get_rect_xysr(float cx, float cy, float s, float r);
static int kf_count;
int m_time_since_update;
int m_hits;
int m_hit_streak;

View File

@@ -54,7 +54,7 @@ void SortTracker::update(vector<cv::Rect> detections_cv, int frame_count, double
tb.confidence = confidences[i];
detections.push_back(tb);
KalmanTracker trk = KalmanTracker(detections[i].box, detections[i].confidence, detections[i].classId);
KalmanTracker trk = KalmanTracker(detections[i].box, detections[i].confidence, detections[i].classId, i);
trackers.push_back(trk);
}
return;
@@ -167,7 +167,7 @@ void SortTracker::update(vector<cv::Rect> detections_cv, int frame_count, double
// create and initialise new trackers for unmatched detections
for (auto umd : unmatchedDetections)
{
KalmanTracker tracker = KalmanTracker(detections[umd].box, detections[umd].confidence, detections[umd].classId);
KalmanTracker tracker = KalmanTracker(detections[umd].box, detections[umd].confidence, detections[umd].classId, umd);
trackers.push_back(tracker);
}