Hi,
I've created a class Image which is a wrapper over a Mat (the actual data), plus some keypoints, descriptors, camera intrinsic matrix, etc .. I have an Image::ptr which is a shared_ptr<image>
I have vectors of Image::ptr, pairs of Image::ptr. Everybody is sharing, everything is great!
Up until I serialize // deserialize them using FileStorage.
Not surprisingly the serialized file contains a copy of the data, in every place I've used an Image::ptr. The more problematic thing, is that if I de-serialize I now have a copy of my Image everytime it appeared in a vector. (I don't serialize the actual pixels, just descriptors but still).
The question is, Is there a way to deal with smart / auto ptr to avoid redundancy when serializing ?
Otherwise, I'm considering using a global variable holding a map<index,image::ptr> and then replace Image::ptr with index everywhere. Or is there a simpler cleaner way that I haven't seen ?
Thank you!