# Processing camera

**URL:** <https://discourse.processing.org/t/processing-camera/38415>\
**Category:** Libraries\
**Created:** [August 19, 2022, 8:05am UTC](https://discourse.processing.org/t/processing-camera/38415 "2022-08-19T08:05:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![madtolla](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@madtolla](https://discourse.processing.org/u/madtolla)\
**Post date:** [August 19, 2022, 8:05am UTC](https://discourse.processing.org/t/processing-camera/38415/1 "2022-08-19T08:05:41Z")

</div>

Hello guys  
I’m trying to run the code below for 2 days to open the camera by using processing and literally tried every single method but I didn’t solve it, plz need your help

import processing.video.\*;

Capture video;

void setup()  
{  
size(550,550);

video = new Capture(this,1080,720,30);  
video.start();  
}

void draw()  
{  
video.read();  
background(0);  
tint(0);  
image(video, 0,0);  
}

\*\*below is the error

“Could not run the sketch (Target VM failed to initialize).  
For more information, read revisions.txt and Help? Troubleshooting.”

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [August 19, 2022, 12:38pm UTC](https://discourse.processing.org/t/processing-camera/38415/2 "2022-08-19T12:38:13Z")

</div>

The first thing to try are the video example sketches that come with Processing. If they work then there is something wrong with your code, if not then the problem lies somewhere else.

---

<div class="post-metadata">

**Author:** ![madtolla](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@madtolla](https://discourse.processing.org/u/madtolla)\
**Post date:** [August 20, 2022, 11:37am UTC](https://discourse.processing.org/t/processing-camera/38415/3 "2022-08-20T11:37:49Z")

</div>

@quark I tried the example sketches and unfortunately, I got the same problem every single time, while my friend’s laptop works perfectly from the first try  
really I need your help guys.

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [August 20, 2022, 12:49pm UTC](https://discourse.processing.org/t/processing-camera/38415/4 "2022-08-20T12:49:28Z")

</div>

Try this sketch

```auto
void setup() {
  size(550,550);
}

void draw() {
  background(0);
}

```

Do you get the same error? If you do then it is nothing to do with the video library.

Not my specialist area but I did a [google search](https://www.google.com/search?client=firefox-b-d&q=Could+not+run+the+sketch+%28Target+VM+failed+to+initialize%29) and it provided a number of links that might help.

If you need further help on this topic it would be useful to know what OS and version of Processing you are using.

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [August 20, 2022, 3:09pm UTC](https://discourse.processing.org/t/processing-camera/38415/5 "2022-08-20T15:09:29Z")

</div>

> [@madtolla](#):
>
> import processing.video.\*;
> 
> Capture video;
> 
> void setup()  
> {  
> size(550,550);
> 
> video = new Capture(this,1080,720,30);  
> video.start();  
> }
> 
> void draw()  
> {  
> video.read();  
> background(0);  
> tint(0);  
> image(video, 0,0);  
> }

Try this:

```auto
import processing.video.*;

Capture video;

void setup() {
  size(550, 550);
  String[] cameras = Capture.list();
  video = new Capture(this, cameras[0]);
  video.start();
}

void draw() {
  video.read();
  image(video, 0, 0);
}

```

---

<div class="post-metadata">

**Author:** ![madtolla](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@madtolla](https://discourse.processing.org/u/madtolla)\
**Post date:** [August 21, 2022, 9:18am UTC](https://discourse.processing.org/t/processing-camera/38415/6 "2022-08-21T09:18:23Z")

</div>

@quark thank you so much for your time bro but the problem is deeper than I think  
anyway thanks

---

<div class="post-metadata">

**Author:** ![madtolla](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@madtolla](https://discourse.processing.org/u/madtolla)\
**Post date:** [August 21, 2022, 9:21am UTC](https://discourse.processing.org/t/processing-camera/38415/7 "2022-08-21T09:21:25Z")

</div>

@svan same error, do you think that is the issue from bios maybe! 😥

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [August 21, 2022, 9:36am UTC](https://discourse.processing.org/t/processing-camera/38415/8 "2022-08-21T09:36:13Z")

</div>

Most unlikely to be BIOS since that would affect many applications on your computer. The problem appears to be that the JVM (Java Virtual Machine) can’t initialize the Processing sketch.

In all problems like this you need to be methodical in your approach to the problem.

As I suggested before start with an empty sketch (see below) until you get the sketch to launch then you can try and add functionality such as video. i.e.

```auto
void setup() {
  size(550,550);
}

void draw() {
  background(0);
}

```

Does this cause the same error.  
If the answer is yes then try some or all of the following.

1. Reinstall Processing and try again
2. Update Java on your system if needed.
3. Update your graphics card software.

Number 3 might seem strange but in the past I have found this can help because most applications will try to open a window. when it is launched.

As I said previously this is not my specialist area.
