大家好,又见面了,我是你们的朋友全栈君。
修改siamfc文件夹下的Load.py文件
import sys
sys.path.append('/home/nanorobot/Documents/siamfc/siamfc')
sys.path.append('/home/nanorobot/Documents/siamfc')
from siamfc import TrackerSiamFC, ops
上面是把需要用到的自定义的模块路径引入进来,以防后面找不到模块,路径根据你自己的文件位置改。
下面是修改主函数:
if __name__ == '__main__':
seq_dir = os.path.expanduser('/home/nanorobot/Documents/siamfc/BlurBody/')
img_files = sorted(glob.glob(seq_dir + 'datasets/*.jpg'))
anno = np.loadtxt(seq_dir + 'groundtruth.txt')
ims = [cv2.imread(imf) for imf in img_files]
VeryBig = 999999999
Cap = cv2.VideoCapture(0)
ret,frame = Cap.read()
ims = [frame]
cv2.namedWindow('SiamFC', cv2.WND_PROP_FULLSCREEN)
init_rect = cv2.selectROI("SiamFC", ims[0], False, False)
cv2.waitKey(0)
x, y, w, h = init_rect
print(x, y, w, h)
toc = 0
im = frame
target_pos = np.array([x+w/2, y+h/2])
target_sz = np.array([w, h])
net_path = seq_dir + 'siamfc_alexnet_e50.pth'
tracker = TrackerSiamFC(net_path=net_path)
tracker.init(frame, init_rect)
while(True):
ret, im = Cap.read()
if (ret==False):
break
box = tracker.update(im)
ops.show_image(im, box,cvt_code=None)
修改好后,运行
python Load.py
显示
选定目标
按下回车或者空格,等待一会儿就可以了
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/187154.html原文链接:https://javaforall.cn