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