Skip to content

Commit

Permalink
feat(objectron): set confidence parameters at runtime (#605)
Browse files Browse the repository at this point in the history
* chore: update prefab files

* feat(objectron): set confidence parameters at runtime
  • Loading branch information
homuler committed Jun 8, 2022
1 parent 358f7b9 commit af86a8e
Show file tree
Hide file tree
Showing 11 changed files with 1,334 additions and 215 deletions.
1,432 changes: 1,241 additions & 191 deletions Assets/MediaPipeUnity/Samples/Scenes/Objectron/Objectron Config Window.prefab

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions Assets/MediaPipeUnity/Samples/Scenes/Objectron/ObjectronConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ public class ObjectronConfig : ModalContents
{
private const string _CategoryPath = "Scroll View/Viewport/Contents/Category/Dropdown";
private const string _MaxNumObjectsPath = "Scroll View/Viewport/Contents/Max Num Objects/InputField";
private const string _MinDetectionConfidencePath = "Scroll View/Viewport/Contents/Min Detection Confidence/InputField";
private const string _MinTrackingConfidencePath = "Scroll View/Viewport/Contents/Min Tracking Confidence/InputField";
private const string _RunningModePath = "Scroll View/Viewport/Contents/Running Mode/Dropdown";
private const string _TimeoutMillisecPath = "Scroll View/Viewport/Contents/Timeout Millisec/InputField";

private ObjectronSolution _solution;
private Dropdown _categoryInput;
private InputField _maxNumObjectsInput;
private InputField _minDetectionConfidenceInput;
private InputField _minTrackingConfidenceInput;
private Dropdown _runningModeInput;
private InputField _timeoutMillisecInput;

Expand Down Expand Up @@ -53,6 +57,24 @@ public void UpdateMaxNumObjects()
}
}

public void SetMinDetectionConfidence()
{
if (float.TryParse(_minDetectionConfidenceInput.text, out var value))
{
_solution.minDetectionConfidence = value;
_isChanged = true;
}
}

public void SetMinTrackingConfidence()
{
if (float.TryParse(_minTrackingConfidenceInput.text, out var value))
{
_solution.minTrackingConfidence = value;
_isChanged = true;
}
}

public void SetTimeoutMillisec()
{
if (int.TryParse(_timeoutMillisecInput.text, out var value))
Expand All @@ -73,6 +95,8 @@ private void InitializeContents()
InitializeCategory();
InitializeRunningMode();
InitializeMaxNumObjects();
InitializeMinDetectionConfidence();
InitializeMinTrackingConfidence();
InitializeTimeoutMillisec();
}

Expand Down Expand Up @@ -102,6 +126,20 @@ private void InitializeMaxNumObjects()
_maxNumObjectsInput.onEndEdit.AddListener(delegate { UpdateMaxNumObjects(); });
}

private void InitializeMinDetectionConfidence()
{
_minDetectionConfidenceInput = gameObject.transform.Find(_MinDetectionConfidencePath).gameObject.GetComponent<InputField>();
_minDetectionConfidenceInput.text = _solution.minDetectionConfidence.ToString();
_minDetectionConfidenceInput.onValueChanged.AddListener(delegate { SetMinDetectionConfidence(); });
}

private void InitializeMinTrackingConfidence()
{
_minTrackingConfidenceInput = gameObject.transform.Find(_MinTrackingConfidencePath).gameObject.GetComponent<InputField>();
_minTrackingConfidenceInput.text = _solution.minTrackingConfidence.ToString();
_minTrackingConfidenceInput.onValueChanged.AddListener(delegate { SetMinTrackingConfidence(); });
}

private void InitializeRunningMode()
{
_runningModeInput = gameObject.transform.Find(_RunningModePath).gameObject.GetComponent<Dropdown>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ protected override Status ConfigureCalculatorGraph(CalculatorGraphConfig config)
var tensorsToDetectionsCalculators = cannonicalizedConfig.Node.Where((node) => node.Calculator == "TensorsToDetectionsCalculator").ToList();
var thresholdingCalculators = cannonicalizedConfig.Node.Where((node) => node.Calculator == "ThresholdingCalculator").ToList();

Debug.Log(tensorsToDetectionsCalculators.Count);
Debug.Log(thresholdingCalculators.Count);
foreach (var calculator in tensorsToDetectionsCalculators)
{
if (calculator.Options.HasExtension(TensorsToDetectionsCalculatorOptions.Extensions.Ext))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ public int maxNumObjects
set => graphRunner.maxNumObjects = value;
}

public float minDetectionConfidence
{
get => graphRunner.minDetectionConfidence;
set => graphRunner.minDetectionConfidence = value;
}

public float minTrackingConfidence
{
get => graphRunner.minTrackingConfidence;
set => graphRunner.minTrackingConfidence = value;
}

protected override void OnStartRun()
{
if (!runningMode.IsSynchronous())
Expand Down
17 changes: 13 additions & 4 deletions Assets/MediaPipeUnity/Samples/UI/Objects/Console/Console.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 8684544896258824048}
m_Father: {fileID: 3441857903058390880}
Expand Down Expand Up @@ -121,7 +122,7 @@ MonoBehaviour:
m_HandleRect: {fileID: 6817195836431992253}
m_Direction: 0
m_Value: 0
m_Size: 1
m_Size: 0.13688213
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
Expand Down Expand Up @@ -152,6 +153,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 7533351787154748278}
m_Father: {fileID: 4451514694375844671}
Expand Down Expand Up @@ -190,6 +192,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8684544896258824048}
m_RootOrder: 0
Expand Down Expand Up @@ -267,6 +270,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4558350226998646492}
- {fileID: 8128863749803209789}
Expand Down Expand Up @@ -390,6 +394,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2090578403611810331}
m_RootOrder: 0
Expand Down Expand Up @@ -466,6 +471,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2993541527497414948}
m_Father: {fileID: 3441857903058390880}
Expand Down Expand Up @@ -555,14 +561,15 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4558350226998646492}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -1135, y: 24}
m_AnchoredPosition: {x: 27.088018, y: 0.5727863}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 1}
--- !u!114 &4336319649774895248
MonoBehaviour:
Expand Down Expand Up @@ -630,6 +637,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 6817195836431992253}
m_Father: {fileID: 8128863749803209789}
Expand Down Expand Up @@ -669,6 +677,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2090578403611810331}
m_Father: {fileID: 3441857903058390880}
Expand Down Expand Up @@ -761,7 +770,7 @@ MonoBehaviour:
m_HandleRect: {fileID: 7533351787154748278}
m_Direction: 2
m_Value: 0
m_Size: 1
m_Size: 0.95952785
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: -0.7071068, w: 0.7071068}
m_LocalPosition: {x: 11, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2533287827353209602}
m_RootOrder: 0
Expand All @@ -52,6 +53,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
Expand Down Expand Up @@ -124,6 +126,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2533287826761229787}
m_Father: {fileID: 0}
Expand All @@ -140,6 +143,7 @@ LineRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 0
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
Expand All @@ -43,6 +44,7 @@ LineRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 0
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
Expand All @@ -43,6 +44,7 @@ LineRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 0
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 6140629650347037949}
- {fileID: 2711096740066365767}
Expand Down Expand Up @@ -119,12 +120,6 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e260d2f5fb90a790385fcb2d815b23a6, type: 3}
--- !u!4 &6140629650347037949 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 9215842904284589814, guid: e260d2f5fb90a790385fcb2d815b23a6,
type: 3}
m_PrefabInstance: {fileID: 3085711672548358667}
m_PrefabAsset: {fileID: 0}
--- !u!114 &6140629650347037948 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 9215842904284589815, guid: e260d2f5fb90a790385fcb2d815b23a6,
Expand All @@ -137,6 +132,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ae7563ab8645734c6b682cbbca130f6f, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &6140629650347037949 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 9215842904284589814, guid: e260d2f5fb90a790385fcb2d815b23a6,
type: 3}
m_PrefabInstance: {fileID: 3085711672548358667}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &3144842446730745438
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -221,12 +222,6 @@ PrefabInstance:
objectReference: {fileID: 2100000, guid: 0ea6416eaf3d1674291ec58a548378d8, type: 2}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 6f13a2b002175f9a0865766faacfed08, type: 3}
--- !u!4 &3526978146265096737 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 1970024004534580351, guid: 6f13a2b002175f9a0865766faacfed08,
type: 3}
m_PrefabInstance: {fileID: 3144842446730745438}
m_PrefabAsset: {fileID: 0}
--- !u!114 &508183085484426995 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 3218336891424051373, guid: 6f13a2b002175f9a0865766faacfed08,
Expand All @@ -239,6 +234,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 219b3f9aac8f8d18db8e85142b28db7d, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &3526978146265096737 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 1970024004534580351, guid: 6f13a2b002175f9a0865766faacfed08,
type: 3}
m_PrefabInstance: {fileID: 3144842446730745438}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &3442630378391270381
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
Expand All @@ -43,6 +44,7 @@ LineRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 0
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4070943725249276834}
- {fileID: 4070943725190493614}
Expand Down Expand Up @@ -248,12 +249,6 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 960d38eab3d401593b4ec2080d613df3, type: 3}
--- !u!4 &4070943725931072865 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 2533287827353209602, guid: 960d38eab3d401593b4ec2080d613df3,
type: 3}
m_PrefabInstance: {fileID: 1970024002895185507}
m_PrefabAsset: {fileID: 0}
--- !u!114 &4070943725931072864 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 2533287827353209603, guid: 960d38eab3d401593b4ec2080d613df3,
Expand All @@ -266,6 +261,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a793788ee98ea8ea3b28457e7dd7197d, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &4070943725931072865 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 2533287827353209602, guid: 960d38eab3d401593b4ec2080d613df3,
type: 3}
m_PrefabInstance: {fileID: 1970024002895185507}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &1970024003290734752
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down

0 comments on commit af86a8e

Please sign in to comment.