繁体   English   中英

OPEN-CV 错误:(-215:Assertion failed).ssize:empty() in function 'cv::resize'

[英]OPEN-CV error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'

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

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 相机获取视频流

这是一个不成功的帧读取。 当您进行帧读取时,它会返回帧和指示读取是否成功的 Boolean - 以测试/防止您面临的问题。

尝试这个:

ret, frame = video_capture.read()

if ret:
    [frame processing code]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM