-
-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: replace Solution with LegacySolutionRunner
- Loading branch information
Showing
15 changed files
with
256 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 0 additions & 131 deletions
131
Assets/MediaPipeUnity/Samples/Common/Scripts/ImageSourceSolution.cs
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
Assets/MediaPipeUnity/Samples/Common/Scripts/LegacySolutionRunner.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) 2023 homuler | ||
// | ||
// Use of this source code is governed by an MIT-style | ||
// license that can be found in the LICENSE file or at | ||
// https://opensource.org/licenses/MIT. | ||
|
||
using System.Collections; | ||
using UnityEngine; | ||
|
||
namespace Mediapipe.Unity.Sample | ||
{ | ||
public abstract class LegacySolutionRunner<TGraphRunner> : TaskApiRunner where TGraphRunner : GraphRunner | ||
{ | ||
[SerializeField] protected Screen screen; | ||
[SerializeField] protected TGraphRunner graphRunner; | ||
|
||
private Coroutine _coroutine; | ||
|
||
public RunningMode runningMode; | ||
|
||
public long timeoutMillisec | ||
{ | ||
get => graphRunner.timeoutMillisec; | ||
set => graphRunner.timeoutMillisec = value; | ||
} | ||
|
||
public override void Play() | ||
{ | ||
if (_coroutine != null) | ||
{ | ||
Stop(); | ||
} | ||
base.Play(); | ||
_coroutine = StartCoroutine(Run()); | ||
} | ||
|
||
public override void Pause() | ||
{ | ||
base.Pause(); | ||
ImageSourceProvider.ImageSource.Pause(); | ||
} | ||
|
||
public override void Resume() | ||
{ | ||
base.Resume(); | ||
var _ = StartCoroutine(ImageSourceProvider.ImageSource.Resume()); | ||
} | ||
|
||
public override void Stop() | ||
{ | ||
base.Stop(); | ||
StopCoroutine(_coroutine); | ||
ImageSourceProvider.ImageSource.Stop(); | ||
graphRunner.Stop(); | ||
} | ||
|
||
protected abstract IEnumerator Run(); | ||
|
||
protected static void SetupAnnotationController<T>(AnnotationController<T> annotationController, ImageSource imageSource, bool expectedToBeMirrored = false) where T : HierarchicalAnnotation | ||
{ | ||
annotationController.isMirrored = expectedToBeMirrored ^ imageSource.isHorizontallyFlipped ^ imageSource.isFrontFacing; | ||
annotationController.rotationAngle = imageSource.rotation.Reverse(); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ommon/Scripts/ImageSourceSolution.cs.meta → ...mmon/Scripts/LegacySolutionRunner.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 0 additions & 110 deletions
110
Assets/MediaPipeUnity/Samples/Common/Scripts/Solution.cs
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
Assets/MediaPipeUnity/Samples/Common/Scripts/Solution.cs.meta
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.