parent
43d9370d21
commit
dcd855a087
|
@ -130054,11 +130054,11 @@ AnimationClip:
|
|||
intParameter: 0
|
||||
messageOptions: 0
|
||||
- time: 23.4
|
||||
functionName: StartSampling
|
||||
functionName: EndSampling
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 2
|
||||
intParameter: 12
|
||||
messageOptions: 0
|
||||
- time: 23.9
|
||||
functionName: PlayCountDownEndSE
|
||||
|
|
|
@ -38,7 +38,7 @@ public class HoldPosition : PoseBase
|
|||
LogPrint.Warning($"angle: {angle}", PrintLevel.Normal);
|
||||
LogPrint.Log($"distance: {distance}, totalTimeSpan: {totalTimeSpan}", PrintLevel.Normal);
|
||||
|
||||
return (angle < 8 && (distance/ points.Count < 8f));
|
||||
return (angle < 8 && (distance/ points.Count < 12f));
|
||||
}
|
||||
|
||||
public override Vector2 GetBasicVectorDirection(List<Point> startPoint, List<Point> endPoint)
|
||||
|
|
|
@ -286,28 +286,30 @@ public class YogaManager : MonoSingleton<YogaManager>
|
|||
if (_baseNose == -Vector2.one)
|
||||
return;
|
||||
var angle = Mathf.Abs(Vector2.SignedAngle(Vector2.left, (nose - _baseNose)));
|
||||
_samplingYogaResult = _samplingYogaResult.GetValueOrDefault() && (angle < 90);
|
||||
_samplingYogaResult = _samplingYogaResult.GetValueOrDefault() && (angle < 90) && (nose - _baseNose).magnitude > 10;
|
||||
}
|
||||
else if (_lastAction == AvatarAction.HeadTurnRight)
|
||||
{
|
||||
if (_baseNose == -Vector2.one)
|
||||
return;
|
||||
var angle = Mathf.Abs(Vector2.SignedAngle(Vector2.right, (nose - _baseNose)));
|
||||
_samplingYogaResult = _samplingYogaResult.GetValueOrDefault() && (angle < 90);
|
||||
_samplingYogaResult = _samplingYogaResult.GetValueOrDefault() && (angle < 90) && (nose - _baseNose).magnitude > 10;
|
||||
}
|
||||
else if (_lastAction == AvatarAction.HeadTurnDown)
|
||||
{
|
||||
if (_baseNose == -Vector2.one)
|
||||
return;
|
||||
var angle = Mathf.Abs(Vector2.SignedAngle(Vector2.down, -(nose - _baseNose)));//坐标系起始点左上,取y轴位移时需取反
|
||||
_samplingYogaResult = _samplingYogaResult.GetValueOrDefault() && (angle < 90);
|
||||
|
||||
LogPrint.Warning($"angle:{angle}, magnitude:{(nose - _baseNose).magnitude}", PrintLevel.Normal);
|
||||
_samplingYogaResult = _samplingYogaResult.GetValueOrDefault() && (angle < 90) && (nose - _baseNose).magnitude > 10;
|
||||
}
|
||||
else if (_lastAction == AvatarAction.HeadTurnUp)
|
||||
{
|
||||
if (_baseNose == -Vector2.one)
|
||||
return;
|
||||
var angle = Mathf.Abs(Vector2.SignedAngle(Vector2.up, -(nose - _baseNose))); //坐标系起始点左上,取y轴位移时需取反
|
||||
_samplingYogaResult = _samplingYogaResult.GetValueOrDefault() && (angle < 90);
|
||||
_samplingYogaResult = _samplingYogaResult.GetValueOrDefault() && (angle < 90) && (nose - _baseNose).magnitude > 10;
|
||||
}
|
||||
else if (_lastAction == AvatarAction.LeftLateralHead)
|
||||
{
|
||||
|
|
|
@ -31,6 +31,9 @@ public class USBFaceDetectManager : FaceDetectManagerBase, IUVCDrawer
|
|||
|
||||
private void OnEnable()
|
||||
{
|
||||
//摄像头问题 需要反转
|
||||
GlobalData.Instance.IsFlip = true;
|
||||
|
||||
mat4Display = new Mat(UVCManager.Instance.DefaultWidth, UVCManager.Instance.DefaultHeight, CvType.CV_8UC4);
|
||||
mat4Process = new Mat(PositionRect[2] - PositionRect[0], PositionRect[3] - PositionRect[1], CvType.CV_8UC4);
|
||||
mat4DisplayTexture = new Mat(UVCManager.Instance.DefaultWidth, UVCManager.Instance.DefaultHeight, CvType.CV_8UC4);
|
||||
|
@ -44,6 +47,9 @@ public class USBFaceDetectManager : FaceDetectManagerBase, IUVCDrawer
|
|||
|
||||
private void OnDisable()
|
||||
{
|
||||
//摄像头问题,需要反转
|
||||
GlobalData.Instance.IsFlip = false;
|
||||
|
||||
Destroy(_videoTexture);
|
||||
Destroy(_cutTexture);
|
||||
_videoTexture = null;
|
||||
|
@ -93,7 +99,7 @@ public class USBFaceDetectManager : FaceDetectManagerBase, IUVCDrawer
|
|||
RenderTexture.active = prevRT;
|
||||
}
|
||||
|
||||
private void textureToTargetPosTexture2DFlipped(Texture texture, Texture2D texture2D)
|
||||
private void textureToTargetPosTexture2D(Texture texture, Texture2D texture2D, bool isFlip)
|
||||
{
|
||||
if (texture == null)
|
||||
throw new ArgumentNullException("texture");
|
||||
|
@ -110,7 +116,12 @@ public class USBFaceDetectManager : FaceDetectManagerBase, IUVCDrawer
|
|||
|
||||
RenderTexture prevRT = RenderTexture.active;
|
||||
RenderTexture tempRT = RenderTexture.GetTemporary(texture.width, texture.height, 0, RenderTextureFormat.ARGB32);
|
||||
Graphics.Blit(texture, tempRT, _flipImg);
|
||||
if (isFlip)
|
||||
Graphics.Blit(texture, tempRT, _flipImg);
|
||||
|
||||
else
|
||||
Graphics.Blit(texture, tempRT);
|
||||
|
||||
|
||||
RenderTexture.active = tempRT;
|
||||
texture2D.ReadPixels(new UnityEngine.Rect(PositionRect[0], PositionRect[1], PositionRect[2] - PositionRect[0], PositionRect[3] - PositionRect[1]), 0, 0, false);
|
||||
|
@ -134,8 +145,17 @@ public class USBFaceDetectManager : FaceDetectManagerBase, IUVCDrawer
|
|||
|
||||
var devices = UVCManager.Instance.GetAttachedDevices();
|
||||
|
||||
textureToFlipTexture2D(devices.FirstOrDefault().previewTexture, _videoTexture);
|
||||
textureToTargetPosTexture2DFlipped(devices.FirstOrDefault().previewTexture, _cutTexture);
|
||||
if (GlobalData.Instance.IsFlip)
|
||||
{
|
||||
textureToFlipTexture2D(devices.FirstOrDefault().previewTexture, _videoTexture);
|
||||
textureToTargetPosTexture2D(devices.FirstOrDefault().previewTexture, _cutTexture, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.textureToTexture2D(devices.FirstOrDefault().previewTexture, _videoTexture);
|
||||
textureToTargetPosTexture2D(devices.FirstOrDefault().previewTexture, _cutTexture, false);
|
||||
}
|
||||
|
||||
Utils.texture2DToMat(_videoTexture, mat4Display);
|
||||
Utils.texture2DToMat(_cutTexture, mat4Process);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public class RobotController : MonoBehaviour
|
|||
var result = YogaManager.Instance.SamplingResult;
|
||||
if (result != null && result == false)
|
||||
{
|
||||
AudioManager.Instance.PlayCVInQueue(action.ToString());
|
||||
//AudioManager.Instance.PlayCVInQueue(action.ToString());
|
||||
//AudioManager.Instance.PlayCVInQueue("And");
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue