I’ve tried using the debugging console to verify the values of variables, but can’t see why there would be any issues. I should mention that this exact same code seems to work for Shiffman in the Processing tutorial. Any idea why this would be the case?

Based on the number you are getting, it seems your video input is at a higher resolution than your preview image. The number 230400 is exactly divisible by 360 and results in 640.
That means the value in loc is exceeding the size of prev.pixels.

What happens if you use the following inside setup() to initialize `prev’?

prev = createImage(video.width, video.height, RGB);

Alternatively, step through the width and height of prev in the dual for-loops instead of the dimensions of video.

Ah, I see what happened now. The parameters for Capture were wrong. I’ve changed them to include width and height.

video = new Capture(this, 640, 360, cameras[0]);

Now it works like a charm!

This may have something to do with the fact that I’m using theVideo Library Release 6 (version 2.0-beta4) library rather than the standard video library one gets when they ‘import library’ through the processing editor.

In any case, thanks for the help everyone! Your advice was motivating nonetheless