bugfix
This commit is contained in:
parent
fe78e3cbe8
commit
b3d8d06b12
|
@ -214149,7 +214149,7 @@ AnimationClip:
|
||||||
data:
|
data:
|
||||||
objectReferenceParameter: {fileID: 0}
|
objectReferenceParameter: {fileID: 0}
|
||||||
floatParameter: 0
|
floatParameter: 0
|
||||||
intParameter: 3
|
intParameter: 2
|
||||||
messageOptions: 0
|
messageOptions: 0
|
||||||
- time: 33.866665
|
- time: 33.866665
|
||||||
functionName: ActionStart
|
functionName: ActionStart
|
||||||
|
@ -214205,7 +214205,7 @@ AnimationClip:
|
||||||
data:
|
data:
|
||||||
objectReferenceParameter: {fileID: 0}
|
objectReferenceParameter: {fileID: 0}
|
||||||
floatParameter: 0
|
floatParameter: 0
|
||||||
intParameter: 3
|
intParameter: 2
|
||||||
messageOptions: 0
|
messageOptions: 0
|
||||||
- time: 66.333336
|
- time: 66.333336
|
||||||
functionName: FinishCurrentLevel
|
functionName: FinishCurrentLevel
|
||||||
|
|
|
@ -42,11 +42,13 @@ public class CVEstimator : Singleton<CVEstimator>
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
YogaManager.Instance.CurrentEstimator.Init();
|
YogaManager.Instance.CurrentEstimator.Init();
|
||||||
|
LogPrint.Log("Current Estimator Inited", PrintLevel.Important);
|
||||||
IsRunning = false;
|
//IsRunning = false;
|
||||||
_mainThread = new Thread(new ThreadStart(MainThread));
|
_mainThread = new Thread(new ThreadStart(MainThread));
|
||||||
_mainThread.Start();
|
_mainThread.Start();
|
||||||
IsInited = true;
|
IsInited = true;
|
||||||
|
|
||||||
|
LogPrint.Log($"Inited:{IsInited}", PrintLevel.Important);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainThread()
|
private void MainThread()
|
||||||
|
@ -75,9 +77,17 @@ public class CVEstimator : Singleton<CVEstimator>
|
||||||
LogPrint.Error($"Main Thread: {_mainThread.ThreadState}");
|
LogPrint.Error($"Main Thread: {_mainThread.ThreadState}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_estimateThread.Start();
|
|
||||||
LogPrint.Log("EstimateThread Start");
|
|
||||||
IsRunning = true;
|
IsRunning = true;
|
||||||
|
_estimateThread.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StopEstimation()
|
||||||
|
{
|
||||||
|
if (IsRunning)
|
||||||
|
{
|
||||||
|
IsRunning = false;
|
||||||
|
}
|
||||||
|
Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
@ -101,11 +111,11 @@ public class CVEstimator : Singleton<CVEstimator>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LogPrint.Log("Estimation Thread Running!IsRunning: " + IsRunning);
|
LogPrint.Log($"Estimation Thread Running!IsRunning:{IsRunning} {DateTime.Now}, {YogaManager.Instance.CurrentEstimator.GetType().FullName}", PrintLevel.Important);
|
||||||
Mat rgbaMat = YogaManager.Instance.RgbaMat;
|
Mat rgbaMat = YogaManager.Instance.RgbaMat;
|
||||||
if (rgbaMat == null)
|
if (rgbaMat == null)
|
||||||
{
|
{
|
||||||
LogPrint.Log("WebCamTexture is null. ");
|
LogPrint.Log("WebCamTexture is null. ", PrintLevel.Important);
|
||||||
LogPrint.Log("Re-Estimation.");
|
LogPrint.Log("Re-Estimation.");
|
||||||
continue; //重新检测
|
continue; //重新检测
|
||||||
}
|
}
|
||||||
|
@ -113,7 +123,7 @@ public class CVEstimator : Singleton<CVEstimator>
|
||||||
|
|
||||||
if (!YogaManager.Instance.CurrentEstimator.Esitmate(bgrMat, rgbaMat, out List<Point> points))
|
if (!YogaManager.Instance.CurrentEstimator.Esitmate(bgrMat, rgbaMat, out List<Point> points))
|
||||||
{
|
{
|
||||||
LogPrint.Log("Pose estimation failed. Re-Estimating.");
|
LogPrint.Log("Pose estimation failed. Re-Estimating.", PrintLevel.Important);
|
||||||
continue; //重新检测
|
continue; //重新检测
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +144,7 @@ public class CVEstimator : Singleton<CVEstimator>
|
||||||
{
|
{
|
||||||
LogPrint.Exception(e);
|
LogPrint.Exception(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
bgrMat.Dispose();
|
bgrMat.Dispose();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class HandsHold : PoseBase
|
||||||
}
|
}
|
||||||
var angle = Vector2.SignedAngle(Vector2.down, distance);
|
var angle = Vector2.SignedAngle(Vector2.down, distance);
|
||||||
LogPrint.Log($"Angle:{angle}", PrintLevel.Normal);
|
LogPrint.Log($"Angle:{angle}", PrintLevel.Normal);
|
||||||
if (MathF.Abs(angle) < 10)
|
if (MathF.Abs(angle) < 50 && distance.magnitude > 5f)
|
||||||
EventManager.Instance.Dispatch(YogaEventType.Action_Success); //方向不能偏移超过10°
|
EventManager.Instance.Dispatch(YogaEventType.Action_Success); //方向不能偏移超过10°
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class HandsUp : PoseBase
|
||||||
}
|
}
|
||||||
var angle = Vector2.SignedAngle(Vector2.up, distance);
|
var angle = Vector2.SignedAngle(Vector2.up, distance);
|
||||||
LogPrint.Log($"Angle:{angle}", PrintLevel.Normal);
|
LogPrint.Log($"Angle:{angle}", PrintLevel.Normal);
|
||||||
if (MathF.Abs(angle) < 10)
|
if (MathF.Abs(angle) < 50 && distance.magnitude > 5f)
|
||||||
EventManager.Instance.Dispatch(YogaEventType.Action_Success); //方向不能偏移超过10°
|
EventManager.Instance.Dispatch(YogaEventType.Action_Success); //方向不能偏移超过10°
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,10 +27,11 @@ public class HeadTurnDown : PoseBase
|
||||||
}
|
}
|
||||||
var angle = Vector2.SignedAngle(Vector2.down, distance);
|
var angle = Vector2.SignedAngle(Vector2.down, distance);
|
||||||
LogPrint.Log($"Angle:{angle}", PrintLevel.Normal);
|
LogPrint.Log($"Angle:{angle}", PrintLevel.Normal);
|
||||||
if (MathF.Abs(angle) < 10)
|
if (MathF.Abs(angle) < 50 && distance.magnitude > 5f)
|
||||||
EventManager.Instance.Dispatch(YogaEventType.Action_Success); //方向不能偏移超过10°
|
EventManager.Instance.Dispatch(YogaEventType.Action_Success); //方向不能偏移超过10°
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
LogPrint.Warning($"Angle:{angle}, magnitude:{distance.magnitude}", PrintLevel.Important);
|
||||||
EventManager.Instance.Dispatch(YogaEventType.Action_Fail);
|
EventManager.Instance.Dispatch(YogaEventType.Action_Fail);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class HeadTurnLeft : PoseBase
|
||||||
|
|
||||||
var angle = Vector2.SignedAngle(Vector2.left, distance);
|
var angle = Vector2.SignedAngle(Vector2.left, distance);
|
||||||
LogPrint.Log($"Angle:{angle}", PrintLevel.Normal);
|
LogPrint.Log($"Angle:{angle}", PrintLevel.Normal);
|
||||||
if (MathF.Abs(angle) < 10)
|
if (MathF.Abs(angle) < 50 && distance.magnitude > 5f)
|
||||||
EventManager.Instance.Dispatch(YogaEventType.Action_Success); //方向不能偏移超过10°
|
EventManager.Instance.Dispatch(YogaEventType.Action_Success); //方向不能偏移超过10°
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class HeadTurnRight : PoseBase
|
||||||
|
|
||||||
var angle = Vector2.SignedAngle(Vector2.right, distance);
|
var angle = Vector2.SignedAngle(Vector2.right, distance);
|
||||||
LogPrint.Log($"Angle:{angle}", PrintLevel.Normal);
|
LogPrint.Log($"Angle:{angle}", PrintLevel.Normal);
|
||||||
if (MathF.Abs(angle) < 10)
|
if (MathF.Abs(angle) < 50 && distance.magnitude > 5f)
|
||||||
EventManager.Instance.Dispatch(YogaEventType.Action_Success); //方向不能偏移超过10°
|
EventManager.Instance.Dispatch(YogaEventType.Action_Success); //方向不能偏移超过10°
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,10 +27,11 @@ public class HeadTurnUp : PoseBase
|
||||||
}
|
}
|
||||||
var angle = Vector2.SignedAngle(Vector2.up, distance);
|
var angle = Vector2.SignedAngle(Vector2.up, distance);
|
||||||
LogPrint.Log($"Angle:{angle}", PrintLevel.Normal);
|
LogPrint.Log($"Angle:{angle}", PrintLevel.Normal);
|
||||||
if (MathF.Abs(angle) < 10)
|
if (MathF.Abs(angle) < 50 && distance.magnitude > 5f)
|
||||||
EventManager.Instance.Dispatch(YogaEventType.Action_Success); //方向不能偏移超过10°
|
EventManager.Instance.Dispatch(YogaEventType.Action_Success); //方向不能偏移超过10°
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
LogPrint.Warning($"Angle:{angle}, magnitude:{distance.magnitude}", PrintLevel.Important);
|
||||||
EventManager.Instance.Dispatch(YogaEventType.Action_Fail);
|
EventManager.Instance.Dispatch(YogaEventType.Action_Fail);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,6 +171,7 @@ public class YogaManager : MonoSingleton<YogaManager>
|
||||||
//跳转到奖励界面
|
//跳转到奖励界面
|
||||||
UIManager.Instance.CloseCurrent(); //关闭当前界面并停止检测
|
UIManager.Instance.CloseCurrent(); //关闭当前界面并停止检测
|
||||||
UIManager.Instance.ShowPanel<ClearingSettlementUI>(false, CurrentSuccessActionCount, MaxActionCount);//args[0] = successCount args[1] = totalCount
|
UIManager.Instance.ShowPanel<ClearingSettlementUI>(false, CurrentSuccessActionCount, MaxActionCount);//args[0] = successCount args[1] = totalCount
|
||||||
|
_estimateKeyPointsCache.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ScoreUpdate()
|
public void ScoreUpdate()
|
||||||
|
@ -259,7 +260,7 @@ public class YogaManager : MonoSingleton<YogaManager>
|
||||||
{
|
{
|
||||||
AvatarAction actionType = (AvatarAction)args.FirstOrDefault();
|
AvatarAction actionType = (AvatarAction)args.FirstOrDefault();
|
||||||
bool isMoveBack = (bool)args.LastOrDefault();
|
bool isMoveBack = (bool)args.LastOrDefault();
|
||||||
LogPrint.Log($"PlayGuideVoice: {actionType}", PrintLevel.Normal);
|
LogPrint.Log($"PlayGuideVoice: {actionType}");
|
||||||
if (isMoveBack)
|
if (isMoveBack)
|
||||||
{
|
{
|
||||||
AudioManager.Instance.PlayCVInQueue(actionType.ToString());
|
AudioManager.Instance.PlayCVInQueue(actionType.ToString());
|
||||||
|
@ -299,7 +300,7 @@ public class YogaManager : MonoSingleton<YogaManager>
|
||||||
var startTime = ActionStartTime;
|
var startTime = ActionStartTime;
|
||||||
var endTime = DateTime.Now;
|
var endTime = DateTime.Now;
|
||||||
|
|
||||||
LogPrint.Log($"PlayGuideVoice: {actionType}", PrintLevel.Normal);
|
LogPrint.Log($"PlayGuideVoice: {actionType}");
|
||||||
if (isActionEnd)
|
if (isActionEnd)
|
||||||
{
|
{
|
||||||
AudioManager.Instance.PlayCVInQueue("End");
|
AudioManager.Instance.PlayCVInQueue("End");
|
||||||
|
|
|
@ -58,6 +58,7 @@ public partial class SROptions
|
||||||
{
|
{
|
||||||
var index = PlayerPrefs.GetInt("USBCameraIndex");
|
var index = PlayerPrefs.GetInt("USBCameraIndex");
|
||||||
PlayerPrefs.SetInt("USBCameraIndex", ++index);
|
PlayerPrefs.SetInt("USBCameraIndex", ++index);
|
||||||
|
Debug.LogWarning("USBCameraIndex" + index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
using OpenCVForUnity.CoreModule;
|
using OpenCVForUnity.CoreModule;
|
||||||
using OpenCVForUnity.ImgprocModule;
|
using OpenCVForUnity.ImgprocModule;
|
||||||
using OpenCVForUnity.UnityUtils;
|
using OpenCVForUnity.UnityUtils;
|
||||||
|
using Serenegiant.UVC;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
@ -14,8 +16,24 @@ namespace Yoga
|
||||||
protected Mat _bgrMat;
|
protected Mat _bgrMat;
|
||||||
protected bool _isOnCamCapture = false;
|
protected bool _isOnCamCapture = false;
|
||||||
protected Texture2D _displayTexture;
|
protected Texture2D _displayTexture;
|
||||||
|
private bool _isInited;
|
||||||
|
|
||||||
public bool IsOnCamCapture { get => _isOnCamCapture; internal set => _isOnCamCapture = value; }
|
public bool IsOnCamCapture { get => _isOnCamCapture; internal set => _isOnCamCapture = value; }
|
||||||
|
protected Texture2D DisplayTexture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_displayTexture == null)
|
||||||
|
{
|
||||||
|
_displayTexture = new Texture2D(UVCManager.Instance.DefaultWidth, UVCManager.Instance.DefaultHeight, TextureFormat.RGB24, false);
|
||||||
|
TargetDisplayer.texture = _displayTexture;
|
||||||
|
}
|
||||||
|
return _displayTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
set => _displayTexture = value;
|
||||||
|
}
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
@ -23,6 +41,7 @@ namespace Yoga
|
||||||
|
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
|
_isInited = true;
|
||||||
Utils.setDebugMode(true); //打印日志
|
Utils.setDebugMode(true); //打印日志
|
||||||
MatInitial();
|
MatInitial();
|
||||||
CVEstimator.Instance.Init();//姿态检测模型初始化
|
CVEstimator.Instance.Init();//姿态检测模型初始化
|
||||||
|
@ -99,7 +118,7 @@ namespace Yoga
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.matToTexture2D(img, _displayTexture);
|
Utils.matToTexture2D(img, DisplayTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
|
@ -128,6 +147,7 @@ namespace Yoga
|
||||||
if (_bgrMat != null)
|
if (_bgrMat != null)
|
||||||
_bgrMat.Dispose();
|
_bgrMat.Dispose();
|
||||||
CVEstimator.Instance.Dispose();
|
CVEstimator.Instance.Dispose();
|
||||||
|
_isInited = false;
|
||||||
}
|
}
|
||||||
protected virtual void EventRegist()
|
protected virtual void EventRegist()
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace Yoga
|
||||||
{
|
{
|
||||||
Mat img = null;
|
Mat img = null;
|
||||||
|
|
||||||
LogPrint.Log("USB Camera!", PrintLevel.Normal);
|
LogPrint.Log("USB Camera!");
|
||||||
if (UVCManager.Instance != null &&
|
if (UVCManager.Instance != null &&
|
||||||
UVCManager.Instance.GetAttachedDevices() != null && UVCManager.Instance.GetAttachedDevices().Count > 0)
|
UVCManager.Instance.GetAttachedDevices() != null && UVCManager.Instance.GetAttachedDevices().Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -41,19 +41,17 @@ namespace Yoga
|
||||||
for (int i = 0; i < devices.Count; i++)
|
for (int i = 0; i < devices.Count; i++)
|
||||||
{
|
{
|
||||||
UVCManager.CameraInfo device = devices[i];
|
UVCManager.CameraInfo device = devices[i];
|
||||||
LogPrint.Log($"id:{i},pid:{device.Pid},vid:{device.Vid},deviceName:{device.DeviceName}", PrintLevel.Normal);
|
LogPrint.Log($"id:{i},pid:{device.Pid},vid:{device.Vid},deviceName:{device.DeviceName}");
|
||||||
}
|
}
|
||||||
//var index = PlayerPrefs.GetInt("USBCameraIndex");
|
var index = PlayerPrefs.GetInt("USBCameraIndex");
|
||||||
//if (index >= devices.Count || index < 0) //数量超出时候改为默认第一个
|
if (index >= devices.Count || index < 0) //数量超出时候改为默认第一个
|
||||||
// index = 0;
|
index = 0;
|
||||||
|
LogPrint.Log($"current ID {index} name:" + devices[index].DeviceName);
|
||||||
var device1 = devices.Find(d => d.DeviceName.Equals("/dev/bus/usb/002/008"));
|
if (devices[index].previewTexture == null)
|
||||||
|
|
||||||
if (device1.previewTexture == null)
|
|
||||||
throw new Exception("No preview Texture found!");
|
throw new Exception("No preview Texture found!");
|
||||||
|
|
||||||
var tmpTex = new Texture2D(UVCManager.Instance.DefaultWidth, UVCManager.Instance.DefaultHeight);
|
var tmpTex = new Texture2D(UVCManager.Instance.DefaultWidth, UVCManager.Instance.DefaultHeight);
|
||||||
textureToFlipTexture2D(device1.previewTexture, tmpTex);
|
textureToFlipTexture2D(devices[index].previewTexture, tmpTex);
|
||||||
img = new Mat(UVCManager.Instance.DefaultHeight, UVCManager.Instance.DefaultWidth, CvType.CV_8UC3);
|
img = new Mat(UVCManager.Instance.DefaultHeight, UVCManager.Instance.DefaultWidth, CvType.CV_8UC3);
|
||||||
Utils.texture2DToMat(tmpTex, img);
|
Utils.texture2DToMat(tmpTex, img);
|
||||||
}
|
}
|
||||||
|
|
|
@ -498,6 +498,9 @@ namespace Serenegiant.UVC
|
||||||
{
|
{
|
||||||
//return FilterDevice(device.name);
|
//return FilterDevice(device.name);
|
||||||
|
|
||||||
|
if (device.name == "/dev/bus/usb/002/007")
|
||||||
|
return false;
|
||||||
|
|
||||||
if ((UVCDrawers == null) || (UVCDrawers.Length == 0))
|
if ((UVCDrawers == null) || (UVCDrawers.Length == 0))
|
||||||
{ // IUVCDrawerが割り当てられていないときはtrue(接続されたUVC機器を使用する)を返す
|
{ // IUVCDrawerが割り当てられていないときはtrue(接続されたUVC機器を使用する)を返す
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue