Generalize the conversions between Blob and OpenCV Mat