Sketch is running slow


I am currently doing the color track example from thecodingtrain’s youtube video (

I tried writing the code myself, and after comparing to Shiffman’s code on the video (, with the difference of me using less variables (which I guess makes my code slightly nastier), and also me using a higher resolution for the camera (he used 360x240 while I used 640x480)

my code however was really slow (the video also lagged so much) until I changed it almost exactly like the example.

does anyone know if the video resolution is causing this or the code? and if it is the code, can someone explain which things can make a processing sketch lag and if using variables can make it run faster? also if global variables and local variables have an impact?


Video resolution has a direct impact on speed from my experience. If you haven’t tried, use the P2D renderer as it might help. I do not think variables would make a big impact in your case, thinking along the lines that your code base is small.


ohh thank you so much!