在视频的第一帧,我正在运行一个对象检测器,它返回一个像这样的对象的边界框:
<type 'tuple'>: ((786, 1225), (726, 1217), (721, 1278), (782, 1288))
我想将此边界框作为跟踪器的初始边界框传递。但是,我收到以下错误:
OpenCV Error: Backtrace (The model is not initialized) in init, file /Users/jenkins/miniconda/1/x64/conda-bld/conda_1486588158526/work/opencv-3.1.0/build/opencv_contrib/modules/tracking/src/tracker.cpp, line 81
Traceback (most recent call last):
File "/Users/mw/Documents/Code/motion_tracking/motion_tracking.py", line 49, in <module>
tracker.init(frame, bbox)
cv2.error: /Users/jenkins/miniconda/1/x64/conda-bld/conda_1486588158526/work/opencv-3.1.0/build/opencv_contrib/modules/tracking/src/tracker.cpp:81: error: (-1) The model is not initialized in function init
框架形状为1080 x 1920
,传递到跟踪器的值I&#39; m如下所示:
我不确定我发送边界框的订单是错误的,还是我做错其他的事情。
tracker = cv2.Tracker_create("MIL")
init_once = False
while True:
(grabbed, frame) = camera.read()
if not grabbed:
break
symbols = scan(frame)
for symbol in symbols:
if not init_once:
bbox = (float(symbol.location[0][0]), float(symbol.location[0][1]), float(symbol.location[2][0]), float(symbol.location[2][1]))
tracker.init(frame, bbox)
init_once = True
break
# draw_symbol(symbol, frame)
_, newbox = tracker.update(frame)
if _:
top_left = (int(newbox[0]), int(newbox[1]))
bottom_right = (int(newbox[0] + newbox[2]), int(newbox[1] + newbox[3]))
cv2.rectangle(frame, top_left, bottom_right, (200, 0, 0))
cv2.imshow("asd", frame)
out.write(frame)
out.release()