Currently I am following the lessons taught by Paul McWhorter on his YouTube channel. But until the lesson related to face recognition system (Lesson 43), I failed to obtain the results as his. Where he able to have 10-15 fps and the system able to run continuously without any issues, while mine keep crashing as soon as I run the program.
Currently, I have no idea, is it due to different operating system version or the device (hardware) itself that cause this problem. Because, my system setup differs from the setup that Paul have in his video.
Several things on my system setup that I acknowledge to be different from the tutorial video;
- Type of device - Nvidia Jetson Nano 2GB
- Version of Jetpack - 4.5.1 [L4T 32.5.1]
- Camera sensor - IMX219-77
- Version of face recognition library âd-libâ - 19.21
- Micro SD card storage capacity - 64 GB (SanDisk Ultra)
- Swapfile (have 2 partition) - P=-1 (4.3GB) and P=-2 (6.4GB)
This is my codes, which is totally based on the tutorial
import face_recognition
import cv2
import os
import pickle
import time
print(cv2.version)fpsReport=0 #Declaring the variable
scaleFactor=0.4Encodings=[ ]
Names=[ ]with open(âtrain.pklâ,ârbâ)as f:
Names=pickle.load(f)
Encodings=pickle.load(f)font=cv2.FONT_HERSHEY_SIMPLEX
dispW=320
dispH=240
flip=2
camSet=ânvarguscamerasrc ! video/x-raw(memory:NVMM), width=3264, height=2464, format=NV12, framerate=21/1 ! nvvidconv flip-method=â+str(flip)+â ! video/x-raw, width=â+str(dispW)+â, height=â+str(dispH)+â, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsinkâ
cam=cv2.VideoCapture(camSet) #Variable for camera usagetimeStamp=time.time() #present time
while (True):
_,frame=cam.read()frameSmall=cv2.resize(frame,(0,0),fx=scaleFactor,fy=scaleFactor) frameRGB=cv2.cvtColor(frameSmall,cv2.COLOR_BGR2RGB) facePositions=face_recognition.face_locations(frameRGB,model='cnn') allEncodings=face_recognition.face_encodings(frameRGB,facePositions) for (top,right,bottom,left),face_encoding in zip(facePositions,allEncodings): name='Unknown Person' matches=face_recognition.compare_faces(Encodings,face_encoding) if True in matches: first_match_index=matches.index(True) #index for the first match happen name=Names[first_match_index] top=int(top/scaleFactor) right=int(right/scaleFactor) left=int(left/scaleFactor) bottom=int(bottom/scaleFactor) cv2.rectangle(frame,(left,top),(right,bottom),(0,0,255),2) cv2.putText(frame,name,(left,top-6),font,.75,(0,0,255),2) dt=time.time()-timeStamp fps=1/dt fpsReport=.9*fpsReport+.1*fps #print('FPS = {:.2f}'.format(fpsReport)) timeStamp=time.time() cv2.rectangle(frame,(0,0),(100,40),(0,0,255),-1) cv2.putText(frame,str(round(fpsReport,1)) + 'fps',(0,25),font,.75,(0,255,255,2)) cv2.imshow('piCam',frame) cv2.moveWindow('piCam',0,0) if cv2.waitKey(1)==ord('q'): break
cam.release()
cv2.destroyAllWindows()
The error are as shown below;
mfaiz269@mfaiz269-desktop:~/Desktop/pyPro$ /usr/bin/python3 /home/mfaiz269/Desktop/pyPro/FaceRecognizer/FaceRecognize-6liveFPS.py
4.1.1
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connectedâŠ
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 3264 x 2464 FR = 21.000000 fps Duration = 47619048 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;GST_ARGUS: 3264 x 1848 FR = 28.000001 fps Duration = 35714284 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 1920 x 1080 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 1640 x 1232 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 1280 x 720 FR = 59.999999 fps Duration = 16666667 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 1280 x 720 FR = 120.000005 fps Duration = 8333333 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: Running with following settings:
Camera index = 0
Camera mode = 0
Output Stream W = 3264 H = 2464
seconds to Run = 0
Frame Rate = 21.000000
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (933) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
CONSUMER: Done Success
Traceback (most recent call last):
File â/home/mfaiz269/Desktop/pyPro/FaceRecognizer/FaceRecognize-6liveFPS.pyâ, line 34, in
frameSmall=cv2.resize(frame,(0,0),fx=scaleFactor,fy=scaleFactor) #change the frame dimensions
cv2.error: OpenCV(4.1.1) /home/nvidia/host/build_opencv/nv_opencv/modules/imgproc/src/resize.cpp:3720: error: (-215:Assertion failed) !ssize.empty() in function âresizeâ(Argus) Error Timeout: (propagating from src/rpc/socket/client/ClientSocketManager.cpp, function send(), line 137)
(Argus) Error Timeout: (propagating from src/rpc/socket/client/SocketClientDispatch.cpp, function dispatch(), line 87)
GST_ARGUS: Cleaning up
(Argus) Error Timeout: (propagating from src/rpc/socket/client/ClientSocketManager.cpp, function send(), line 137)
(Argus) Error Timeout: (propagating from src/rpc/socket/client/SocketClientDispatch.cpp, function dispatch(), line 87)
GST_ARGUS: Done Success
(Argus) Error Timeout: (propagating from src/rpc/socket/client/ClientSocketManager.cpp, function send(), line 137)
(Argus) Error Timeout: (propagating from src/rpc/socket/client/SocketClientDispatch.cpp, function dispatch(), line 87)
(Argus) Error Timeout: (propagating from src/rpc/socket/client/ClientSocketManager.cpp, function send(), line 137)
(Argus) Error Timeout: (propagating from src/rpc/socket/client/SocketClientDispatch.cpp, function dispatch(), line 87)
(Argus) Error InvalidState: Argus client is exiting with 4 outstanding client threads (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadCore(), line 357)
I am sorry for the long descriptions of my problem in this post. I am very new to this field of study, thanks in advance to anybody that willing to help me to solve this problem, and greetings from Malaysia =D