How to handle code producing an exception in OpenCV

That was it - thankyou

Now I need to add a filter to fix it. Any suggestions?

int objDetected = binKeypoints.size();