# On screen detections

**URL:** <https://forum.opencv.org/t/on-screen-detections/7733>\
**Category:** Python\
**Tags:** programming\
**Created:** [February 27, 2022, 6:20am UTC](https://forum.opencv.org/t/on-screen-detections/7733 "2022-02-27T06:20:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gamerbutterbean](https://avatars.discourse-cdn.com/v4/letter/g/b77776/32.png) [@gamerbutterbean](https://forum.opencv.org/u/gamerbutterbean)\
**Post date:** [February 27, 2022, 6:20am UTC](https://forum.opencv.org/t/on-screen-detections/7733/1 "2022-02-27T06:20:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Alejandro\_Silvestri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/alejandro_silvestri/32/357_2.png) [@Alejandro\_Silvestri](https://forum.opencv.org/u/Alejandro_Silvestri)\
**Post date:** [February 27, 2022, 1:20pm UTC](https://forum.opencv.org/t/on-screen-detections/7733/2 "2022-02-27T13:20:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gamerbutterbean](https://avatars.discourse-cdn.com/v4/letter/g/b77776/32.png) [@gamerbutterbean](https://forum.opencv.org/u/gamerbutterbean)\
**Post date:** [February 27, 2022, 11:34pm UTC](https://forum.opencv.org/t/on-screen-detections/7733/3 "2022-02-27T23:34:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 28, 2022, 12:48am UTC](https://forum.opencv.org/t/on-screen-detections/7733/4 "2022-02-28T00:48:49Z")

</div>

to take a screenshot? use a library for that. there are plenty for python, [if you look for them](https://lmgtfy.app/?q=python+screenshot).

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.

---

<div class="post-metadata">

**Author:** ![gamerbutterbean](https://avatars.discourse-cdn.com/v4/letter/g/b77776/32.png) [@gamerbutterbean](https://forum.opencv.org/u/gamerbutterbean)\
**Post date:** [February 28, 2022, 3:27am UTC](https://forum.opencv.org/t/on-screen-detections/7733/5 "2022-02-28T03:27:32Z")

</div>

No how would I change my code to check the screenshot

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 28, 2022, 11:53am UTC](https://forum.opencv.org/t/on-screen-detections/7733/6 "2022-02-28T11:53:32Z")

</div>

make a suggestion first. try it yourself.

you are here to learn, whether you want to or not 🙂
