Code is not executed in Processing, but in p5.js Web Editor

Interesting demo. The good news is that it does run in Processing IDE with Safari browser on a Mac, which is pretty good since you had no way to test it. The bad news is that you used another method of finding the devices and only opened one of my two cameras, unlike the original demo. The code also placed a multi-color background, flashing canvas on top of the video feed. You could set the canvas to size 0,0 and forget the background changes and it would improve the demo in my opinion. Since you used a new technique of finding the devices and the code ran in Processing IDE I will use this as further evidence that there is a problem using navigator.mediaDevices.enumerateDevices() in Safari until someone proves otherwise.

There were many warnings and one error which you might be interested in knowing.

Use the function form of “use strict”.
‘console’ is not defined.
Expected ‘{’ and instead saw ‘if’.
Expected ‘{’ and instead saw ‘videoDevicesFound’.
Expected ‘{’ and instead saw ‘constraints’.
‘createCapture’ is not defined.
‘globalThis’ is not defined.
‘p5’ is not defined.
‘createCanvas’ is not defined.

In spite of all these warnings it still ran.