当前位置:网站首页>Object tracking using tracker in opencv
Object tracking using tracker in opencv
2022-06-28 18:40:00 【Keep_ Trying_ Go】
List of articles
1. Pre knowledge
(1) Object tracking in the previous article
https://mydreamambitious.blog.csdn.net/article/details/125471084
(2)Opencv Draw a straight line in , rectangular , round , The ellipse , polygon ( Include polygon fill ), Draw text
https://mydreamambitious.blog.csdn.net/article/details/125392536
(3)Opencv Basic knowledge points in
https://mydreamambitious.blog.csdn.net/article/details/125351256
2. Code combat
(1) create a window
# create a window
cv2.namedWindow(winname='track',flags=cv2.WINDOW_AUTOSIZE)
cv2.resizeWindow(winname='track',width=750,height=600)
(2) Instantiate tracker and tracking algorithm
# Create trackers
trackers=cv2.MultiTracker_create()
# The algorithm used KCF
track_algorithm=cv2.TrackerKCF_create()
(3) Scales the size of the image
# Scale the height and width of the picture
height,width,channel=frame.shape
# Zoom factor
factor=500/width
height=int(factor*height)
frame=cv2.resize(src=frame,dsize=(500,height))
(4) Add tracked objects
# If you press t, Draw a rectangle on the object to be tracked
if key==ord('t'):
# selectRoi A tuple is returned [min_x,min_y,w,h]
#shwoCrosshair: Indicates whether to draw a cross on the rectangle ;fromCenter: Indicates whether to draw from the center of the rectangle
box=cv2.selectROI(windowName='track',img=frame,
showCrosshair=True,fromCenter=False)
# Add tracker
trackers.add(track_algorithm,frame,box)
(5) Update the tracking results and draw a rectangle
# Update tracking results
ret,boxes=trackers.update(frame)
endtime=time.time()
FPS=1/(endtime-startime)
if ret:
for box in boxes:
x,y,w,h=int(box[0]),int(box[1]),int(box[2]),int(box[3])
cv2.rectangle(img=frame,pt1=(x,y),pt2=(x+w,y+h),color=(0,255,0),thickness=2)
cv2.putText(img=frame, text='FPS: ' + str(int(FPS)), org=(20, height - 50),
fontFace=cv2.FONT_HERSHEY_SIMPLEX, fontScale=1.0
, color=(0, 255, 0), thickness=2)
cv2.imshow('track',frame)
key=cv2.waitKey(30)
3. Demo video
Target tracking demo
边栏推荐
- 做跨境电商一定要学会用PRA软件,解放双手提高效率!
- halcon知识:矩阵专题【01】
- Sword finger offer 11 Minimum number of rotation array
- Lumiprobe丨Lumizol RNA 提取试剂解决方案
- 从知名软件提取出的神器,吊打一众付费
- Seata implementation of sharing JDBC distributed transaction
- Opencv中使用Tracker实现物体跟踪
- A preliminary study of IO model
- Small program graduation project based on wechat campus lost and found graduation project opening report function reference
- 东方财富软件股票开户是靠谱的吗?在哪开户安全
猜你喜欢

数据库对比工具

声网 VQA:将实时互动中未知的视频画质用户主观体验变可知

halcon知识:矩阵专题【01】

PHP使用栈解决迷宫问题

杂记:数据库go,begin,end,for,after,instead of

图形系统——1. 布局加载

Alist+RaiDrive 给电脑整个80亿GB硬盘

面部识别试验涉及隐私安全问题?国外一公司被紧急叫停

Small program graduation project based on wechat subscription water supply mall small program graduation project opening report function reference

Sword finger offer 11 Minimum number of rotation array
随机推荐
Record an emotet Trojan horse handling case
OOM out of memory 内存溢出
Dnslog injection
如何设计业务高性能高可用计算架构 - 作业
Common DOS commands
SMARCA2抗体研究:Abnova SMARCA2 单克隆抗体方案
今天开户今天能买股票吗?在线开户是安全么?
Lumiprobe丨Lumizol RNA 提取试剂解决方案
Openfire 3.8.2集群配置
手动备份和还原DHCP服务器
Does face recognition test involve privacy and security issues? A foreign company was urgently stopped
剑指 Offer 11. 旋转数组的最小数字
CORBA 架构体系指南(通用对象请求代理体系架构)
双功能交联剂丨Lumiprobe 磺基花青7二羧酸研究
打破学科之间壁垒的STEAM教育
SqlTransaction
Lumiprobe 蛋白质标记研究方案
Sharing-JDBC分布式事务之Seata实现
Lumiprobe ProteOrange 蛋白质凝胶染料说明书
Small program graduation project based on wechat examination small program graduation project opening report function reference