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;
pars.push_back(CV_IMWRITE_PNG_COMPRESSION);
pars.push_back(3);
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!
you are trying to save an empty vector... You need to put something in that vector, first
why the imencode() ?
I'm filling imageMat with depth values of a Kinect depth frame. For that, I'm using the following code:
i'm pretty sure, your writing code is correct, and the culprit is your (weird) filling code. what is dataEnd ?
In my case c++ Code Generation settings were wrong Should have been Multithreaded DEBUG Dll MT