简体   繁体   English

在python中使用多个摄像头进行面部识别时,有没有办法确定哪个摄像头在直播stream中识别出一个人

[英]Is there a way to determine which camera has recognized a person in live stream when using multiple cameras for facial recognition in python

This is a facial recognition program and is programmed with python and opencv with database insertion model through MySQL.这是一个面部识别程序,用 python 和 opencv 编程,数据库插入 model 到 MySQL。

I have one query in the program.我在程序中有一个查询。 In the first part, there is real-time data insertion in a table when the camera recognizes a person through the pictures given in which a date, time, name and ID stamp is inserted in the database.第一部分,当相机通过给定的图片识别人时,在表格中实时插入数据,在数据库中插入日期、时间、姓名和 ID 戳。 I also want to insert the camera name which has recognized the person to know the particular location also.我还想插入已识别人的相机名称,以了解特定位置。

    face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
recognizer = cv2.face.LBPHFaceRecognizer_create()

recognizer.read("trainner.yml")

labels = {"person_name": 1}
with open("labels.pickle", 'rb') as f:
    og_labels = pickle.load(f)
    labels = {v: k for k, v in og_labels.items()}


cap = cv2.VideoCapture(0)
#cap1 = cv2.VideoCapture('rtsp://admin:umerkhan261@192.168.226.201')

while True:
     ret, frame = cap.read()
     # ret, frame1 = cap1.read()
     gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    #gray1 = cv2.cvtColor(frame1, cv2.COLOR_BGR2GRAY)
     faces = face_cascade.detectMultiScale(gray, scaleFactor=1.5, minNeighbors=5)
     now = datetime.now()
     print("Today's date: ", str(now))
     for (x, y, w, h) in faces:
        roi_gray = gray[y:y + h, x:x + w]
         #   roi_gray1 = gray1[y:y + h, x:x + w]
        roi_color = frame[y:y + h, x:x + w]


        #  roi_color1 = frame1[y:y + h, x:x + w]

            # deep Learned Model for recognizing the person in live stream

        id_, conf = recognizer.predict(roi_gray)
 #      id_, conf = recognizer.predict(roi_gray1)
        if 45 <= conf <= 85:
           print(id_)
           print(labels[id_])
           font = cv2.FONT_HERSHEY_SIMPLEX
           name = labels[id_]
           new = datetime.now()
           tString = new.strftime('%H:%M:%S')
           dtString = new.strftime('%D:%m')

I figured out a way to solve the problem.我想出了解决问题的方法。 I made the frame reading from my webcam a function with a variable named cam1, then I made another python file copied the whole program and named that variable to cam2.我用一个名为 cam1 的变量从我的网络摄像头读取帧 function,然后我制作了另一个 python 文件,复制了整个程序并将该变量命名为 cam2。 I made another file calling those functions on the main file and by the multi threading function I called them simultaneously.我制作了另一个文件,在主文件上调用这些函数,并通过多线程 function 我同时调用了它们。 It turned out to be successful结果成功了

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

相关问题 使用python的人脸识别软件 - Facial recognition Software using python 我正在开发一个面部识别和考勤系统,该系统将姓名和时间写入 CSV 文件,但同一个人被多次记录 - I am working on a facial recognition and attendance system which writes the name and time in a CSV file, but the same person is logged multiple times OpenCV / Python:用于实时面部识别的多线程 - OpenCV / Python : multi-threading for live facial recognition 有没有办法在 AGI python 中使用 stream 实时音频进行语音识别? - Is there any way to stream live audio for speech recognition in AGI python? 如何使用Python从多个IP摄像机流式传输视频 - How to stream videos from multiple IP cameras using Python 调整图像大小时使用OpenCV进行的面部识别不正确 - Inaccurate facial recognition using OpenCV when the image is resized 使用 React Native 进行面部识别 Python - Facial Recognition Python with React Native 使用Android IP摄像机(python)在openCv中进行实时流 - Live stream in openCv using Android IP Camera (python) 标签中的直播相机使用Tkinter python2 - Live Stream Camera in Label Using Tkinter python2 从使用 python 通过 usb 连接的摄像机获取实时 Stream - Get Live Stream from a Camera connected via usb using python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM