-
Notifications
You must be signed in to change notification settings - Fork 690
[Model] add tracking trail on vis_mot #461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
92eb0ab
c34b67a
5ac31e7
dd64a46
ff5ee8f
38ce0cf
cff22b8
d6215ad
db3c81e
1d64e35
0251b22
2910b3f
f2f95ad
c54af78
fff9af0
f8f6998
5b845b4
9f79627
6b9a5c4
1d134b0
d800402
d7b534e
c92e5d5
a0b7f67
cef6dd5
a4dedb8
d80be12
3da3d36
00fa281
1902c3c
e8c6f0b
9552329
33ab3e6
0a18021
e86411c
c80dbd9
6eb6a7a
cb424cd
c4bf265
7dbd62a
5b93f1d
4e8db89
9a3f1a4
5eaf19e
df0d551
23f329d
a5f5544
20edce2
09d9a7f
2e09944
b23bb44
0734229
edcdab6
dd99333
faaa94e
bef7cc9
25c1576
778de0d
e1b5cf4
7001bee
60ca6d4
4b4705b
470134f
a2fe764
8025d28
aa23471
87c00ce
d02baa3
ba7a848
4fd8144
cbd8ce1
4f5400f
10772b1
08d3bdc
08123fb
62e5352
875fb04
893036e
52c8063
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,6 @@ | |
|
|
||
| import fastdeploy as fd | ||
| import cv2 | ||
| import time | ||
| import os | ||
|
|
||
|
|
||
|
|
@@ -61,10 +60,10 @@ def build_option(args): | |
| model_file, params_file, config_file, runtime_option=runtime_option) | ||
|
|
||
| # 初始化轨迹记录器 | ||
| trail_recorder = fd.vision.tracking.TrailRecorder() | ||
| recorder = fd.vision.tracking.TrailRecorder() | ||
| # 绑定记录器 注意:每次预测时,往trail_recorder里面插入数据,随着预测次数的增加,内存会不断地增长, | ||
| # 可以通过unbind_trail_recorders()方法来解除绑定 | ||
| model.bind_trail_recorders(trail_recorder) | ||
| # 可以通过unbind_recorder()方法来解除绑定 | ||
| model.bind_recorder(recorder) | ||
| # 预测图片分割结果 | ||
| cap = cv2.VideoCapture(args.video) | ||
| # count = 0 | ||
|
|
@@ -75,10 +74,11 @@ def build_option(args): | |
| result = model.predict(frame) | ||
| # count += 1 | ||
| # if count == 10: | ||
| # model.unbind_trail_recorders() | ||
| img = fd.vision.vis_mot(frame, result, 0.0) | ||
| # model.unbind_recorder() | ||
| img = fd.vision.vis_mot(frame, result, 0.0, recorder) | ||
| cv2.imshow("video", img) | ||
| if cv2.waitKey(30) == ord("q"): | ||
| break | ||
| model.unbind_recorder() | ||
| cap.release() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 也显式调用一行model.unbind_trail_recorder()
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 添加显示调用 |
||
| cv2.destroyAllWindows() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,11 +15,13 @@ | |
| from __future__ import absolute_import | ||
| from .... import FastDeployModel, ModelFormat | ||
| from .... import c_lib_wrap as C | ||
| import logging | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 可以改成 这样在python层面可以直接用
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已按要求调整 |
||
|
|
||
| class TrailRecorder(C.vision.tracking.TrailRecorder): | ||
| def __init__(self): | ||
| super(TrailRecorder, self).__init__() | ||
| try: | ||
| TrailRecorder = C.vision.tracking.TrailRecorder | ||
| except Exception as e: | ||
| logging.warning("something was wrong, detail:" + str(e) + | ||
| "so 'TrailRecorder' can not be loaded") | ||
|
||
|
|
||
|
|
||
| class PPTracking(FastDeployModel): | ||
|
|
@@ -54,8 +56,17 @@ def predict(self, input_image): | |
| assert input_image is not None, "The input image data is None." | ||
| return self._model.predict(input_image) | ||
|
|
||
| def bind_trail_recorders(self, val): | ||
| self._model.bind_trail_recorders(val) | ||
| def bind_recorder(self, val): | ||
| """ Binding tracking trail | ||
|
|
||
| :param val: (TrailRecorder) trail recorder, which is contained object's id and center point sequence | ||
| :return: None | ||
| """ | ||
| self._model.bind_recorder(val) | ||
|
|
||
| def unbind_trail_recorders(self): | ||
| self._model.unbind_trail_recorders() | ||
| def unbind_recorder(self): | ||
| """ cancel binding of tracking trail | ||
|
|
||
| :return: | ||
| """ | ||
| self._model.unbind_recorder() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在for循环后,显式调用一行
model.UnBindRecorder();便于用户直接了解There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
添加显示调用