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;
}
when using cv::resize, please give it a Size or scale factors, those things are pretty much xor.
how can i do this sorry i don't understand i need the image to be 50*50
resize(lbp, lbp, cvSize(50, 50));
(that's just general advice, unsure if this is the real error here)
i run the code with this new resize function but i have the same error
yea, already doubted so.
re-edit your question, show a bit more code happening before
i re-edit the question pls see it and tell me can i use the histogramsimg mat vector for my need instead of converting the histogrames vector or can i convert it from vector of mat into just one mat image
or can i convert it from vector of mat into just one mat image