OPEN-CV错误:(-215:断言失败)函数'cv :: resize'中的!ssize.empty() [英] OPEN-CV error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'

查看:186
本文介绍了OPEN-CV错误:(-215:断言失败)函数'cv :: resize'中的!ssize.empty()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从流式视频中获取图像,并且花了几分钟,但是随后出现以下错误:cv2.error:OpenCV(4.1.1)C:\ projects \ opencv-python\ opencv \ modules \ imgproc \ src \ resize.cpp:3720:错误:(-215:断言失败)!函数'cv :: resize'中的ssize.empty()我的代码:

I am trying to get the images from a streaming video, and I get it for a few minutes, but then I get the following error: cv2.error: OpenCV (4.1.1) C:\projects\opencv-python\opencv\modules\imgproc\src\resize.cpp: 3720: error: (-215: Assertion failed)! ssize.empty () in function 'cv :: resize' My code:

while True:

ret, frame = video_capture.read()


small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)


rgb_small_frame = small_frame[:, :, ::-1]

#
if process_this_frame:

    face_locations = face_recognition.face_locations(rgb_small_frame, number_of_times_to_upsample=2)
    face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations)

    face_names = []
    for face_encoding in face_encodings:

        matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
        name = "None"

        # #
        # if True in matches:
        #     first_match_index = matches.index(True)
        #     name = known_face_names[first_match_index]

        face_distances = face_recognition.face_distance(known_face_encodings, face_encoding)
        best_match_index = np.argmin(face_distances)
        if matches[best_match_index]:
            name = known_face_names[best_match_index]

        face_names.append(name)
        if matches[best_match_index]:
            adicionar_json()

process_this_frame = not process_this_frame

font = cv2.FONT_ITALIC





for (top, right, bottom, left), name in zip(face_locations, face_names):

    top *= 4
    right *= 4
    bottom *= 4
    left *= 4

我正在尝试从rtsp摄像机获取视频流

I am trying to get video streaming from an rtsp camera

推荐答案

读取的帧失败.当您进行框架读取时,它会返回该框架和一个布尔值,指示读取是否成功-测试/预防您所面临的问题.

It's an unsuccessful frame-read. When you do a frame read, it returns the frame and a Boolean indicating whether the read was successful - to test/prevent the kind of issue you're facing.

尝试一下:

ret, frame = video_capture.read()

if ret:
    [frame processing code]

这篇关于OPEN-CV错误:(-215:断言失败)函数'cv :: resize'中的!ssize.empty()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆