Hello
I'm using VS2013 and openvc 3.0
Here I'm trying to read an image, convert it to float* from CV::MAT, do some processing, and again convert it back to CV::MAT from float*
Here is the code snippet
`
#include
#include
using namespace std;
using namespace cv;
int main()
{
//read the image
Mat src = imread("foggyHouse.jpg");
//convert to float*
Mat dst;
src.convertTo(dst, CV_32F);
float *data = dst.ptr();
//convert back to CV::MAT from float*
Mat dest;
dst.convertTo(dest,CV_8U);
//print image
imwrite("IMg.jpg", dest);
return 0;
}
`
the problem is I'm getting an error saying
First-chance exception at 0x528E0A14 (opencv_world300.dll) in Project3.exe: 0xC0000005: Access violation reading location 0x00137000.
Unhandled exception at 0x528E0A14 (opencv_world300.dll) in Project3.exe: 0xC0000005: Access violation reading location 0x00137000.
i tried other method to convert from CV:MAT to float*
here is the code
int height = src.rows;
int width = src.cols;
//convert from CV::MAT to float*
Mat dst;
src.convertTo(dst, CV_32F);
float *data = dst.ptr();
//convert from float* to CV::MAT
Mat dest(height, width, CV_32FC1, data);
imwrite("IMg.jpg", dest);
this is also giving the same error
Any suggestion or help will be appreciated.
Thanks
↧