openCV online Camera [closed]
Hello.
I'm trying to make face recognition and i did it in my laptop camera . Now i have cameras connected to the DVR . So i need to connect to them by my app to see my cameras even if i connect to another Network so how can i modify my code to make "VideoCapture" get my camera ?
import cv2
import numpy as np
import os
import pickle
face_cascade=cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
recognizer=cv2.face.LBPHFaceRecognizer_create()
recognizer.read("E:\\trained.yml");
recognizer.setThreshold(90);
cap=cv2.VideoCapture(0)
font = cv2.FONT_HERSHEY_SIMPLEX
while(True):
ret,frame=cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('gray?',gray)
faces = face_cascade.detectMultiScale(frame, 1.3, 5)
for (x,y,w,h) in faces:
cv2.rectangle(frame,(x,y),(x+w,y+h),(0,255,0),2)
roi_gray = gray[y:y+h, x:x+w]
roi_color = frame[y:y+h, x:x+w]
idLablel,conf=recognizer.predict(gray[y:y+h,x:x+w])
cv2.putText(frame,str(idLablel),(x,y+h),font,4,(255,255,255));
cv2.putText(frame,str(conf),(x+w,y+h),font,4,(255,255,255));
gray=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break;
cap.release()
cv2.waitKey(0)
cv2.destroyAllWindows()
I think you might only need to change the 0 in
cap=cv2.VideoCapture(0)
The the ip of your "online camera" or to a streaming link that your camera might give you... For example, I'm using an ONVIF conformant camera and I'm getting a RTSP link from it. So, I had to usecap = cv2.VideoCapture("rtsp://user:[email protected]/stream0")
so i need to get RTSP links to run them.. this will work even network changed?
its work put ur answer to submit it