Analyzing frames from OpenCV cv2.VideoCapture()

Got it working now:

def grab_image() :
    ret_val, img = cap.read()
    img_col = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
    pil_img = PImage.fromarray(img_col.astype('uint8'), 'RGB')
    pil_img = pil2tensor(pil_img,np.float32)
    inf_img = Image(pil_img.div_(255))
    return(inf_img, img)
6 Likes