<p>我正在使用python 2.7和opencv 3.1
我想运行一个跟踪对象的代码:</p>
<pre><code>import cv2
import sys
if __name__ == '__main__' :
# Set up tracker.
# Instead of MIL, you can also use
# BOOSTING, KCF, TLD, MEDIANFLOW or GOTURN
tracker = cv2.Tracker_create("MIL")
# Read video
video = cv2.VideoCapture("videos/chaplin.mp4")
# Exit if video not opened.
if not video.isOpened():
print "Could not open video"
sys.exit()
# Read first frame.
ok, frame = video.read()
if not ok:
print 'Cannot read video file'
sys.exit()
# Define an initial bounding box
bbox = (287, 23, 86, 320)
# Uncomment the line below to select a different bounding box
# bbox = cv2.selectROI(frame, False)
# Initialize tracker with first frame and bounding box
ok = tracker.init(frame, bbox)
</code></pre>
<p>但当我运行它时,我会面临这个错误:</p>
<p><code>AttributeError: 'module' object has no attribute 'Tracker_create'</code></p>
<p>这是源代码:<a href="http://www.learnopencv.com/object-tracking-using-opencv-cpp-python/" rel="noreferrer">http://www.learnopencv.com/object-tracking-using-opencv-cpp-python/</a>
我在寻找解决办法,但我找不到任何有用的…
如何将此模块添加到我的opencv库中?</p>