'Getting Run Time Error(Not getting the desired output in Sign Language recognition project)

I am trying to make a sign language recognition project. There is no error shown by the compiler. But when I run it do not recognize any of the signs. Here is the code:

 cap=cv2.VideoCapture(0)

while True:
    ret,frame=cap.read()

    roi=frame[100:400,320:620]
    cv2.imshow('roi',roi)
    roi=cv2.cvtColor(roi,cv2.COLOR_BGR2GRAY)
    roi=cv2.resize(roi,(28,28),interpolation=cv2.INTER_AREA)

    cv2.imshow('roi scaled and gray', roi)
    copy=frame.copy()
    cv2.rectangle(copy,(320,100),(620,400),(255,0,0),5)

    roi=roi.reshape(1,28,28,1)

    result=str(model.predict(roi,1,verbose=0)[0])
    np.argmax(result)
    cv2.putText(copy,getLetter(result),(300,100),cv2.FONT_HERSHEY_COMPLEX,2,(0,255,0),2)
    cv2.imshow('frame',copy)

    if cv2.waitKey(1)== 13:
        break
cap.release()
cv2.destroyAllWindows()

I searched about this and came to know that there is some problem with the line

 result=str(model.predict(roi,1,verbose=0)[0])

What to change in the code to get the desired output?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source