Code stops responding after getting camera image.

Hey. My team and I are currently working on identifying the baskets with out camera. We set a LED on our camera and the idea is that we take a picture with the LED on and another with the LED off. Then we take the absolute difference between both, and that gets us exactly what we need.

The problem is that we need to take one picture, turn the LED off, take another one and compare it with the previously taken picture. I tried doing this by creating two global variables and filling each with a picture when a button is clicked. But for some reason the code stops right when I give the order to take a picture.

The project is attached. Do you know what can I do to fix this? Is there a better way to use a two-picture script?

Or perhaps the whole concept of using two pictures is wrong? is there a much better way to identify the baskets?


Retrying Camera.rar (221 KB)

Retrying Camera.rar (221 KB)