我想将我的人脸识别系统从 PC 最小化到 Jetson nano。
在系统完成对数据集中的一些图像进行编码后,系统会冻结一段时间并被杀死。
这是我的代码:
import face_recognition
import cv2
import numpy as np
import os
import glob
import platform
def running_on_jetson_nano():
return platform.machine() == "aarch64"
def get_jetson_gstreamer_source(capture_width=1280, capture_height=720, display_width=1280, display_height=720, framerate=60, flip_method=0):
return (f'nvarguscamerasrc ! video/x-raw(memory:NVMM), ' +
f'width=(int){capture_width}, height=(int){capture_height}, ' +
f'format=(string)NV12, framerate=(fraction){framerate}/1 ! ' +
f'nvvidconv flip-method={flip_method} ! ' +
f'video/x-raw, width=(int){display_width}, height=(int){display_height}, format=(string)BGRx ! ' +
'videoconvert ! video/x-raw, format=(string)BGR ! appsink'
)
if running_on_jetson_nano():
video_capture = cv2.VideoCapture(get_jetson_gstreamer_source(), cv2.CAP_GSTREAMER)
else:
video_capture = cv2.VideoCapture(0)
path = './dataset'
folders = [f for f in glob.glob(path + '**/*', recursive=True)]
known_face_encodings = []
known_face_names = []
for f in folders:
names = f.split('/')[2]
print('encoding file : {}'.format(names))
for images_f in glob.glob(f + '**/*.jpg'):
images = face_recognition.load_image_file(images_f)
location = face_recognition.face_locations(images)
images_encoding = face_recognition.face_encodings(images, known_face_locations = location)[0]
known_face_encodings.append(images_encoding)
known_face_names.append(names)
有谁知道如何解决这个问题?