# How to declare an instance when no face is detected in \[deep-vision-processing library\]?

**URL:** <https://discourse.processing.org/t/how-to-declare-an-instance-when-no-face-is-detected-in-deep-vision-processing-library/33336>\
**Category:** Libraries\
**Created:** [November 5, 2021, 2:29pm UTC](https://discourse.processing.org/t/how-to-declare-an-instance-when-no-face-is-detected-in-deep-vision-processing-library/33336 "2021-11-05T14:29:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yatish001](https://avatars.discourse-cdn.com/v4/letter/y/e0b2c6/32.png) [@Yatish001](https://discourse.processing.org/u/Yatish001)\
**Post date:** [November 5, 2021, 2:29pm UTC](https://discourse.processing.org/t/how-to-declare-an-instance-when-no-face-is-detected-in-deep-vision-processing-library/33336/1 "2021-11-05T14:29:49Z")

</div>

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

```auto
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:

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

```
