I am getting "Exception thrown at 0x00007FFF428944E0 (opencv_world343d.dll) in ... .exe: 0xC0000005: Access violation reading location 0x0000023339631FB8." I have read some "access violation reading location" posts and topics but I think I allocate and initialize memory correctly, which seems to be the issue most often.
My code contains a "loadfits" function that loads a 16bit grayscale picture and stores it in a openCV cv::Mat. The function works - right at the end before the return statement, I can show or save the image and everything works perfectly, inside the function. But when I try to access and work with the cv::Mat in main(), I get the access violation error.
#define DFTtypeCV CV_64FC1
#define PICtypeCV CV_16UC1 //16bit grayscale image
Mat loadfits(std::string path)
{
ifstream streamIN(path, ios::binary | ios::in);
vector<char> celyobraz_8(fitsSize*fitsSize * 2, 0);
streamIN.read(&celyobraz_8[0], fitsSize*fitsSize * 2);
... //some code
Mat fits_PICTURE_Mat = Mat(fitsSize, fitsSize, PICtypeCV, &celyobraz_8[0], Mat::AUTO_STEP);
showimg(fits_PICTURE_Mat, "fitsRaw"); //shows the correct image
return fits_PICTURE_Mat; //returns the same image
}
Then I use this function to initialize and work with with a cv::Mat in main()
Mat picZERO(fitsSize, fitsSize, PICtypeCV);
Mat picZEROd(fitsSize, fitsSize, DFTtypeCV);
picZERO = loadfits(path);
picZERO.convertTo(picZEROd, DFTtypeCV); //I get the error here
I thought I am gonna be able to solve this bug easily since I have the correct data right before the function return statement, but can't seem to figure it out.
Any ideas? Thanks.
Had the same problem. In my case, the solution was to remove the link to opencv_world343d.dll in release configuration. This file is only for debug mode.
(Initially, I followed this instruction http://shailendra.me/tutorial/add-opencv-to-visual-studio-c++-project/ )
User contributions licensed under CC BY-SA 3.0