Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 2088

openCV online Camera

$
0
0
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()

Viewing all articles
Browse latest Browse all 2088

Trending Articles