![]() |
ImFusion C++ SDK 4.4.0
|
#include <ImFusion/Base/ImFusionImage.h>
Loading and saving of the ImFusion image format. More...
Loading and saving of the ImFusion image format.
Classes | |
| class | ImFusionImageHeader |
| For image types, the corresponding data block contains the following header. More... | |
Public Member Functions | |
| ImFusionImage () | |
| Constructor with filename to load or save. | |
| ~ImFusionImage () override | |
| Deletes all auxiliary storage however not any loaded data. | |
| void | setCompressionOptions (int mode, int passes, int dx, int dy) |
| Set options for image compression. | |
| Data * | loadInstance (unsigned int type, unsigned int headerSize) override |
| Create specialized instance for a given data type or return null if not supported. | |
| unsigned int | saveType (const Data *data) override |
| Return type for saving a given data instance or null if not supported. | |
| bool | load (unsigned int type, Data *data, std::istream &file, Progress *p=0) override |
| Load specified data type into given class instance from file, return true upon success. | |
| bool | save (Data *data, std::ostream &file, Progress *p=0) override |
| Save a data instance to file, return true if successful. | |
| bool | startSaveAsync (SharedImageSet *is, std::ostream &file, Progress *p=0) |
| Prepares the asynchronous saving of images. | |
| bool | addFrameAsync (TypedImage< unsigned char > *memImg, std::ostream &file) |
| After calling startSaveAsync(), call this method to save an image. Blocking. | |
| bool | closeAsync (SharedImageSet *is, std::ostream &file, bool saveTimestamps=false) |
| After calling startSaveAsync() and addFrameAsync() for each image, finalize the operation with this method. | |
| bool | loadFromAsyncFormat (SharedImageSet *is, std::istream &file, Progress *p=0) |
| Reads a SharedImageSet that was saved with startSaveAsync/addFrameAsync/closeAsync. | |
| void | setCurrentFilePath (const std::string &path) |
| Sets the path of the current IMF file being loaded/saved. | |
| const std::string & | currentFilePath () const |
| Returns the path of the current IMF file being loaded/saved. | |
| Public Member Functions inherited from ImFusion::ImFusionFilePlugin | |
| virtual | ~ImFusionFilePlugin ()=default |
| Destructor. | |
| virtual std::unique_ptr< Properties > | customPropertiesToSave (Data *) |
| Lets plugin save custom properties as part of the global file metadata. | |
| virtual bool | loadCustomProperties (Data *, Properties *) |
| Load custom properties as returned previously by customPropertiesToSave(). | |
| virtual void | applyFlipToEnsureConsistency (Data *) |
| Is called after the image content had to be flipped to ensure a consistent coordinate system. | |
| virtual bool | beginBlockRead (std::iostream &, unsigned long long) |
| Initialize plugin with current file pointer. | |
| virtual bool | endBlockRead () |
| Indicate to plugin that it will lose read access to the file pointer after this call. | |
| virtual void | setBlockType (unsigned int type) |
| Set the type of current data block which is being loaded/saved. | |
Static Public Member Functions | |
| static unsigned int | imageSaveType (const SharedImageSet *is) |
| Return the first 9 bits of the save type of a given SharedImageSet. | |
Protected Member Functions | |
| virtual bool | loadHeader (std::istream &file) |
| Load the file header, return true upon success. | |
| virtual unsigned char | saveHeader (std::ostream &file, SharedImageSet *is, ImageCompression *c, int nf) |
| Save the file header, return the data format. | |
| bool | loadFrame (std::istream &file, const ImageDescriptor &d, const mat4 &m, const double t, unsigned int blockType, SharedImageSet *is) |
| Loads an image data frame, returns true if successful. | |
| ImageDescriptor | loadDescriptor (std::istream &file) |
| Load an image descriptor. | |
| void | saveDescriptor (std::ostream &file, const ImageDescriptor &d, int reverseScaling=1) |
| Save an image descriptor. | |
| mat4 | loadMatrix (std::istream &file) |
| Load a transformation matrix. | |
| void | saveMatrix (std::ostream &file, const mat4 &m) |
| Save a matrix. | |
| void | saveImage (std::ostream &file, const MemImage *img, unsigned char format) const |
| Save a single image given compression format. | |
| template<typename T> | |
| void | loadImage (std::istream &file, TypedImage< T > *img) const |
| Template method to load a compressed image. | |
| template<typename T> | |
| void | saveImage (std::ostream &file, const TypedImage< T > *img, unsigned char format) const |
| Template method to actually save an image with compression. | |
| Data::Modality | computeModality (unsigned int blockType) const |
| Assemble image modality from block type and data format. | |
| std::string | currentFileDirectory () const |
| Returns the directory of the ImFusion file currently being loaded/saved. | |
Protected Attributes | |
| Progress * | m_progress |
| Optional progress callback interface. | |
| std::vector< ImageDescriptor > | m_desc |
| Image descriptors for per frame data. | |
| std::vector< mat4 > | m_matrices |
| Matrix transformation for per frame data. | |
| std::vector< double > | m_timestamps |
| Timestamp for per frame data. | |
| ImFusionImageHeader * | m_header |
| The image format header. | |
| DataList | m_data |
| List of all loaded image data. | |
| Protected Attributes inherited from ImFusion::ImFusionFilePlugin | |
| unsigned int | m_blockType = 0 |
| Keeps the type of currently saving/loading data block. | |
Members for streaming | |
| std::iostream * | m_stream |
| file stream | |
| unsigned long long | m_streamWritten |
| number of bytes written | |
| unsigned long long | m_streamStartPos |
| start offset | |
Members of async. saving | |
| std::streampos | m_asyncPosHeader |
| Header position in current stream. | |
| int | m_asyncFrameCounter |
| Frame counter (to fix header afterwards). | |
| std::unique_ptr< ImageCompressionCodec > | m_asyncCompressor |
| FFMPEP image compression engine. | |
| std::string | m_currentFilePath |
| Path of the current IMF file being loaded/saved. | |
| std::string | m_asyncFilePath |
| Path to the binary file with the actual images. | |
Methods for streaming images into file | |
| bool | beginBlockWrite (std::iostream &io) override |
| Begin block to be written into file. Returns true if successful, false otherwise. | |
| bool | blockWriteImage (SharedImageSet *is) |
| Stream image with header into block. Returns true if successful, false otherwise. | |
| unsigned long long | endBlockWrite () override |
| Finish block written into file. Returns number of bytes written to the block. | |
|
overridevirtual |
Create specialized instance for a given data type or return null if not supported.
Implements ImFusion::ImFusionFilePlugin.
|
overridevirtual |
Return type for saving a given data instance or null if not supported.
Implements ImFusion::ImFusionFilePlugin.
|
overridevirtual |
Load specified data type into given class instance from file, return true upon success.
Reimplemented from ImFusion::ImFusionFilePlugin.
|
overridevirtual |
Save a data instance to file, return true if successful.
Reimplemented from ImFusion::ImFusionFilePlugin.
| bool ImFusion::ImFusionImage::startSaveAsync | ( | SharedImageSet * | is, |
| std::ostream & | file, | ||
| Progress * | p = 0 ) |
Prepares the asynchronous saving of images.
The provided SharedImageSet must already be filled with at least one image to ensure correct metadata. Does not save any images, call addFrameAsync() for each image.
| bool ImFusion::ImFusionImage::closeAsync | ( | SharedImageSet * | is, |
| std::ostream & | file, | ||
| bool | saveTimestamps = false ) |
After calling startSaveAsync() and addFrameAsync() for each image, finalize the operation with this method.
Without it, the data will not be readable. If desired, appends the images' timestamps at the end. If saveTimestamps is false, is can be nullptr.
| bool ImFusion::ImFusionImage::loadFromAsyncFormat | ( | SharedImageSet * | is, |
| std::istream & | file, | ||
| Progress * | p = 0 ) |
Reads a SharedImageSet that was saved with startSaveAsync/addFrameAsync/closeAsync.
Internally calls load(), and then reads any potential timestamps from the end.
|
overridevirtual |
Begin block to be written into file. Returns true if successful, false otherwise.
Reimplemented from ImFusion::ImFusionFilePlugin.
|
overridevirtual |
Finish block written into file. Returns number of bytes written to the block.
Reimplemented from ImFusion::ImFusionFilePlugin.