Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjustment to SSD Bounding Box Size Calculation to Account for Texture Aspect Ratio #357

Merged
merged 2 commits into from
May 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions Assets/Samples/SSD/SsdSample.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TensorFlowLite;
using TensorFlowLite;
using UnityEngine;
using UnityEngine.UI;
using TextureSource;
Expand Down Expand Up @@ -77,12 +77,23 @@ private void OnDestroy()
private void Invoke(Texture texture)
{
ssd.Run(texture);

SSD.Result[] results = ssd.GetResults();
Vector2 size = (frameContainer.transform as RectTransform).rect.size;

Vector2 ratio;
if (texture.width >= texture.height)
{
ratio = new Vector2(1.0f, (float)texture.height / (float)texture.width);
}
else
{
ratio = new Vector2((float)texture.width / (float)texture.height, 1.0f);
}

for (int i = 0; i < 10; i++)
{
SetFrame(frames[i], results[i], size);
SetFrame(frames[i], results[i], size * ratio);
}
}

Expand Down Expand Up @@ -114,3 +125,4 @@ private string GetLabelName(int id)
}

}