# Using a part of the computer screen for computer vision

**URL:** https://discourse.processing.org/t/using-a-part-of-the-computer-screen-for-computer-vision/902
**Category:** Coding Questions
**Created:** [June 12, 2018, 6:18pm UTC](https://discourse.processing.org/t/using-a-part-of-the-computer-screen-for-computer-vision/902 "2018-06-12T18:18:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jan-jelle](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@jan-jelle](https://discourse.processing.org/u/jan-jelle)
#### Post date: [June 12, 2018, 6:18pm UTC](https://discourse.processing.org/t/using-a-part-of-the-computer-screen-for-computer-vision/902/1 "2018-06-12T18:18:48Z")

</div>

Hello everybody,

I am trying to manipulate a video input with data from a software program that is running on the PC itself. basically, i try to implement information from the PC screen into the live video screen. however, I need a way to read the pixels of the PC screen itself, and not a “sketch” or processing window.

Does anyone know if this is possible? or are there other handy ways to do this? for example by recording a part the computer screen and displaying it in processing as a live stream?

hopefully someone can give me the answer! Thanks!

---

<div class="post-metadata">

### Author: ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)
#### Post date: [June 12, 2018, 10:55pm UTC](https://discourse.processing.org/t/using-a-part-of-the-computer-screen-for-computer-vision/902/2 "2018-06-12T22:55:57Z")

</div>

This is black magic that isn’t something you can do easily and might not work at all. Here’s a starting point for you.

```auto
import java.awt.Robot;
import java.awt.Rectangle;
import java.awt.AWTException;
 
PImage screenshot;
int x, y;
 
void setup() {
  size(600, 400);
}
 
void draw() {
  screenshot();
  image(screenshot, 0, 0, width, height);
}
 
void screenshot() {
  try {
    Robot robot = new Robot();
    screenshot = new PImage(robot.createScreenCapture(new Rectangle(0, 0, displayWidth, displayHeight)));
  } 
  catch (AWTException e) {
  }
}

```

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [June 14, 2018, 12:01am UTC](https://discourse.processing.org/t/using-a-part-of-the-computer-screen-for-computer-vision/902/3 "2018-06-14T00:01:25Z")

</div>

> [@jan-jelle](#):
>
> recording a part the computer screen and displaying it in processing as a live stream

Do you need the live stream? If not, then check any desktop capture app. You can save what you see in your desktop’s scree as a movie and process it afterwards.

Kf
