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 int instanceId;
///
/// The labelId of the object resolved by a
///
public int labelId;
///
/// 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;
///
public override string ToString()
{
return $"{nameof(instanceId)}: {instanceId}, {nameof(labelId)}: {labelId}, {nameof(boundingBox)}: {boundingBox}, {nameof(pixelCount)}: {pixelCount}";
}
///
public bool Equals(RenderedObjectInfo other)
{
return instanceId == other.instanceId && labelId == other.labelId && 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 = instanceId;
hashCode = (hashCode * 397) ^ labelId;
hashCode = (hashCode * 397) ^ boundingBox.GetHashCode();
hashCode = (hashCode * 397) ^ pixelCount;
return hashCode;
}
}
}
}