You haven't told us where this is crashing, but I'd bet that it's crashing due to you trying to insert a nil value into your dictionary. (Next time, please look for anything being logged to the console when asking a question like this.)
That nil image is going to come from the fact that you've put your -useNextFrameForImageCapture
in the wrong place. It need to go before the -processImage
calls in the above, which are what triggers the actual rendering to your filter.
I bet if you move that line back, you'll no longer get a nil image and will no longer crash.