Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

TypeError: Expected cv::UMat for argument 'img'

I converted image into numpy array. <class 'numpy.ndarray'=""> But still why I am facing this error.

accum_time = 0
    curr_fps = 0
    fps = "FPS: ??"
    prev_time = timer()

while True:
        return_value, frame = vid.read()
        image = Image.fromarray(frame)
        image = detect_image(image)
        result = np.asarray(image)
        curr_time = timer()
        exec_time = curr_time - prev_time
        prev_time = curr_time
        accum_time = accum_time + exec_time
        curr_fps = curr_fps + 1
        if accum_time > 1:
            accum_time = accum_time - 1
            fps = "FPS: " + str(curr_fps)
            curr_fps = 0

        cv2.putText(result, text=fps, org=(3, 15), fontFace=cv2.FONT_HERSHEY_SIMPLEX,
                    fontScale=0.50, color=(255, 0, 0), thickness=2)

        cv2.namedWindow("result", cv2.WINDOW_NORMAL)
        cv2.imshow("result", result)


Traceback (most recent call last):
File "detect.py", line 228, in detect_ob
 fontScale=0.50, color=(255, 0, 0), thickness=2)
TypeError: Expected cv::UMat for argument 'img'