MosaicWriter Class
A class for writing projected video to a GeoPackage.
NuGet/Assembly: Carmenta.Engine.5.17.0.nupkg (in the CEDataSets assembly)
Syntax
public class MosaicWriter : EngineObject
Remarks
This class is used to stitch together georeferenced video frames into a mosaic, represented as a GeoPackage image tile pyramid. This GeoPackage can be read by MapPackageDataSet, either live as it is updated or after writing has finished.
![]() |
The MosaicWriter can create new mosaics or modify existing ones. Some properties can be modified for new mosaics but are static after the mosaic has been created, indicated by the status of the property Initialized.
The frames are fetched from the Input operator and have to be georeferenced mesh features with the same attributes as those produced by CameraProjectOperator.
The frames are rendered to tiles in the geopackage and the detail level for a particular frame is chosen by the MosaicWriter based on the MaximumResolution and AdjustTileLevel properties. The MosaicWriter will attempt to find a tile level with a pixel size that matches that of the frame as closely as possible, but if a greater level of detail is already present (e.g from a previous more zoomed in frame), then that greater level is used instead.
Rendering a mosaic is different compared to streaming video and puts different requirements on the custom dataset that provides the frames. When writing to mosaic one could for example want to get the frames at specific intervals of the entire video in one go. To simplify this, the WriteFeatures method takes an AttributeSet that is propagated to the operator chain and the custom dataset as updateAttributes that can be used as argument to control the behaviour of the custom dataset.
Another tool to control which frames are actually rendered to the mosaic geopackage is to use OverlapLimit and MergeFilterPolygons to discard frames which overlap the mosaic too much. This can be useful to filter based on the geographic positions of the frames to prevent the same area is covered by too many frames, which would otherwise cost performance and create seam artifacts in the resulting mosaic raster.
When adding a new frame to the mosaic, the MosaicWriter always adds pixels which don't overlap the existing mosaic. There are two alternative ways of selecting overlapping pixels controlled by the Strategy property. With value LatestView, overlapping pixels always overwrite the old values. With BestView, the angle of the camera used to take the frame is compared to the angle that was used to take the frame of the pixel in the existing mosaic. If the new camera has a more vertical view of the area, the pixel is overwritten. A BestView mosaic should provide a more accurate vertical representation of an area than LatestView. Parts of objects that are not vertical-facing, like building walls, should be less apparent as can be seen below. The accuracy of a BestView mosaic can be improved by allowing many highly-overlapping frames since each frame probably has a better view of a unique area compared to the rest. A lower OverlapLimit will reduce the number of frames to pick pixels from and therefore lower the benefit obtained by the BestView strategy.
![]() |
In order for the BestView strategy to work, the CameraProjectOperator used to project the video frames must have the property CameraProjectOperator.KeepAttributes set to true in order to perserve the attributes from the camera used to calculate which pixels to use. If the required attributes are not available an exception is thrown.
The MosaicWriter can be used in a scenario where video is processed live and the mosaic is visualized in a view as it is updated. The property MapPackageDataSet.MonitorInterval can be used to monitor changes in the GeoPackage and signal to the view when the mosaic has changed. It's recommended to call WriteFeatures on a background thread. The GUI thread (or another thread) can stop the operation by calling Abort. See the sample application "ProjectedVideo" for an example implementation of the live scenario.
Inheritance Hierarchy
System.Object
EngineObject
MosaicWriter
Platforms
Windows, Linux, Android
MosaicWriter Members
The MosaicWriter type has the following members.
Constructors
Name | Description |
---|---|
MosaicWriter | Initializes a new instance of the MosaicWriter class with the given path, table name and operator chain for writing projected video to a new or existing OGC GeoPackage. |
Properties
Name | Description |
---|---|
AdjustTileLevel | Gets or if uninitialized sets the adjustment to tile level. |
Crs | Gets or if unitialized sets the CRS used to write video imagery to the GeoPackage. |
Initialized | Gets whether a GeoPackage has already been initialized. |
Input | Gets the operator used to read video imagery from. |
IsDisposed | Gets a value that tells whether the current MosaicWriter has been disposed. Inherited from EngineObject |
MaximumResolution | Gets or if uninitialized sets the pixel size in meters for the most detailed tiles. |
MergeFilterPolygons | Gets or if unintialized sets whether new written frames are checked against all written frames or only the last. |
NativeHandle | Gets the native Carmenta Engine kernel object the current MosaicWriter represents. Inherited from EngineObject |
OverlapLimit | Gets or if uninitialized sets the minimum allowed overlap between rendered video frames. |
Path | Gets the path to the GeoPackage to create or open. |
Strategy | Gets or if uninitialized sets the strategy used to update the geopackage. |
TableName | Gets the table name to write video imagery to. |
TileSize | Gets or if uninitialized sets the tile size in pixels. |
Methods
Name | Description |
---|---|
Abort | Method to terminate active calls to writeFeatures. |
Clone | Creates a copy of an object. Inherited from EngineObject |
Dispose | Releases the reference to the native Carmenta Engine kernel instance the EngineObject represents. Inherited from EngineObject |
Equals | Determines whether this instance is equal to another. Inherited from EngineObject |
WriteFeatures | Writes frame features from the assigned input to GeoPackage. |