-1

I'm trying to read a video into python (be it live or pre-recorded is irrelevant) then have each frame processed using a thresholding algorithm to convert the video to a 2 colour format.

with a simple thresholding method, i get this error:

cv2.imshow('newFrame',newFrame) TypeError: Expected Ptr<cv::UMat> for argument 'mat'

Thresholding for images seems simple but i cant seem to convert the data produced from the thresholding method into a format that is recognised by anything further down the line. I have included the full code below.

import numpy as np
import cv2

cap = cv2.VideoCapture('Loop_1.mov')

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

        threshed = cv2.threshold(frame,50,255,cv2.THRESH_BINARY)
        newFrame = np.array(threshed)

        cv2.imshow('newFrame',newFrame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    else:
        break

# Release everything if job is finished
cap.release()
#out.release()
cv2.destroyAllWindows()
Prayson W. Daniel
  • 14,191
  • 4
  • 51
  • 57
  • [`cv2.threshold`](https://docs.opencv.org/master/d7/d1b/group__imgproc__misc.html#gae8a4a146d1ca78c626a53577199e9c57) returns a pair of values... – Dan Mašek Feb 18 '20 at 16:15

1 Answers1

0

The threshold function should return two parameters

retval, threshold = cv2.threshold(frame, 50, 255, cv2.THRESH_BINARY)

VIJAYA SRI
  • 32
  • 3