Processing camera

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.”

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.

2 Likes

@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.

Try this sketch

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 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.

2 Likes

Try this:

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);
}

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

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

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.

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.

2 Likes