Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1255

Python • Error 139, segmentation fault

$
0
0
Hi there, when i try run python opencv code on my raspberry pi 4b with 2gb ram, i get error 139, segmentation fault
there is my code, who can help??

Code:

import cv2import face_recognition# Захват видеопотока с камерыvideo_capture = cv2.VideoCapture(0)# Загрузка известных изображений и их кодированиеknown_image = face_recognition.load_image_file("known_person.jpg")known_face_encoding = face_recognition.face_encodings(known_image)[0]known_face_names = ["Known Person"]while True:    # Захват кадра из видеопотока    ret, frame = video_capture.read()    # Преобразование изображения в формат RGB (OpenCV использует BGR)    rgb_frame = frame[:, :, ::-1]    # Найти все лица и их координаты в текущем кадре    face_locations = face_recognition.face_locations(rgb_frame)    face_encodings = face_recognition.face_encodings(rgb_frame, face_locations)    # Сравнение лиц из видеопотока с известными лицами    for (top, right, bottom, left), face_encoding in zip(face_locations, face_encodings):        matches = face_recognition.compare_faces([known_face_encoding], face_encoding)        name = "Unknown"        # Если найдено совпадение        if True in matches:            first_match_index = matches.index(True)            name = known_face_names[first_match_index]        # Отображение имени над распознанным лицом        cv2.rectangle(frame, (left, top), (right, bottom), (0, 255, 0), 2)        cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 255, 0), cv2.FILLED)        font = cv2.FONT_HERSHEY_DUPLEX        cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)    # Показ видеопотока с рамками и именами    cv2.imshow('Video', frame)    # Прерывание по нажатию клавиши 'q'    if cv2.waitKey(1) & 0xFF == ord('q'):        break# Очищаем ресурсыvideo_capture.release()cv2.destroyAllWindows()

Statistics: Posted by shadowpolka — Sun Sep 22, 2024 7:42 am



Viewing all articles
Browse latest Browse all 1255

Trending Articles