Importing face-api

Importing face-api

by Omar Sehlouli -
Number of replies: 4

I'm trying to import face-api.js to my plugin

I've tried to call the js from attempt.php

by that line $PAGE->requires->js('/mod/quiz/accessrule/plugin/amd/src/face-api.js');

It loaded successfully , but when I tried to call it from another js

using those lines

Promise.all([
                    faceapi.nets.tinyFaceDetector.loadFromUri('./models'),
                    faceapi.nets.faceLandmark68Net.loadFromUri('./models'),
                    faceapi.nets.faceRecognitionNet.loadFromUri('./models'),
                    faceapi.nets.ssdMobilenetv1.loadFromUri('./models')
                  ]).then(start)


it says that faceapi is not defined
my problem essentially is how to made faceapi defined or simply how to import face-api.js globally in the attempt  page



Average of ratings: -
In reply to Omar Sehlouli

Re: Importing face-api

by Omar Sehlouli -
I fixed it by changing the line to $PAGE->requires->js("/mod/quiz/accessrule/plugin/amd/build/face-api.min.js", true);
Average of ratings: Useful (2)
In reply to Omar Sehlouli

Re: Importing face-api

by MIGUEL TORRES VARGAS -
Hi Omar, a query I hope you can help me, I am also trying to make a quizz access rule plugin with face-api, I already have the model in javascript, I have even developed a local type plugin with face-api in moodle, I don't know where to start developing the quizz access rule plugin, could you help me please, how are you doing your quizz access rule plugin?
Thanks.
In reply to MIGUEL TORRES VARGAS

Re: Importing face-api

by Omar Sehlouli -
Hi Miguel, I think my specifications were to only include face detection and report it back to the quiz administrator. In fact, I have only modified proctoring plugin which is already available in Moodle plugins. It's a free software licensed. In fact, it's useful to start where BS23 left their plugin. It's quite architectured in a way you can understand if you look up their plugin. I have also needed to use their function that screenshot the evidence of cheating, so that when the person moves around like 8 seconds or the API detects more than one person it screenshots the evidence. I think, morally speaking, you can't use a proctoring plugin and give people false alerts of cheating without evidence. That's why proctoring plugin is a nice point to start your editing.
Average of ratings: Useful (1)