[Opencv.js] High Ram and CPU usage makes calibration and Timeout impossible on some phones

Dear community,

I’m facing an issue with opencv.js. I’m doing a complete camera calibration using calib3d functions. Those functions leads to a High usage of CPU and RAM on some phones (low cost phones mostly).

When allocation fail a warning is written in console after few minutes of computing(calibrating on my pixel 6 takes 3 seconds).

To counter this problem, I tried to display an alert telling the user that the calibration had “timeout” using promises race with a SetTimeout. But it didn’t worked as the CPU usage is too high to makes async works. Because of that the message is displayed after opencv finished to compute. So I don’t have any control on my Timeout time.

I would like to know if you had some solutions to make a timeout system working even if javascript doesn’t allow multithreading.


can you use Web Workers?

calibration is a compute-intensive task. you should have expected high resource usage for this task.

I’ll give it a look. Thank you