using UnityEngine;
namespace MagicLeap.OpenXR.Features.MarkerUnderstanding
{
///
/// Represents the different tracker profiles used to optimize marker tracking in difference use cases.
///
public enum MarkerDetectorProfile
{
///
/// Generic tracker profile.
/// Tracker profile that covers standard use cases. If this does not fit the
/// needs of the application try the other profiles.
///
Default = 0,
///
/// Use this profile to reduce the compute load and increase detection/tracker speed.
/// This can result poor poses.
///
Speed,
///
/// Use this profile to optimize for accurate marker poses.
/// This can cause increased load on the compute.
///
Accuracy,
///
/// Use this profile to optimize for markers that are small or for larger
/// markers that need to detected from far.
///
SmallTargets,
///
/// Use this profile to be able to detect markers across a larger Field Of View.
/// Marker Tracker system will attempt to use multiple cameras to detect the markers.
///
LargeFOV,
///
/// Application can define a custom tracker profiler.
///
Custom,
}
///
/// Represents the different marker types supported by the API
///
public enum MarkerType
{
Aruco = 0,
AprilTag,
QR,
EAN13,
UPCA,
Code128
}
///
/// The current status of the readiness of the marker tracker.
///
public enum MarkerDetectorStatus
{
Pending = 0,
Ready,
Error
}
///
/// Supported pre-defined ArUco dictionaries.
/// Marker Understanding supports pre-defined ArUco dictionaries.
/// ArUco dictionaries can be looked up and markers can be generated for them here:
/// http://chev.me/arucogen/
///
public enum ArucoType
{
///
/// 4 by 4 pixel ArUco marker dictionary with 50 IDs.
///
Dictionary_4x4_50 = 0,
///
/// 4 by 4 pixel ArUco marker dictionary with 100 IDs.
///
Dictionary_4x4_100,
///
/// 4 by 4 pixel ArUco marker dictionary with 250 IDs.
///
Dictionary_4x4_250,
///
/// 4 by 4 pixel ArUco marker dictionary with 1000 IDs.
///
Dictionary_4x4_1000,
///
/// 5 by 5 pixel ArUco marker dictionary with 50 IDs.
///
Dictionary_5x5_50,
///
/// 5 by 5 pixel ArUco marker dictionary with 100 IDs.
///
Dictionary_5x5_100,
///
/// 5 by 5 pixel ArUco marker dictionary with 250 IDs.
///
Dictionary_5x5_250,
///
/// 5 by 5 pixel ArUco marker dictionary with 1000 IDs.
///
Dictionary_5x5_1000,
///
/// 6 by 6 pixel ArUco marker dictionary with 50 IDs.
///
Dictionary_6x6_50,
///
/// 6 by 6 pixel ArUco marker dictionary with 100 IDs.
///
Dictionary_6x6_100,
///
/// 6 by 6 pixel ArUco marker dictionary with 250 IDs.
///
Dictionary_6x6_250,
///
/// 6 by 6 pixel ArUco marker dictionary with 1000 IDs.
///
Dictionary_6x6_1000,
///
/// 7 by 7 pixel ArUco marker dictionary with 50 IDs.
///
Dictionary_7x7_50,
///
/// 7 by 7 pixel ArUco marker dictionary with 100 IDs.
///
Dictionary_7x7_100,
///
/// 7 by 7 pixel ArUco marker dictionary with 250 IDs.
///
Dictionary_7x7_250,
///
/// 7 by 7 pixel ArUco marker dictionary with 1000 IDs.
///
Dictionary_7x7_1000,
}
///
/// Supported pre-defined AprilTag dictionaries.
/// Marker Understanding supports pre-defined AprilTag dictionaries.
/// AprilTag dictionaries can be looked up and markers can be generated for them here:
/// http://chev.me/arucogen/
///
public enum AprilTagType
{
///
/// 4x4 bits, minimum hamming distance between any two codes = 5, 30 codes
///
Dictionary_16H5 = 0,
///
/// 5x5 bits, minimum hamming distance between any two codes = 9, 35 codes
///
Dictionary_25H9,
///
/// 6x6 bits, minimum hamming distance between any two codes = 10, 2320 codes
///
Dictionary_36H10,
///
/// 6x6 bits, minimum hamming distance between any two codes = 11, 587 codes
///
Dictionary_36H11
}
///
/// Used to hint to the back-end the max frames per second
/// that should be analyzed. This is set in the
/// CustomProfileSettings structure and this setting
/// applies to all enabled trackers.
///
/// CPU load is a combination of enabled detector types,
/// FpsHint and ResolutionHint. More detectors with a higher FPS
/// and resolution hints will result in a higher CPU load. High CPU load can affect the
/// performance of your system.
///
public enum MarkerDetectorFPS
{
Low = 0,
Medium,
High,
Max
}
///
/// The MarkerDetectorResolution enum values are
/// used to hint to the back-end the resolution
/// that should be used. This is set in the
/// CustomProfileSettings structure and this setting
/// currently only applies to the QR, UPC and EAN detectors.
///
/// CPU load is a combination of enabled detector types,
/// MarkerDetectorFPS and MarkerDetectorResolution. More detectors and a higher
/// fps and resolution hints will result in a higher CPU load.
/// High CPU load can affect the performance of your system.
///
public enum MarkerDetectorResolution
{
Low = 0,
Medium,
High
}
///
/// The MarkerDetectorCamera enum values are
/// used to hint to the camera
/// that should be used. This is set in the
/// CustomProfileSettings structure and this setting
/// currently only applies to the aruco detectors.
///
/// RGB camera has higher resolution than world cameras and are better suited
/// for use cases where the target to be tracked is small or needs to be detected
/// from far.
///
/// World cameras make use of multiple world cameras to improve accuracy and
/// increase the FoV for detection.
/// from far.
///
public enum MarkerDetectorCamera
{
///
/// Single RGB Camera.
///
RGB = 0,
///
/// One or more world cameras.
///
World
}
///
/// The Aruco/April tag detector comes with several corner refinement methods.
/// Choosing the right corner refinement method has an impact on the accuracy and
/// speed trade-off that comes with each detection pipeline.
/// Corner refinement only applies to Aruco and April tags, not QR codes.
///
public enum MarkerDetectorCornerRefineMethod
{
///
/// No refinement, may have inaccurate corners.
///
None = 0,
///
/// Corners have subpixel coordinates.
/// High detection rate, very fast, reasonable accuracy.
///
Subpix,
///
/// High detection rate, fast, reasonable accuracy.
///
Contour,
///
/// Reasonable detection rate, slowest, but very accurate.
///
AprilTag
}
///
/// In order to improve performance, the detectors don't always run on the full
/// frame. Full frame analysis is however necessary to detect new markers that
/// weren't detected before. Use this option to control how often the detector may
/// detect new markers and its impact on tracking performance.
///
public enum MarkerDetectorFullAnalysisInterval
{
///
/// Detector analyzes every frame fully.
///
Max = 0,
///
/// Detector analyzes frame fully very often.
///
Fast,
///
/// Detector analyzes frame fully a few times per second.
///
Medium,
///
/// Detector analyzes frame fully about every second.
///
Slow
}
///
/// The data retrieved from a marker detector.
///
public struct MarkerData
{
///
/// The reprojection error is only useful when tracking codes. A high
/// reprojection error means that the estimated pose of the QR code doesn't match
/// well with the 2D detection on the processed video frame and thus the pose might
/// be inaccurate. The error is given in degrees, signifying by how much either
/// camera or QR code would have to be moved or rotated to create a perfect
/// reprojection. The further away your QR code is, the smaller this reprojection
/// error will be for the same displacement error of the code.
///
public float ReprojectionErrorMeters;
///
/// The estimated length of the marker in meters.
///
public float MarkerLength;
///
/// The number data retrieved from the marker. Only applies to and .
///
public ulong? MarkerNumber;
///
/// The string data obtained from the marker. Only applies to , , , and .
///
public string MarkerString;
///
/// The position and rotation data of the marker. Only applies to , , and .
///
public Pose? MarkerPose;
}
///
/// All of the settings associated with the marker tracker.
///
public struct MarkerDetectorSettings
{
///
/// The marker type to be associated with the marker tracker.
///
public MarkerType MarkerType;
///
/// The type of tracker profile to be associated with the marker tracker.
///
public MarkerDetectorProfile MarkerDetectorProfile;
///
/// The custom settings to be applied to the marker tracker. This is only applicable when a custom type is selected for the MarkerDetectorProfile.
///
public CustomProfileSettings CustomProfileSettings;
///
/// The settings associated with the Aruco marker type to be applied to the marker tracker. This only applies if the MarkerType is Aruco.
///
public ArucoSettings ArucoSettings;
///
/// The settings associated with the AprilTag marker type to be applied to the marker tracker. This only applies if the MarkerType is AprilTag.
///
public AprilTagSettings AprilTagSettings;
///
/// The settings associated with the QR marker type to be applied to the marker tracker. This only applies if the MarkerType is QR.
///
public QRSettings QRSettings;
}
///
/// The custom settings applied to the marker tracker when a custom profile is used.
///
public struct CustomProfileSettings
{
///
/// A hint to the back-end the max frames per second hat should be analyzed.
///
public MarkerDetectorFPS FPSHint;
///
/// A hint to the back-end the resolution that should be used.
///
public MarkerDetectorResolution ResolutionHint;
///
/// A hint to the back-end for what cameras should be used.
///
public MarkerDetectorCamera CameraHint;
///
/// This option provides control over corner refinement methods and a way to
/// balance detection rate, speed and pose accuracy. Always available and
/// applicable for Aruco and April tags.
///
public MarkerDetectorCornerRefineMethod CornerRefinement;
///
/// Run refinement step that uses marker edges to generate even more accurate
/// corners, but slow down tracking rate overall by consuming more compute.
/// Aruco/April tags only.
///
public bool UseEdgeRefinement;
///
/// In order to improve performance, the detectors don't always run on the full
/// frame. Full frame analysis is however necessary to detect new markers that
/// weren't detected before. Use this option to control how often the detector may
/// detect new markers and its impact on tracking performance.
///
public MarkerDetectorFullAnalysisInterval AnalysisInterval;
}
///
/// Settings associated with the Aruco marker type.
///
public struct ArucoSettings
{
///
/// Whether the length of the Aruco marker will be estimated automatically.
///
public bool EstimateArucoLength;
///
/// The estimated length of the Aruco marker in meters.
///
public float ArucoLength;
///
/// The type of pre-defined Aruco dictionary.
///
public ArucoType ArucoType;
}
///
/// Settings associated with the AprilTag marker type.
///
public struct AprilTagSettings
{
///
/// Whether the length of the AprilTag marker will be estimated automatically.
///
public bool EstimateAprilTagLength;
///
/// The estimated length of the AprilTag marker in meters.
///
public float AprilTagLength;
///
/// The type of pre-defined AprilTag dictionary.
///
public AprilTagType AprilTagType;
}
///
/// Settings associated with the QR marker type.
///
public struct QRSettings
{
///
/// Whether the length of the QR marker will be estimated automatically.
///
public bool EstimateQRLength;
///
/// The estimated length of the QR marker in meters.
///
public float QRLength;
}
}