1 | initial version |
Two possibilities : Don't use allocated memory copy each pixel in a Mat example image of type CV_16SC1
short *tmp=new short[256*256];
......
cv::Mat m(256,256,CV_16S);
for (int i=0;i<256;i++)
for (int j=0;j<256;j++)
{
m.at< short >(i,j)=tmp[i*256+j];
}
and another way use memory still allocated
short tmp=new short[256256]; ......
cv::Mat m(256,256,CV_16S,(void *) tmp,AUTO_STEP);
In that case "The external data is not automatically deallocated, so you should take care of it."
2 | No.2 Revision |
Two possibilities : Don't use allocated memory copy each pixel in a Mat example image of type CV_16SC1
short *tmp=new short[256*256];
......
cv::Mat m(256,256,CV_16S);
for (int i=0;i<256;i++)
for (int j=0;j<256;j++)
{
m.at< short >(i,j)=tmp[i*256+j];
}
and another way use memory still allocated
short
In that case "The external data is not automatically deallocated, so you should take care of it."