I want to play one video when no face is detected and play another video when a face is detected using Deep Vision Library for processing. I am using the FaceDetectorHaarWebcam code from the examples. However, I am not able to declare thr instance when no face is detected, I tried using
if (detections==null){
image(video1,0,0);
rect(0,0,100,100);
}
But this doesn’t work. In the given example, for loop is used to draw rectangle around faces for the instances when a face is detected. But how to declare the instance when no face is detected is not clear to me.
Example Code for reference:
import ch.bildspur.vision.*;
import ch.bildspur.vision.result.*;
import processing.video.Capture;
Capture cam;
DeepVision vision;
CascadeClassifierNetwork network;
ResultList<ObjectDetectionResult> detections;
public void setup() {
size(640, 480, FX2D);
colorMode(HSB, 360, 100, 100);
println("creating network...");
vision = new DeepVision(this);
network = vision.createCascadeFrontalFace();
println("loading model...");
network.setup();
println("setup camera...");
String[] cams = Capture.list();
cam = new Capture(this, cams[0]);
cam.start();
}
public void draw() {
background(55);
if (cam.available()) {
cam.read();
}
image(cam, 0, 0);
detections = network.run(cam);
noFill();
strokeWeight(2f);
stroke(200, 80, 100);
for (ObjectDetectionResult detection : detections) {
rect(detection.getX(), detection.getY(), detection.getWidth(), detection.getHeight());
}
surface.setTitle("Face Recognition Test - FPS: " + Math.round(frameRate));
}