# What's the point of having a const cv::Mat?

It looks like openCV can modify a Mat even if it's const. Many function (e.g. morphologyExor GaussianBlur) will happily take and modify a const cv::Mat. I suppose that's because they could be making a copy of the header, but then access the raw data and modify it. The OutputArray type is even defined as typedef const _OutputArray& OutputArray;.

Is this by design? What's the idea behind it? How can one protect a cv::Mat from changes?

GaussianBlur manipulates the OutputArray, which is typedef-ed as const. Basically it doesn't matter if you have a const cv::Mat, opencv will still change it via the raw pointer.