Skip to content

Commit

Permalink
Merge pull request asus4#357 from kaku-panda/master
Browse files Browse the repository at this point in the history
Adjustment to SSD Bounding Box Size Calculation to Account for Texture Aspect Ratio
  • Loading branch information
asus4 authored May 9, 2024
2 parents 7f0e3bb + 8372227 commit d58f7ed
Showing 1 changed file with 15 additions and 3 deletions.
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)
}

}

0 comments on commit d58f7ed

Please sign in to comment.