目標追蹤演算法

2021-09-22 19:51:53 字數 2729 閱讀 7586

#include #include using namespace cv;

using namespace std;

// global variables

rect box;

bool drawing_box = false;

bool gotbb = false;

// bounding box mouse callback

void mousehandler(int event, int x, int y, int flags, void *param)

break;

case cv_event_lbuttondown:

drawing_box = true;

box = rect( x, y, 0, 0 );

break;

case cv_event_lbuttonup:

drawing_box = false;

if( box.width < 0 )

if( box.height < 0 )

gotbb = true;

break;

}}

// tracker: get search patches around the last tracking box,

// and find the most similar one

void tracking(mat frame, mat &model, rect &trackbox)

int main(int argc, char * ar**)

//register mouse callback to draw the bounding box

cvnamedwindow("tracker", cv_window_autosize);

cvsetmousecallback("tracker", mousehandler, null );

mat frame, model;

capture >> frame;

while(!gotbb)

//remove callback

cvsetmousecallback("tracker", null, null );

mat gray;

cvtcolor(frame, gray, cv_rgb2gray);

model = gray(box);

int framecount = 0;

while (1)

return 0;

}

模板匹配的表現

zcu102 1920*1080

小目標大約在60-70ms

這個的版本號較高,kcf建立方式略有不同。

#include #include #include #include #include #include using namespace std;

using namespace cv;

int main()

cout << "press c to leap current image" << endl;

cout << "press q to slect current image" << endl;

cout << "press empty key to start track rio object" << endl;

cap >> frame;

while (1)

if (key == 'q') // 按q鍵退出跳幀

imshow("first", frame);

}cv::destroywindow("first");

roi = selectroi("tracker", frame);

if (roi.width == 0 || roi.height == 0)

return 0;

tracker->init(frame, roi);

// perform the tracking process

printf("start the tracking process\n");

for (;; )

// update the tracking result

tracker->update(frame, roi);

// draw the tracked object

rectangle(frame, roi, scalar(255, 0, 0), 2, 1);

// show image with the tracked object

imshow("tracker", frame);

//quit on esc button

if (char(waitkey(1)) == 'q')

}return 0;

}

這個對應opencv 3.1版本的

#include #include #include #include #include #include using namespace std;

using namespace cv;

int main()

return 0;

}

關於select roi設定問題,參考下面的部落格

看一下在zcu102上的表現 4核a53

1920*1080的影象,小目標。

時間是130ms

目標追蹤 多目標追蹤之資料關聯

最近忙著寫 斷更很久,現在和大家分享一下我目前研究的多目標追蹤中的資料關聯問題。首先說明一下我本人目前是做基於船舶自動駕駛的資料融合和多目標追蹤,儘管和計算機視覺方向的多目標追蹤本質是一樣的,但是兩個領域的技術手段是不同的。具體說來,cv方向更側重於高質量高可靠的檢測結果的獲取和提純,而雷達方向則更...

目標追蹤 背景分割

coding utf 8 import cv2 import numpy as np from mycvutils import mycvutils datapath d imgdata video bs cv2.createbackgroundsubtractorknn detectshadows...

多目標追蹤總結

多目標追蹤 multi object tracking,mot 有兩種思路 具體的一些演算法上文提到了,km匹配演算法 kcf 核相關濾波演算法 deep sort 針對自己的需要,可以有選擇性的選擇某類演算法。目前主流的多目標追蹤演算法為分三類 1.以匈牙利 km匹配的後端追蹤優化演算法。代表性的...