-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathobject_counting_log.py
More file actions
31 lines (23 loc) · 987 Bytes
/
object_counting_log.py
File metadata and controls
31 lines (23 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import cv2 as cv
class ObjectCountingLog:
""" 物体计数日志 """
def __init__(self, split_line):
self.split_line = split_line
self._counting_pic_list = []
def update_counting_pic_list(self, frame, new_counting_list):
"""
更新物体图像列表
:param frame: 图像
:param new_counting_list: 被新追踪到的物体列表
"""
# 维护此列表最多只有8个物体
if len(new_counting_list) + len(self._counting_pic_list) > 8:
del self._counting_pic_list[:len(new_counting_list)]
for each_object in new_counting_list:
x1, y1, x2, y2 = each_object.rect
object_pic = frame[y1 - self.split_line:y2 - self.split_line, x1:x2]
object_pic = cv.resize(object_pic, (160, 160))
self._counting_pic_list.append(object_pic)
def get_counting_pic_list(self):
"""获取图像列表"""
return self._counting_pic_list