how can i convert a vector of float into mat image
i
i need to convert vector of float to mat image then use this image in imgshow and resize function
i have this function but it doesn't work
memcpy(lbp.data,Vtrn.data(),Vtrn.size()*sizeof(float));
resize(lbp, lbp, cvSize(50, 50),100,100,1); //in order to make all image same size
imwrite(In.vectorofotrainpath[i].c_str(),lbp);// true with mat image or not
i have this error
Windows has triggered a breakpoint in mycode.exe.
This may be due to a corruption of the heap, which indicates a bug in mycode.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while mycode.exe has focus.
the vector i want to convert is the histograms vector i obtained from this function
vector<float> spatialhist::spatialHistogramforknnorsvm( const Mat& lbpImage, const Size& grid)
{
vector<float> histograms;
histograms.resize(grid.width*grid.height*sizeb);
int width=lbpImage.cols/grid.width;
int height=lbpImage.rows/grid.height;
int cnt=0;
vector<Mat> histogramsimage;
//#pragma omp parallel for
for(int i=0;i<grid.height;i++)
{
for(int j=0;j<grid.width;j++)
{
Mat cell=lbpImage(Rect(j*width,i*height,width,height));
Mat cell_hist=computeHistogram(cell);
histogramsimage.push_back(cell_hist);
//imshow("FFF",cell_hist);
Mat tmp_feature;
Mat feature =cell_hist.reshape(1,1);
feature.convertTo(tmp_feature,CV_32FC1);
float * ptr=tmp_feature.ptr<float>(0);
for(int k=0;k<tmp_feature.cols-1;k++)
{
if(ptr[k]==0)
ptr[k]=1.0/sizeb;
histograms[(cnt*sizeb)+k]=ptr[k];
// cerr << ptr[k] << endl;
}
cnt++;
}
}
return histograms;
}