Tracking-with-darkflow
Tracking-with-darkflow copied to clipboard
Using tracking with darkflow from another python application
Hi, I am trying to use this application from another application in python.
import cv2 from darkflow.darkflow.defaults import argHandler #Import the default arguments from darkflow.darkflow.net.build import TFNet import numpy as np import time
option = { 'model': 'darkflow/cfg/yolo-voc.2.0.cfg', 'load': 'darkflow/bin/yolo-voc_26600.weights', 'threshold': 0.15, 'gpu': 0.5, 'track': True, 'trackObj': ["person"], 'saveVideo': False, 'BK_MOG':True, 'tracker': "deep_sort", 'skip': 0, 'csv': True, 'display':True }
tfnet = TFNet(option)
capture = cv2.VideoCapture(0) # using webcamera colors = [tuple(255 * np.random.rand(3)) for i in range(5)]
while (capture.isOpened()): stime = time.time() ret, frame = capture.read() contours_now = [] if ret: results = tfnet.return_predict(frame)
for color, result in zip(colors, results):
tl = (result['topleft']['x'], result['topleft']['y'])
br = (result['bottomright']['x'], result['bottomright']['y'])
label = result['label']
frame = cv2.rectangle(frame, tl, br, color, 7)
frame = cv2.putText(frame, label, tl, cv2.FONT_HERSHEY_COMPLEX, 1, (0, 0, 0), 2)
cv2.imshow('frame', frame)
print('FPS {:.1f}'.format(1 / (time.time() - stime)))
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
capture.release()
cv2.destroyAllWindows()
break
After results = tfnet.return_predict(frame), I want to feed this data to a tracking algorithm (deep_sort), so that I can get results with trackid. How can I do that? Thanks
可以看一下net/yolov2/predict.py中的相关函数