On screen detections

Hello so I was wondering if there was anyway to do read what is on my pc screen, with face recognition. This is what I have gotten so far. But I want instead of it reading a webcam to read my pc screen.

import cv2
import numpy as np

faceDetect = cv2.CascadeClassifier(‘haarcascade_frontalface_default.xml’);
cam = cv2.VideoCapture(0);

while(True):
ret, img = cam.read();
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = faceDetect.detectMultiScale(gray, 1.3, 5);
for(x, y, w, h) in faces:
cv2.rectangle(img, (x, y), (x+w, y+h), (0, 0, 255), 2)
cv2.imshow(“Face”, img);
if(cv2.waitKey(1) == ord(‘q’)):
break;
cam.release()
cv2.destroyAllWindows()

Hi @gamerbutterbean

OpenCV doesn’t provide a way to capture the screen. You should get the image somehow (there may be plenty of libraries to doing so), and then process it with OpenCV, as you already do.

May be other users can provide you some libraries they know.

How would you suggest I screenshot the screen and check the image?

to take a screenshot? use a library for that. there are plenty for python, if you look for them.

OpenCV doesn’t have to come with all the things someone would want to do. and it doesn’t come with screenshotting abilities.

as has been stated.

No how would I change my code to check the screenshot

make a suggestion first. try it yourself.

you are here to learn, whether you want to or not :slight_smile: