Process crashes Java

I’m trying to set up a facial recognition system for my art degree - where I want it to print off peoples faces each time they enter the gallery space. The code I’ve used, from a couple of guides, is included below - and is apparently a basic facial recognition script. Unfortunately, I get the following error - can anyone help?

“2021-10-26 11:34:32.472 java[2098:69034] Warning: Expected min height of view: (<NSButton: 0x7fb107884470>) to be less than or equal to 30 but got a height of 32.000000. This error will be logged once per view in violation.
2021-10-26 11:34:32.475 java[2098:69034] Warning: Expected min height of view: (<NSButton: 0x7fb107855dd0>) to be less than or equal to 30 but got a height of 32.000000. This error will be logged once per view in violation.
Processing video library using GStreamer 1.16.2
OpenCV for Processing 0.5.4 by Greg Borenstein http://gregborenstein.com
Using Java OpenCV 2.4.5.0
Load cascade from: /Users/richardmead/Documents/Processing/libraries/opencv_processing/library/cascade-files/haarcascade_frontalface_alt.xml
Cascade loaded: haarcascade_frontalface_alt.xml
BaseSrc: [avfvideosrc0] : Device video access permission has just been denied
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help → Troubleshooting.”

import gab.opencv.*;
import processing.video.*;
import java.awt.*;

Capture video;
OpenCV opencv;

void setup() {
  size(640, 480);
  video = new Capture(this, 640/2, 480/2);
  opencv = new OpenCV(this, 640/2, 480/2);
  opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);  

  video.start();
}

void draw() {
  scale(2);
  opencv.loadImage(video);

  image(video, 0, 0 );

  noFill();
  stroke(0, 255, 0);
  strokeWeight(3);
  Rectangle[] faces = opencv.detect();
  
  for (int i = 0; i < faces.length; i++) {
    rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
  }
}

void captureEvent(Capture c) {
  c.read();
}

Hello,

The code provided works here with:

  • Processing 3.5.4
  • Logitech C922
  • W10

It thinks the corner of a piece of furniture is a face!

With Processing 4.0b2:

Try a search for this if you are using a Mac::
“BaseSrc: [avfvideosrc0] : Device video access permission has just been denied”

:)

I’m using 3.5.4 - I’m not technically minded enough to use the beta haha!

Ahh - any idea what to change to do the inbuilt camera on a Mac? I’m so confused!

Hello,

Resources here:
https://processing.org/

Video is in the libraries section:
https://processing.org/reference/libraries/video/index.html

Example of how to detect cameras:

This would be my “Logitech QuickCam Pro 9000”:

cam = new Capture(this, cameras[1]);

:)

1 Like

Hey, thanks for the reply! This is insane for my first coding thing - especially since I failed maths at High School!

SO, for the below code, where would I add the [0] for the Facetime built in cam? I’m going mad haha

import gab.opencv.*;
import processing.video.*;
import java.awt.*;

Capture video;
OpenCV opencv;

void setup() {
  size(640, 480);
  video = new Capture(this, 640/2, 480/2);
  opencv = new OpenCV(this, 640/2, 480/2);
  opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);  

  video.start();
}

void draw() {
  scale(2);
  opencv.loadImage(video);

  image(video, 0, 0 );

  noFill();
  stroke(0, 255, 0);
  strokeWeight(3);
  Rectangle[] faces = opencv.detect();
  
  for (int i = 0; i < faces.length; i++) {
    rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
  }
}

void captureEvent(Capture c) {
  c.read();
}

When the madness subsides… go to to the link I provided and explore.

Each of these lines has a link with details:

:)