Using this code for exhibition. how to make the size of file smaller?

changing pixelated dot size by distance

Hi, I am a beginner at coding and I just made this code using some references.
In this code, the webcam recognizes the distance of people using PoseNet. And the size of dots gets bigger when the audience is far away and smaller when the audience is closer.

I am planning to use this code for an exhibition, using a monitor, a webcam, and a mini computer. As I am testing this code with my computer, I found out the video with the code is getting slower and later almost not working. I am concerned because I am planning to install and play this piece for 8 hours a day without wifi.

Question 1: how to make it safe to play for many hours.
Question 2: what is the best and affordable mini-computer do you recommend for this project?

My guess is (guess because I cannot verify it or documentation doesn’t help) that loadPixels() keeps hogging memory and garbage collection doesn’t keep up. Usually loadPixels() is followed with updatePixels() after drawing has been done. I suspect it also releases memory or enable reuse of it. You don’t have updatePixels() and it might cause (i’m guessing) slow down of carbage collection. Beside do you need loadPixels() for canvas, because you don’t use that pixel array at all.

I would try raspberry. It might well have enough power to run your script and sure is affordable.