Ask Your Question

Revision history [back]

Access violation when using imwrite to save an imageMat

Hi everybody!

I'm having an extremely annoying issue when tryig to save a PGN file with the depth value of a Kinect frame. I already have the millimeters Matrix in format.

 cv::Mat imageMat = cv::Mat(height, width, CV_16UC1);

I'm having a problem when I execute this:

vector<int> pars;
vector<unsigned char> image;
char *fmt = (char *)".png";
cv::imencode(fmt, imageMat, image, pars);
cv::imwrite("data.png", imageMat, pars);

The problem is actually in the last two lines. They both returns the same "Access violation while reading location at..."

Could anybody help me? I'm using OpenCV 3.0 on Visual Studio 2013.

Thank you all!