Running video library and i get the error Target VM failed to initialise

the error I got is :

terminating with uncaught exception of type NSException
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help → Troubleshooting.

this error occurs when I try to run any code that relates to using my camera which is the Facetime HD Camera (Built-in)
I’m using a Macbook Pro with touch–bar and the graphics card I’m using is Intel Iris Plus Graphics 655 1536 MB I have never used any external graphic cards and especially not anything to do with Nvidia as I’ve seen that this error could be related to that.

I downloaded the video library in processing and any codes that I run from that file gives me the same error. I have a school assignment that requires me to use it I really hope I can solve this issue as soon as possible thank you :worried:

1 Like
/**
 * Mirror 
 * by Daniel Shiffman.  
 *
 * Each pixel from the video source is drawn as a rectangle with rotation based on brightness.   
 */ 
 
import processing.video.*;


// Size of each cell in the grid
int cellSize = 20;
// Number of columns and rows in our system
int cols, rows;
// Variable for capture device
Capture video;


void setup() {
  size(640, 480);
  frameRate(30);
  cols = width / cellSize;
  rows = height / cellSize;
  colorMode(RGB, 255, 255, 255, 100);

  // This the default video input, see the GettingStartedCapture 
  // example if it creates an error
  video = new Capture(this, width, height);
  
  // Start capturing the images from the camera
  video.start();  
  
  background(0);
}


void draw() { 
  if (video.available()) {
    video.read();
    video.loadPixels();
  
    // Begin loop for columns
    for (int i = 0; i < cols; i++) {
      // Begin loop for rows
      for (int j = 0; j < rows; j++) {
      
        // Where are we, pixel-wise?
        int x = i*cellSize;
        int y = j*cellSize;
        int loc = (video.width - x - 1) + y*video.width; // Reversing x to mirror the image
      
        float r = red(video.pixels[loc]);
        float g = green(video.pixels[loc]);
        float b = blue(video.pixels[loc]);
        // Make a new color with an alpha component
        color c = color(r, g, b, 75);
      
        // Code for drawing a single rect
        // Using translate in order for rotation to work properly
        pushMatrix();
        translate(x+cellSize/2, y+cellSize/2);
        // Rotation formula based on brightness
        rotate((2 * PI * brightness(c) / 255.0));
        rectMode(CENTER);
        fill(c);
        noStroke();
        // Rects are larger than the cell for some overlap
        rect(0, 0, cellSize+6, cellSize+6);
        popMatrix();
      }
    }
  }
}

this is one of the codes in the video library posted by the processing foundation. It works on my friend’s comps but it doesn’t on mine I’m not sure what went wrong.

You’ll find some answers here Did macOS Catalina (or something) break the Video library?, I managed to get it to work last week but back to bugging again today… Look for @enigmeta answer.

1 Like

Solved the problem by manually enabling Processing to access the camera by using this method https://github.com/processing/processing-video/issues/134#issuecomment-593909771

1 Like