# Revision history [back]

### OpenCV tracker: The model is not initialized in function init

On the first frame of a a video, I'm running an object detector that returns the bounding box of an object like this:

<type 'tuple'>: ((786, 1225), (726, 1217), (721, 1278), (782, 1288))


I want to pass this bounding box as the initial bounding box to the tracker. However, I get the following error:

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


The frame shape is 1080 x 1920 and the values I'm passing into tracker look like this:

I'm not sure if the order I'm sending the bounding box is wrong, or if I'm doing something else wrong.

tracker = cv2.Tracker_create("MIL")
init_once = False

while True:

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()


X-posting from this SO question, as this is kind of time sensitive - would appreciate any help!

### OpenCV tracker: The model is not initialized in function init

On the first frame of a a video, I'm running an object detector that returns the bounding box of an object like this:

<type 'tuple'>: ((786, 1225), (726, 1217), (721, 1278), (782, 1288))


I want to pass this bounding box as the initial bounding box to the tracker. However, I get the following error:

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


The frame shape is 1080 x 1920 and the values I'm passing into tracker look like this:

I'm not sure if the order I'm sending the bounding box is wrong, or if I'm doing something else wrong.wrong. It doesn't error out when I do something like bbox = (1,1,1,1) but obviously that doesn't do anything useful.

tracker = cv2.Tracker_create("MIL")
init_once = False

while True:

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()


X-posting from this SO question, as this is kind of time sensitive - would appreciate any help!