fix spot tracking

This commit is contained in:
Piotr Dobrowolski 2020-04-05 16:32:59 +02:00
parent 75cc736490
commit 514034d2c8

View File

@ -50,7 +50,7 @@ def run(path):
if ret == True: if ret == True:
h, w, channels = frame.shape h, w, channels = frame.shape
smol = frame[int(h*0.5):int(h*0.9), int(w*0.58):int(w*0.8)] smol = frame[int(h*0.5):int(h*0.9), int(w*0.55):int(w*0.8)]
gray = cv2.cvtColor(smol, cv2.COLOR_BGR2GRAY) gray = cv2.cvtColor(smol, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (7, 7), 0) blurred = cv2.GaussianBlur(gray, (7, 7), 0)
thresh = cv2.threshold(blurred, 235, 255, cv2.THRESH_BINARY)[1] thresh = cv2.threshold(blurred, 235, 255, cv2.THRESH_BINARY)[1]
@ -59,7 +59,7 @@ def run(path):
for c in cnts: for c in cnts:
area = cv2.contourArea(c) area = cv2.contourArea(c)
if area > 30 and area < 80: if area > 28 and area < 80:
# compute the center of the contour # compute the center of the contour
M = cv2.moments(c) M = cv2.moments(c)
cX = int(M["m10"] / M["m00"]) cX = int(M["m10"] / M["m00"])
@ -104,7 +104,7 @@ def run(path):
turnedon = False turnedon = False
spots = [spot for spot in spots if spot['lastseen'] > framenum - framerate] spots = [spot for spot in spots if spot['lastseen'] > framenum - framerate]
spots.sort(key=lambda v: v['lastseen'], reverse=True) spots.sort(key=lambda v: v['lifetime'], reverse=True)
framenum += 1 framenum += 1
if gui: if gui: