我有一個計算成本高昂的方式來查找圖像中某個特徵的確切邊界框。在所有後續圖像上,該功能可能已移動。我希望避免在每一幀上執行這個計算量很大的過程。是否有一種技術可以使用諸如背景減法+輪廓檢測之類的功能追蹤一個特徵,並在其邊界框被識別一次之後?從鏈接知道圖像中某個特徵的確切位置後,在所有後續幀上跟蹤它。
回答
Object Tracking using OpenCV (C++/Python)
的Python代碼示例:
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) # x, y, width, height
# 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)
while True:
# Read a new frame
ok, frame = video.read()
if not ok:
break
# Update tracker
ok, bbox = tracker.update(frame)
# Draw bounding box
if ok:
p1 = (int(bbox[0]), int(bbox[1]))
p2 = (int(bbox[0] + bbox[2]), int(bbox[1] + bbox[3]))
cv2.rectangle(frame, p1, p2, (0,0,255))
# Display result
cv2.imshow("Tracking", frame)
# Exit if ESC pressed
k = cv2.waitKey(1) & 0xff
if k == 27 : break
希望這有助於!
邊界框中點的順序是什麼?我得到[這個錯誤](http://stackoverflow.com/questions/43593444/opencv-tracker-the-model-is-not-initialized-in-function-init)當我嘗試這種方法 – Carpetfizz
一個元組與4值通過以下命令:1.邊界框左上角的x座標 2.邊界框左上角的y座標 3.邊界框的寬度 4.邊界框的高度 – kai06046
座標系的高度如何座標是1值? – Carpetfizz
- 1. 視頻幀中的特徵跟蹤
- 2. 排序後跟蹤位置
- 3. 在Android中某個位置所花費的跟蹤時間
- 4. 如何在上傳後跟蹤並顯示上傳的圖像?
- 5. 某個點後切割圖像
- 6. UWP後臺任務位置跟蹤
- 7. 連續幀中的跟蹤功能
- 8. 圖像旋轉和跟蹤位置
- 9. 在滾動時跟蹤滾動視圖中圖像的位置
- 10. iOS4在後臺和時間間隔中的位置跟蹤
- 11. 連續跟蹤位置Windows Phone 8
- 12. HTML5跟蹤地理位置持續
- 13. 在android中跟蹤位置
- 14. 更改跟蹤器將不正確後續的ID分配給
- 15. 位置跟蹤
- 16. 跟蹤位置
- 17. 請求知道他們的位置後,他否認它
- 18. cllocation跟蹤一個位置
- 19. 檢查確切位置的確切圖像是否在屏幕上
- 20. 瞭解iOS中用戶位置的後臺跟蹤
- 21. 在matlab中跟蹤圖像
- 22. XNA跟蹤旋轉的像素位置
- 23. 面部特徵檢測與跟蹤
- 24. 自然特徵跟蹤 - 增強現實
- 25. 後退按鈕後跟蹤
- 26. 在QGraphicsItem上跟蹤鼠標位置
- 27. 是否可以在gogle地圖上知道有限距離上所有方向上所有位置的名稱?
- 28. 如何知道位置是地圖中另一個位置的前/後的位置
- 29. 如何確定某個鍵是否被按下,只知道它在美式鍵盤上的位置?
- 30. 加載的DLL能夠知道它所在的位置嗎?
嘗試openCV 3.1的TLD跟蹤 – Micka