     
     override func viewDidDisappear(_ animated: Bool) {
         self.captureSession.stopRunning()
+        if(detectionActive) {
+            detectionActive = false
+            cameraButton.animatePress(detectionActive: detectionActive)
+        }
     }
     
     

    }
    
    func setupCameraPreview() {
        self.previewLayer = AVCaptureVideoPreviewLayer(session: self.captureSession)
        self.previewLayer?.frame = view.layer.frame
        self.previewLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill
        self.previewHolder.layer.masksToBounds = true
        self.previewHolder.layer.addSublayer(self.previewLayer!)
        self.captureSession.sessionPreset = AVCaptureSessionPresetPhoto
//        self.captureSession.sessionPreset = AVCaptureSessionPresetHigh
        self.captureSession.startRunning()
    }
    

        self.navigationController?.delegate = self
        
        self.videoDataOutputQueue = DispatchQueue(label: "VideoDataOutputQueue")
        
        updateCameraSelection()
        setupVideoProcessing()
