The code below returns the position and orientation of the image (typically from a camera feed) within the map. The
LocalizeImage function returns
0 if localization failed and
1 if it succeeded.
Immersal.AR.ARLocalizer in the
Samples/Scripts/AR folder as an example of how to get the pixel buffer data and intrinsics for the image in an AR Foundation application.
Samples/Scenes/SampleScene utilizes this class and can be used for quickly testing of your mappings.
To localize, use this code
int width; // width of the imageint height; // height of the imageVector4 intrinsics; // camera intrinsicsbyte pixels; // image dataVector3 pos; // resulting device positionQuaternion rot; // resulting device orientationint result = Immersal.Core.LocalizeImage(out pos, out rot, width, height, ref intrinsics, pixels);
The code below captures and saves an image to the current mapping session. Typically, capturing several images is required to calculate a continuous point cloud map. The
CaptureImage function returns the number of bytes captured.
Immersal.Samples.Mapping.Mapper class and
Samples/Scenes/MappingApp as an example.
To capture an image, use this code
byte pixels; // image data (typically from the camera)int width; // image widthint height; // image heightint channels; // 1 or 3, monochromatic or RGB capturebyte capture = new byte[4 * 1024 * 1024]; // should need less than 2 megs when reso is 1440pint size = Immersal.Core.CaptureImage(capture, capture.Length, pixels, width, height, channels);
The currently loaded point cloud can be retrieved for e.g. visualization.
The code below retrieves the currently active point cloud and visualizes it. The
GetPointCloud function returns the number of points in the cloud.
To get the point cloud, use this code
Vector3 points = new Vector3; // allocate spaceint num = Immersal.Core.GetPointCloud(points); // get the point cloudm_PointRenderer.CreateCloud(points, num); // do something with the point cloud data, e.g. visualize
The code below initializes the plugin with a previously captured and saved map data. See
Immersal.AR.ARCloud in the
Samples/Scripts/AR folder as an example.
To load the captured point cloud map, use this code