I'm trying to use facial recognition via OpenCV.js, however when I call on the detectMultiScale()
method of the CascadeClassifier
object I receive the error:
Uncaught 6446128 - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.
The problem is I'm leveraging a hosted version of opencv.js
directly from opencv.org - it's not a build version because I'm unable to build it myself, and therefore cannot follow the error's instructions.
I've followed an example from their GitHub here and adapted the code to suit my needs, as follows:
<html>
<head>
<script src="https://docs.opencv.org/master/opencv.js"></script>
<script src="https://docs.opencv.org/master/utils.js"></script>
</head>
<body>
<img id="test" src="image/with/face.jpg" alt=""/>
<canvas id="output"></canvas>
<script>
let face_cascade = new cv.CascadeClassifier();
face_cascade.load("https://raw.githubusercontent.com/opencv/opencv/master/data/haarcascades_cuda/haarcascade_frontalface_default.xml");
function face_detector() {
let imgEl = document.getElementById("test");
let img = cv.imread(imgEl);
cv.imshow("output", img);
let src = cv.imread("output");
let gray = new cv.Mat();
let msize = new cv.Size(0,0);
cv.cvtColor(src, gray, cv.COLOR_RGBA2GRAY, 0);
let faces = new cv.RectVector();
face_cascade.detectMultiScale(gray, faces, 1.1, 3, 0, msize, msize); //Error occurs here
}
face_detector();
</script>
</body>
</html>
Anyone with experience with OpenCV.js and facial recognition that could help?