A little problem in Image Recognition in video

Hi all!
I’ve already create an image recognition application, now I want to use it to do real-time recognition, I wonder how can I do it?
I was thinking use opencv to get the camera video frame, and I hope to apply my image recognition application on it, here’s my code:

cap = cv2.VideoCapture(0)
cap.open(0)
learn = load_learner(path)
while(cap.isOpened()):
ret, frame = cap.read()
cv2.imshow(‘frame’,frame)
while()
pred_class,pred_idx,outputs = learn.predict(frame)
pred_class
if cv2.waitKey(1)&0xFF == ord(‘q’):
break
cap.release()
cv2.destoryWindow(‘frame’)

And I get an error:
AttributeError: ‘numpy.ndarray’ object has no attribute ‘apply_tfms’

So how can I fix the problem to get my code work?
Thanks to everyone who answer it.

1 Like