Skip to content

Commit

Permalink
Come on
Browse files Browse the repository at this point in the history
  • Loading branch information
ross-endgame committed Dec 17, 2018
1 parent a97d680 commit 9c9621c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

setuptools.setup(
name="centroid_tracker",
version="0.0.1",
version="0.0.3",
author="Ross Leitch",
author_email="[email protected]",
description="A small centroid tracker library based off https://www.pyimagesearch.com/2018/07/23/simple-object-tracking-with-opencv/",
url="https://github.com/balbatross/centroid-tracker",
packages=['centroid-tracker'],
packages=['tracker'],
install_requires=[
'scipy',
'numpy'
Expand Down
File renamed without changes.
20 changes: 20 additions & 0 deletions centroid-tracker/centroidtracker.py → tracker/centroidtracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import OrderedDict
import numpy as np


class CentroidTracker():
def __init__(self, maxDisappeared=50):
self.nextObjectID = 0
Expand All @@ -19,6 +20,25 @@ def deregister(self, objectID):
del self.objects[objectID]
del self.disappeared[objectID]

def get_id(self, rect):
(x, y, eX, eY) = rect
cX = ((x + eX) / 2.0)
cY = ((y + eY) / 2.0)

objectIDs = list(self.objects.keys())
objectCentroids = list(self.objects.values())

D = dist.cdist(np.array(objectCentroids), [(cX, cY)])

rows = D.min(axis=1).argsort()
cols = D.argmin(axis=1)[rows]
objectID = None

for (row, col) in zip(rows, cols):
objectID = objectIDs[row]
break
return objectID

def update(self, rects):

if(len(rects) == 0):
Expand Down

0 comments on commit 9c9621c

Please sign in to comment.