Hello Adam,
i hope you can help me again, and i have 2 questions for you. sorry dude i know i did ask you a lot of questions.
The idea is to read rtsp/rtmp stream frame by frame, transferring frames to np.ndarray using OpenCV, then processing ndarray with face_recognition.
Here's a demo that reads a single frame from a rtsp stream.
import cv2
import PIL.Image
cap = cv2.VideoCapture(rtsp_addr)
if cap.isOpened():
try:
ret, frame = cap.read()
fr_frame = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
# fr_frame is what we want here.
finally:
cap.release()
Not Working bro. if you for me example rtmp capture face recognition fetch into know photos.
@windforce7 did U get this to work. Also really want this awesome code to work with rtsp streams.
Could it be done thru ffmpeg?
If so, how?
Thanks in advance!
@htilly Our rtsp source was a Hikvision ipc camera and we managed to read output stream. The code above worked and was good enough for me, though I don't know what exactly was @cengizakcan 's problem. You may have to solve the following issues on your own:
try:
while cap.isOpen():
ret, frame = cap.read()
# blah
I can't tell you whether this would process all frames without missing any one of them. If the inside part ran too slow, it might not catch up with coming frames. In my project, we only need to take a few shots. So I didn't do much further digging.
this is a good demo of face_recognition, the link is as flow:
https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam_faster.py
edit one line of the code :
video_capture = cv2.VideoCapture(0)
to
video_capture = cv2.VideoCapture('rtsp_url')
then all is done.
below is my test code:
https://github.com/shi-hao/face_recognition_demo/blob/master/face_recog_rtsp.py
this is a good demo of face_recognition, the link is as flow:
https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam_faster.py
edit one line of the code :
video_capture = cv2.VideoCapture(0)
to
video_capture = cv2.VideoCapture('rtsp_url')
then all is done.
below is my test code:
https://github.com/shi-hao/face_recognition_demo/blob/master/face_recog_rtsp.py
I'm trying to do exactly what you did in this code, I used yours as a base, however streaming closed and got an encoding error I made some changes, and streaming no longer closes yet it freezes, when you use it works normally?
this is a good demo of face_recognition, the link is as flow:
https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam_faster.py
edit one line of the code :
video_capture = cv2.VideoCapture(0)
to
video_capture = cv2.VideoCapture('rtsp_url')
then all is done.
below is my test code:
https://github.com/shi-hao/face_recognition_demo/blob/master/face_recog_rtsp.pyI'm trying to do exactly what you did in this code, I used yours as a base, however streaming closed and got an encoding error I made some changes, and streaming no longer closes yet it freezes, when you use it works normally?
please use the demo in face_recognition
this is a good demo of face_recognition, the link is as flow:
https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam_faster.py
edit one line of the code :
video_capture = cv2.VideoCapture(0)
to
video_capture = cv2.VideoCapture('rtsp_url')
then all is done.
below is my test code:
https://github.com/shi-hao/face_recognition_demo/blob/master/face_recog_rtsp.pyI'm trying to do exactly what you did in this code, I used yours as a base, however streaming closed and got an encoding error I made some changes, and streaming no longer closes yet it freezes, when you use it works normally?
please use the demo in face_recognition project, this is the link
https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam_faster.py
edit one line of the code :
video_capture = cv2.VideoCapture(0)
to
video_capture = cv2.VideoCapture('rtsp_url')
then all is done.
this is a good demo of face_recognition, the link is as flow:
https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam_faster.py
edit one line of the code :
video_capture = cv2.VideoCapture(0)
to
video_capture = cv2.VideoCapture('rtsp_url')
then all is done.
below is my test code:
https://github.com/shi-hao/face_recognition_demo/blob/master/face_recog_rtsp.pyI'm trying to do exactly what you did in this code, I used yours as a base, however streaming closed and got an encoding error I made some changes, and streaming no longer closes yet it freezes, when you use it works normally?
please use the demo in face_recognition
this is a good demo of face_recognition, the link is as flow:
https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam_faster.py
edit one line of the code :
video_capture = cv2.VideoCapture(0)
to
video_capture = cv2.VideoCapture('rtsp_url')
then all is done.
below is my test code:
https://github.com/shi-hao/face_recognition_demo/blob/master/face_recog_rtsp.pyI'm trying to do exactly what you did in this code, I used yours as a base, however streaming closed and got an encoding error I made some changes, and streaming no longer closes yet it freezes, when you use it works normally?
please use the demo in face_recognition project, this is the link
https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam_faster.py
edit one line of the code :
video_capture = cv2.VideoCapture(0)
to
video_capture = cv2.VideoCapture('rtsp_url')
then all is done.
I made the change but the streaming keeps crashing.
this is a good demo of face_recognition, the link is as flow:
https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam_faster.py
edit one line of the code :
video_capture = cv2.VideoCapture(0)
to
video_capture = cv2.VideoCapture('rtsp_url')
then all is done.
below is my test code:
https://github.com/shi-hao/face_recognition_demo/blob/master/face_recog_rtsp.pyI'm trying to do exactly what you did in this code, I used yours as a base, however streaming closed and got an encoding error I made some changes, and streaming no longer closes yet it freezes, when you use it works normally?
please use the demo in face_recognition
this is a good demo of face_recognition, the link is as flow:
https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam_faster.py
edit one line of the code :
video_capture = cv2.VideoCapture(0)
to
video_capture = cv2.VideoCapture('rtsp_url')
then all is done.
below is my test code:
https://github.com/shi-hao/face_recognition_demo/blob/master/face_recog_rtsp.pyI'm trying to do exactly what you did in this code, I used yours as a base, however streaming closed and got an encoding error I made some changes, and streaming no longer closes yet it freezes, when you use it works normally?
please use the demo in face_recognition project, this is the link
https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam_faster.py
edit one line of the code :
video_capture = cv2.VideoCapture(0)
to
video_capture = cv2.VideoCapture('rtsp_url')
then all is done.I made the change but the streaming keeps crashing.
debug
(1)face_recognition is ok?
(2)rtsp stream is ok?
(3)combine them, then is ok?
Most helpful comment
The idea is to read rtsp/rtmp stream frame by frame, transferring frames to np.ndarray using OpenCV, then processing ndarray with face_recognition.
Here's a demo that reads a single frame from a rtsp stream.