You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
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:
@@ -7,8 +7,6 @@
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
int KalmanTracker::kf_count = 0;
|
||||
|
||||
// initialize Kalman filter
|
||||
void KalmanTracker::init_kf(
|
||||
StateType stateMat)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user