I am new to python programing. I am using background subtraction on avi video file followed by tracking the cells in image using trackpy
When i run the code it gives the error: raise KeyError(key) from err KeyError: 'frame'
my code is
import cv2
import trackpy as tp
cap = cv2.VideoCapture('0.3_1_23.64fps.avi')
fgbg = cv2.createBackgroundSubtractorKNN()
while(1):
ret, frame = cap.read()
if ret == 1:
fgmask = fgbg.apply(frame)
#cv2.imshow('fgmask',fgmask)
#k = cv2.waitKey(30) & 0xff
#if k == 27:
# break
else:
break
cap.release()
cv2.destroyAllWindows()
f = tp.locate(fgmask, 25, invert=False, minmass= 30)
#tp.annotate(f, fgmask)
t = tp.link(f, 5, memory=5)
I am using background subtraction on avi video file followed by tracking the cells in image using trackpy
KeyError indicates that the requested key of the key/value pair the dictionary uses cannot be found/does not exist. It may be that you are passing malformed data into your package's functions. I don't know the specifics of cv2 or trackpy, but make sure that the arguments for the functions you're using from them are getting proper data.
Also take note of the 4 commented out lines in the middle of the code:
If none of this helps, you can try looking into the package's files and making sure they're working correctly. You can try re-downloading them, but this is unlikely to be the answer.