OpenCV exception handling