如何将 OpenCV Tracker 与 tif 图像一起使用?

问题描述

我想将 cv2 Tracker 与连续的图像序列一起使用(以便执行实时跟踪)。因此,我不能使用vs = cv2.VideoCapture("video.mp4"),我会有一堆numpy数组需要一个一个分析,有什么办法可以使用frame = vs.read()来初始化跟踪器并更新跟踪器每个获取的图像?

我已经尝试获取一些图像,然后将它们转换为视频(mp4 或 avi),但是您可以想象这个过程非常缓慢,而且对实时跟踪毫无用处。

我想做这样的事情:

from tifffile import imread,imsave

img = imread("filename.tif") #shape = (1024,1024)

#HERE IS WHERE I HAVE PROBLEMS
vs = Treat_the_image_as_video(img) #In normal cases,here we would use cv2.VideoCapture
frame = vs.read() #?

bbox = get_bbox(image) #Get the bbox from the image (I already have this with cv2.findContours)
tracker = cv2.TrackerKCF_create() #Create tracker
tracker.init(frame,bbox)
while(True):
   (success,bbox) = tracker.update(frame)
   .
   .
   #Place the rectangle and text
   .
   .
   img = imread("filename.tif") #shape = (1024,1024)
   vs = Treat_the_image_as_video(img) #?
   frame = vs.read() #?

如果您能就我如何解决此问题给我任何建议或提示,我将不胜感激。 提前致谢!!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)