SparseSpatialMap Class

This type is an EasyAR Sense API in C#: SparseSpatialMap . Some descriptions may not apply to Unity environment on this page.

This type is partially wrapped into Unity components: SparseSpatialMapWorkerFrameFilter . Members and instances of this type are not required to be used directly in most situations. Use this type by SparseSpatialMapWorkerFrameFilter.Builder SparseSpatialMapWorkerFrameFilter.Localizer instead of creating new instances when a few unwrapped API is desired for use.

Description

Provides core components for SparseSpatialMap, can be used for sparse spatial map building as well as localization using existing map. Also provides utilities for point cloud and plane access.

SparseSpatialMap occupies 2 buffers of camera. Use setBufferCapacity of camera to set an amount of buffers that is not less than the sum of amount of buffers occupied by all components. Refer to Overview .


Methods

isAvailable

C#

public static bool isAvailable()

Check whether SparseSpatialMap is is available, always return true.

inputFrameSink

C#

public virtual InputFrameSink inputFrameSink()

Input port for input frame. For SparseSpatialMap to work, the inputFrame must include camera parameters, timestamp and spatial information. See also InputFrameSink

Note: Both pinhole and fisheye camera are supported. But performance may decrease while using a fisheye camera.

bufferRequirement

C#

public virtual int bufferRequirement()

Camera buffers occupied in this component.

outputFrameSource

C#

public virtual OutputFrameSource outputFrameSource()

Output port for output frame. See also OutputFrameSource

create

C#

public static SparseSpatialMap create()

Construct SparseSpatialMap.

setResultPoseType

C#

public virtual void setResultPoseType(bool enableStabilization)

Sets type of result pose. enableStabilization defaults to false. It only takes effect when InputFrame contains spatial information.

setResultAsyncMode

C#

public virtual bool setResultAsyncMode(bool enableAsync)

Sets result async mode. Set true If results are to be outputted via outputFrameSource, false if results are to be fetched via getSyncResult. enableAsync defaults to true. Sync mode is only available with input frames including spatial information and with a XR license.

start

C#

public virtual bool start()

Start SparseSpatialMap system.

stop

C#

public virtual void stop()

Stop SparseSpatialMap from running。Can resume running by calling start().

close

C#

public virtual void close()

Close SparseSpatialMap. SparseSpatialMap can no longer be used.

getPointCloudBuffer

C#

public virtual Buffer getPointCloudBuffer()

Returns the buffer of point cloud coordinate. Each 3D point is represented by three consecutive values, representing X, Y, Z position coordinates in the world coordinate space, each of which takes 4 bytes.

getMapPlanes

C#

public virtual List< PlaneData > getMapPlanes()

Returns detected planes in SparseSpatialMap.

hitTestAgainstPointCloud

C#

public virtual List< Vec3F > hitTestAgainstPointCloud( Vec2F cameraImagePoint)

Perform hit test against the point cloud. The results are returned sorted by their distance to the camera in ascending order.

hitTestAgainstPlanes

C#

public virtual List< Vec3F > hitTestAgainstPlanes( Vec2F cameraImagePoint)

Performs ray cast from the user’s device in the direction of given screen point.

Intersections with detected planes are returned. 3D positions on physical planes are sorted by distance from the device in ascending order.

For the camera image coordinate system ([0, 1]^2), x-right, y-down, and origin is at left-top corner. CameraParameters.imageCoordinatesFromScreenCoordinates can be used to convert points from screen coordinate system to camera image coordinate system.

The output point cloud coordinate is in the world coordinate system.

getMapVersion

C#

public static string getMapVersion()

Get the map data version of the current SparseSpatialMap.

unloadMap

C#

public virtual void unloadMap(string mapID, CallbackScheduler callbackScheduler, Optional<Action<bool>> resultCallBack)

UnloadMap specified SparseSpatialMap data via callback function.The return value of callback indicates whether unload map succeeds (true) or fails (false).

setConfig

C#

public virtual void setConfig( SparseSpatialMapConfig config)

Set configurations for SparseSpatialMap. See also SparseSpatialMapConfig .

getConfig

C#

public virtual SparseSpatialMapConfig getConfig()

Returns configurations for SparseSpatialMap. See also SparseSpatialMapConfig .

startLocalization

C#

public virtual bool startLocalization()

Start localization in loaded maps. Should set LocalizationMode first.

stopLocalization

C#

public virtual void stopLocalization()

Stop localization in loaded maps.

getSyncResult

C#

public virtual Optional< SparseSpatialMapResult > getSyncResult( MotionInputData motionInputData)

Get synchronized result. If SparseSpatialMap is paused, or the result async mode is not set to false through setResultAsyncMode, the return value is empty.