Unsolved How can I make a QBytearray from non Qt DataType matrix<float,1,0>
-
Hi,
I wan to wirte my 512 dimension float matrix to the Sqlite . I can manage for Pixmap . png as below:
QByteArray inByteArray; descBuffer.open(QIODevice::ReadWrite); QBuffer inBuffer( &inByteArray ); inBuffer.open( QIODevice::WriteOnly ); inPixmap.save( &inBuffer, "PNG" ); // write inPixmap into inByteArray in PNG format
than I can write inByteArray to the Sqlite.
How can I do this for matrix<float , 0 , 1> which is a 512D matrix?
so I can write sqlite and read back ?
Best
-
Hi,
Where does that type come from ?
-
-
Looks like steal_memory might be what you are looking for.
-
what you mean ?
-
@RahibeMeryem there is a
steal_memory()
function in the header file you showed us. -
The
serialize
function probably helps:void serialize ( const matrix<T,NR,NC,mm,l>& item, std::ostream& out ) { try { // The reason the serialization is a little funny is because we are trying to // maintain backwards compatibility with an older serialization format used by // dlib while also encoding things in a way that lets the array2d and matrix // objects have compatible serialization formats. serialize(-item.nr(),out); serialize(-item.nc(),out); for (long r = 0; r < item.nr(); ++r) { for (long c = 0; c < item.nc(); ++c) { serialize(item(r,c),out); } } } catch (serialization_error& e) { throw serialization_error(e.info + "\n while serializing dlib::matrix"); } }
You just need to replace the
std::ostream
with aQDataStream