detectFaces(app, facedetector) {
        return function() {
            // Apply algorithm from app settings
            const algorithm = app.algorithm || faceapi.TinyFaceDetectorOptions;
            

            // Get the canvas ready with the app options
            const canvas = facedetector.prepareCanva(app.options);


            // Match the canva size with the video
            const displaySize = {
                width: facedetector.media.width,
                height: facedetector.media.height
            };
            faceapi.matchDimensions(canvas, displaySize);

            // Run the face detection algorithm every 100ms 
            facedetector.runningEvent = setInterval(async () => {
                
                

                // Detect all the faces present in the stream with Landmarks, Age and Gender, and Facial Expressions
                const detections = await faceapi.detectAllFaces(facedetector.media, new algorithm()).withFaceLandmarks().withFaceDescriptors().withAgeAndGender().withFaceExpressions();

                // resize the detections to fit in the canva
                const resizedDetections = faceapi.resizeResults(detections, displaySize);
                
                // expose the detections to the app
                facedetector.app = app;
                facedetector.app.detections = resizedDetections;
                facedetector.app.canvas = canvas;
                
                
                // call the defined app method
                app.method(facedetector);
                
            }, 100); // end interval
        } // end callback 
    }
/* 
     * Method that detects faces throughout the life cycle of the video stream
     * @app: object definition of the app and its options
     * @facedetector: FaceDetector object
     *
     */
Method that detects faces throughout the life cycle of the video stream
@app: object definition of the app and its options
@facedetector: FaceDetector object
Method that detects faces throughout the life cycle of the video stream @app : object definition of the app and its options @facedetector : FaceDetector object
detectFaces(app, facedetector) {
        return function() {
            const algorithm = app.algorithm || faceapi.TinyFaceDetectorOptions;
            const canvas = facedetector.prepareCanva(app.options);
            const displaySize = {
                width: facedetector.media.width,
                height: facedetector.media.height
            };
            faceapi.matchDimensions(canvas, displaySize);
            facedetector.runningEvent = setInterval(async () => {
                const detections = await faceapi.detectAllFaces(facedetector.media, new algorithm()).withFaceLandmarks().withFaceDescriptors().withAgeAndGender().withFaceExpressions();
                const resizedDetections = faceapi.resizeResults(detections, displaySize);
                facedetector.app = app;
                facedetector.app.detections = resizedDetections;
                facedetector.app.canvas = canvas;
                app.method(facedetector);
            }, 100); 
        } 
    }
detectFaces ( app , facedetector ) { return function ( ) { const algorithm = app . algorithm || faceapi . TinyFaceDetectorOptions ; const canvas = facedetector . prepareCanva ( app . options ) ; const displaySize = { width : facedetector . media . width , height : facedetector . media . height } ; faceapi . matchDimensions ( canvas , displaySize ) ; facedetector . runningEvent = setInterval ( async ( ) => { const detections = await faceapi . detectAllFaces ( facedetector . media , new algorithm ( ) ) . withFaceLandmarks ( ) . withFaceDescriptors ( ) . withAgeAndGender ( ) . withFaceExpressions ( ) ; const resizedDetections = faceapi . resizeResults ( detections , displaySize ) ; facedetector . app = app ; facedetector . app . detections = resizedDetections ; facedetector . app . canvas = canvas ; app . method ( facedetector ) ; } , 100 ) ; } }
Method that detects faces throughout the life cycle of the video stream
 @app: object definition of the app and its options
 @facedetector: FaceDetector object
Method that detects faces throughout the life cycle of the video stream @app : object definition of the app and its options @facedetector : FaceDetector object
// Apply algorithm from app settings // Get the canvas ready with the app options // Match the canva size with the video // Run the face detection algorithm every 100ms  // Detect all the faces present in the stream with Landmarks, Age and Gender, and Facial Expressions // resize the detections to fit in the canva // expose the detections to the app // call the defined app method // end interval // end callback 