Posts

Face detection in Python OpenCV using smartphone Camera

Prerequisites Text Editor ( Anyone IDE  PyCharm , Visual studio code, etc.,) Installed  Python >=3.6 Install opencv-python package ( reference ) Webcam or Smart phone (phone should installed DroidCam Webcam - here  Playstore link ) Code #Sample created by chandran marimuthu on Mar-2022 import cv2 #trained datasets link: https://github.com/opencv/opencv/tree/master/data/haarcascades trainedDataset=cv2.CascadeClassifier ( 'haarcascade_frontalface_default.xml' ) ##Default camera #video=cv2.VideoCapture(0) ##Local video files #video=cv2.VideoCapture('videos/chn_video.mp4') #Web cam link video=cv2.VideoCapture ( 'http://192.168.43.157:4747/video?640x480' ) while True : success , frame = video.read () if success == True : ##To get gray scale image #gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) faces = trainedDataset.detectMultiScale ( frame ) ##Printing detected face range #print(faces) for x , y , w , h in
Recent posts