using System;
// ReSharper disable NonReadonlyMemberInGetHashCode
namespace UnityEngine.Perception.GroundTruth
{
///
/// Describes an instance of an object in an instance segmentation frame. Generated by .
///
public struct RenderedObjectInfo : IEquatable
{
///
/// The instanceId of the rendered object.
///
public uint instanceId;
///
/// The bounding box of the object in pixel coordinates.
///
public Rect boundingBox;
///
/// The number of pixels in the image matching this instance.
///
public int pixelCount;
///
/// The unique RGBA color for the instance.
///
public Color32 instanceColor;
///
public override string ToString()
{
return $"{nameof(instanceId)}: {instanceId}, {nameof(boundingBox)}: {boundingBox}, {nameof(pixelCount)}: {pixelCount}, {nameof(instanceColor)}: {instanceColor}";
}
///
public bool Equals(RenderedObjectInfo other)
{
return instanceId == other.instanceId && boundingBox.Equals(other.boundingBox) && pixelCount == other.pixelCount;
}
///
public override bool Equals(object obj)
{
return obj is RenderedObjectInfo other && Equals(other);
}
///
public override int GetHashCode()
{
unchecked
{
var hashCode = (int)instanceId;
hashCode = (hashCode * 397) ^ boundingBox.GetHashCode();
hashCode = (hashCode * 397) ^ pixelCount;
return hashCode;
}
}
}
}