how to convert char str_buffer[3072] into mat;
how to convert cifar10 image char str_buffer[3072] into mat ;
how to convert cifar10 image char str_buffer[3072] into mat ;
May be you should read a book about C++
int main() {
ifstream fs;
const int tailleImage=3073;
fs.open("F:\\Images\\cifar-10-batches-bin\\data_batch_1.bin",ios::binary);
if (!fs.is_open())
return 0;
char *data=new char[tailleImage];
for (int indexImage=25;indexImage<50;indexImage++)
{
fs.seekg(indexImage*tailleImage,ios::beg);
fs.read(data,tailleImage);
Mat im(32,32,CV_8UC3);
for (int i=0;i<im.rows;i++)
for (int j=0;j<im.rows;j++)
im.at<Vec3b>(i,j)=Vec3b(data[j+i*32],data[j+i*32+32*32],data[j+i*32+32*32*2]);
imshow("CIFAR",im);
waitKey(100);
}
delete data;
return 0;
}
I don't check if it was BGR or RGB.
Asked: 2015-06-02 09:09:29 -0600
Seen: 189 times
Last updated: Jun 02 '15