您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
59 行
2.0 KiB
59 行
2.0 KiB
using System;
|
|
// ReSharper disable NonReadonlyMemberInGetHashCode
|
|
|
|
namespace UnityEngine.Perception.GroundTruth
|
|
{
|
|
/// <summary>
|
|
/// Describes an instance of an object in an instance segmentation frame. Generated by <see cref="RenderedObjectInfoGenerator"/>.
|
|
/// </summary>
|
|
public struct RenderedObjectInfo : IEquatable<RenderedObjectInfo>
|
|
{
|
|
/// <summary>
|
|
/// The instanceId of the rendered object.
|
|
/// </summary>
|
|
public int instanceId;
|
|
/// <summary>
|
|
/// The labelId of the object resolved by a <see cref="LabelingConfiguration"/>
|
|
/// </summary>
|
|
public int labelId;
|
|
/// <summary>
|
|
/// The bounding box of the object in pixel coordinates.
|
|
/// </summary>
|
|
public Rect boundingBox;
|
|
/// <summary>
|
|
/// The number of pixels in the image matching this instance.
|
|
/// </summary>
|
|
public int pixelCount;
|
|
|
|
/// <inheritdoc />
|
|
public override string ToString()
|
|
{
|
|
return $"{nameof(instanceId)}: {instanceId}, {nameof(labelId)}: {labelId}, {nameof(boundingBox)}: {boundingBox}, {nameof(pixelCount)}: {pixelCount}";
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public bool Equals(RenderedObjectInfo other)
|
|
{
|
|
return instanceId == other.instanceId && labelId == other.labelId && boundingBox.Equals(other.boundingBox) && pixelCount == other.pixelCount;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override bool Equals(object obj)
|
|
{
|
|
return obj is RenderedObjectInfo other && Equals(other);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override int GetHashCode()
|
|
{
|
|
unchecked
|
|
{
|
|
var hashCode = instanceId;
|
|
hashCode = (hashCode * 397) ^ labelId;
|
|
hashCode = (hashCode * 397) ^ boundingBox.GetHashCode();
|
|
hashCode = (hashCode * 397) ^ pixelCount;
|
|
return hashCode;
|
|
}
|
|
}
|
|
}
|
|
}
|