Sketch is running slow

hi!

I am currently doing the color track example from thecodingtrain’s youtube video (https://www.youtube.com/watch?v=h8tk0hmWB44&list=PLRqwX-V7Uu6bw0bVn4M63p8TMJf3OhGy8&index=4).

I tried writing the code myself, and after comparing to Shiffman’s code on the video (http://learningprocessing.com/examples/chp16/example-16-11-ColorTrack), 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?

thanks!!

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.

Kf

ohh thank you so much!