【发布时间】:2017-02-22 09:20:44
【问题描述】:
我正在使用 python 2.7 和 opencv 3.1 我想通过这个来运行跟踪对象的代码:
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)
但是当我运行它时,我遇到了这个错误:
AttributeError: 'module' object has no attribute 'Tracker_create'
这里是源代码:http://www.learnopencv.com/object-tracking-using-opencv-cpp-python/ 我正在寻找解决方案,但找不到任何有用的东西…… 我该怎么做才能将此模块添加到我的 opencv 库中?
【问题讨论】: