如何使用匈牙利算法将连续两帧之间的对应目标关联起来,最终实现可以判断下一帧中的运动目标是已经存在的还是新的?我没有在实际执行程序时如何开始使用C++和Opencv3库?
现在我可以得到每帧卡尔曼滤波器检测到的运动目标的质心。
//这是主函数的一部分。
kalmanv.clear();
initKalman(0, 0);
Point s, p;//s:kalmanCorrect,p:kalmanPredict
//variable definition
vector<vector<Point>> contours;//rectangular frame position around the contour
vector<Vec4i> hierarchy;
int count = 0;
Mat frame, gray, mogMask;
char numText[8];
while (capture.read(frame)) {
...
findContours(mogMask, contours, hierarchy, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE, Point(0, 0));
//definition of moment and center moment
vector<Moments> mu(contours.size());
vector<Point2f> mc(contours.size());
...
mu[t] = moments(contours[t], false);//calculate moment
mc[t] = Point2f(mu[t].m10 / mu[t].m00, mu[t].m01 / mu[t].m00);//calculate center moment
measurement(0) = mc[t].x;
measurement(1) = mc[t].y;
p = kalmanPredict();
Point center = Point(selection.x + (selection.width / 2), selection.y + (selection.height / 2));//calculate centroid
s = kalmanCorrect(center.x, center.y);
//I don't know what to do next.
}
我已经得到了移动目标的质心点集合,那么如何结合匈牙利算法使用这些数据?