Hi so my code seems to give me NullPointerException when i get to the 86th line. Im not sure why could you help.
import gab.opencv.*;
import processing.video.*;
import java.awt.*;
int maxImages = 61; //61 Frames
int imageIndex = 0;  
PImage [] imgArray = new PImage[maxImages]; //image array
PImage background;
PImage imgCoral;
color colCoral;
Capture video;
OpenCV opencv;
void setup() {
size(960, 540);
colorMode (HSB);
   
  background=loadImage ("sea1.png");
  imgCoral = loadImage ("coral1.png");
        
  video = new Capture(this, 640, 480);
  opencv = new OpenCV(this, 640, 480);
  opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE); 
  
  video.start();
     for (int i=0;i<imgArray.length; i++){ //Setting up Array (randomiser)
      imgArray[i]=loadImage("clown" + i +".png");
    }
   
  frameRate(60);
  
}
void draw() {
  scale(1);
  opencv.loadImage(video);
  background (background);
  image(imgCoral,0,0);
   
  noFill();
  stroke(0, 255, 0);
  strokeWeight(3);
  Rectangle[] faces = opencv.detect();
  println(faces.length);
  for (int i = 0; i < faces.length; i++) {
    println(faces[i].x + "," + faces[i].y);
    image(imgArray[imageIndex],faces[i].x,faces[i].y,faces[i].width,faces[i].height); //Calling Array Image
        if (faces[i].x>=180 && faces[i].y<=100){
         noTint();
         image(imgArray[imageIndex],faces[i].x,faces[i].y, faces[i].width,faces[i].height);
         imageIndex = (imageIndex+1)%imgArray.length;
         tint(0,153,204,100);
         image(imgCoral,0,0);
         } 
         else {
           noTint();
           image(imgCoral,0,0);
           
         }
    }
    
    imageIndex=(imageIndex+1)%imgArray.length;
  }
void captureEvent(Capture c) {
  c.read();
}
 mmm in order to avoid de error, maybe you can add :
 mmm in order to avoid de error, maybe you can add :
 .
.