python获取vot gt坐标

https://github.com/jacke121/meta_trackers/tree/master/dataset

import cv2
import numpy as np
import os




data = {}
seq=r"../data/vot2016/bag/"
img_list = sorted([p for p in os.listdir(seq) if os.path.splitext(p)[1] == '.jpg'])
gt = np.loadtxt(seq + '/groundtruth.txt', delimiter=',')

assert len(img_list) == len(gt), "Lengths do not match!!"

if gt.shape[1] == 8:
    x_min = np.min(gt[:, [0, 2, 4, 6]], axis=1)[:, None]
    y_min = np.min(gt[:, [1, 3, 5, 7]], axis=1)[:, None]
    x_max = np.max(gt[:, [0, 2, 4, 6]], axis=1)[:, None]
    y_max = np.max(gt[:, [1, 3, 5, 7]], axis=1)[:, None]
    gt = np.concatenate((x_min, y_min, x_max - x_min, y_max - y_min), axis=1)

data[seq] = {'images': img_list, 'gt': gt}

for i,path in enumerate(img_list):
    img=cv2.imread(seq+path)
    pos_x, pos_y, target_w, target_h = gt[i]
    # pos_x = pos_x * 0.85
    # pos_y = pos_y * 0.8
    cv2.rectangle(img, (int(pos_x), int(pos_y)), (int(pos_x + target_w), int(pos_y + target_h)), (0, 255, 0), 2)

    cv2.imshow("asadf", img)
    cv2.waitKeyEx()



print(data)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI算法网奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值