新增打印层级功能
This commit is contained in:
parent
541927fbdd
commit
2e0150979d
|
@ -540,7 +540,7 @@ namespace OpenCVCompact
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (webCamTexture == null)
|
if (webCamTexture == null)
|
||||||
Debug.Log("Cannot find camera device " + requestedDeviceName + ".");
|
LogPrint.Log("Cannot find camera device " + requestedDeviceName + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (webCamTexture == null)
|
if (webCamTexture == null)
|
||||||
|
@ -617,7 +617,7 @@ namespace OpenCVCompact
|
||||||
}
|
}
|
||||||
else if (webCamTexture.didUpdateThisFrame)
|
else if (webCamTexture.didUpdateThisFrame)
|
||||||
{
|
{
|
||||||
Debug.Log("WebCamTextureToMatHelper:: " + "devicename:" + webCamTexture.deviceName + " name:" + webCamTexture.name + " width:" + webCamTexture.width + " height:" + webCamTexture.height + " fps:" + webCamTexture.requestedFPS
|
LogPrint.Log("WebCamTextureToMatHelper:: " + "devicename:" + webCamTexture.deviceName + " name:" + webCamTexture.name + " width:" + webCamTexture.width + " height:" + webCamTexture.height + " fps:" + webCamTexture.requestedFPS
|
||||||
+ " videoRotationAngle:" + webCamTexture.videoRotationAngle + " videoVerticallyMirrored:" + webCamTexture.videoVerticallyMirrored + " isFrongFacing:" + webCamDevice.isFrontFacing);
|
+ " videoRotationAngle:" + webCamTexture.videoRotationAngle + " videoVerticallyMirrored:" + webCamTexture.videoVerticallyMirrored + " isFrongFacing:" + webCamDevice.isFrontFacing);
|
||||||
|
|
||||||
if (colors == null || colors.Length != webCamTexture.width * webCamTexture.height)
|
if (colors == null || colors.Length != webCamTexture.width * webCamTexture.height)
|
||||||
|
|
|
@ -70,13 +70,13 @@ namespace OpenCVCompact
|
||||||
|
|
||||||
if (!mat.isContinuous())
|
if (!mat.isContinuous())
|
||||||
{
|
{
|
||||||
Debug.LogError("mat.isContinuous() must be true.");
|
LogPrint.Error("mat.isContinuous() must be true.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (texture2D.mipmapCount != 1)
|
//if (texture2D.mipmapCount != 1)
|
||||||
//{
|
//{
|
||||||
// Debug.LogError("texture2D.mipmapCount must be 1.");
|
// LogPrint.Error("texture2D.mipmapCount must be 1.");
|
||||||
// return;
|
// return;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
@ -240,8 +240,8 @@ namespace OpenCVCompact
|
||||||
if (request.isError)
|
if (request.isError)
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
Debug.LogWarning(request.error);
|
LogPrint.Warning(request.error);
|
||||||
Debug.LogWarning(request.responseCode);
|
LogPrint.Warning(request.responseCode);
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ namespace OpenCVCompact
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(request.error))
|
if (!string.IsNullOrEmpty(request.error))
|
||||||
{
|
{
|
||||||
Debug.LogWarning(request.error);
|
LogPrint.Warning(request.error);
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,8 +401,8 @@ namespace OpenCVCompact
|
||||||
if (request.isError)
|
if (request.isError)
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
Debug.LogWarning(request.error);
|
LogPrint.Warning(request.error);
|
||||||
Debug.LogWarning(request.responseCode);
|
LogPrint.Warning(request.responseCode);
|
||||||
|
|
||||||
if (errorOccurred != null)
|
if (errorOccurred != null)
|
||||||
{
|
{
|
||||||
|
@ -440,7 +440,7 @@ namespace OpenCVCompact
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(request.error))
|
if (!string.IsNullOrEmpty(request.error))
|
||||||
{
|
{
|
||||||
Debug.LogWarning(request.error);
|
LogPrint.Warning(request.error);
|
||||||
|
|
||||||
if (errorOccurred != null)
|
if (errorOccurred != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class ClearingSettlementUI : UIPopupBase
|
||||||
|
|
||||||
if (pageData == null || pageData.Length < 2)
|
if (pageData == null || pageData.Length < 2)
|
||||||
{
|
{
|
||||||
Debug.LogError("ClearingSettlementUI page parameter is invalid");
|
LogPrint.Error("ClearingSettlementUI page parameter is invalid");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class CVEstimator : Singleton<CVEstimator>
|
||||||
{
|
{
|
||||||
if (!IsInited)
|
if (!IsInited)
|
||||||
{
|
{
|
||||||
Debug.LogError("CVEstimator is not inited. ");
|
LogPrint.Error("CVEstimator is not inited. ");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_estimateThread.Start();
|
_estimateThread.Start();
|
||||||
|
@ -93,15 +93,15 @@ public class CVEstimator : Singleton<CVEstimator>
|
||||||
Mat rgbaMat = YogaManager.Instance.RgbaMat;
|
Mat rgbaMat = YogaManager.Instance.RgbaMat;
|
||||||
if (rgbaMat == null)
|
if (rgbaMat == null)
|
||||||
{
|
{
|
||||||
//Debug.Log("WebCamTexture is null. ");
|
LogPrint.Log("WebCamTexture is null. ");
|
||||||
//Debug.Log("Re-Estimation.");
|
LogPrint.Log("Re-Estimation.");
|
||||||
continue; //重新检测
|
continue; //重新检测
|
||||||
}
|
}
|
||||||
Imgproc.cvtColor(rgbaMat, bgrMat, Imgproc.COLOR_RGBA2BGR);
|
Imgproc.cvtColor(rgbaMat, bgrMat, Imgproc.COLOR_RGBA2BGR);
|
||||||
|
|
||||||
if (!YogaManager.Instance.CurrentEstimator.Esitmate(bgrMat, rgbaMat, out List<Point> points))
|
if (!YogaManager.Instance.CurrentEstimator.Esitmate(bgrMat, rgbaMat, out List<Point> points))
|
||||||
{
|
{
|
||||||
Debug.LogWarning("Pose estimation failed. Re-Estimating.");
|
LogPrint.Warning("Pose estimation failed. Re-Estimating.");
|
||||||
continue; //重新检测
|
continue; //重新检测
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,14 +109,14 @@ public class CVEstimator : Singleton<CVEstimator>
|
||||||
YogaManager.Instance.CurrPersonPoints = points;
|
YogaManager.Instance.CurrPersonPoints = points;
|
||||||
|
|
||||||
//等待到下一个更新周期
|
//等待到下一个更新周期
|
||||||
if (DateTime.Now - startTime > _refreshRate)
|
//if (DateTime.Now - startTime > _refreshRate)
|
||||||
{
|
//{
|
||||||
startTime = DateTime.Now;
|
// startTime = DateTime.Now;
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
Thread.Sleep(_refreshRate - (DateTime.Now - startTime));
|
// Thread.Sleep(_refreshRate - (DateTime.Now - startTime));
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
bgrMat.Dispose();
|
bgrMat.Dispose();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class MediaPipeEstimator : Estimator
|
||||||
var personDetectModelPath = Utils.getFilePath(YogaConfig.MODEL_PATHS[ModelType.MediapipePersonDetect]);
|
var personDetectModelPath = Utils.getFilePath(YogaConfig.MODEL_PATHS[ModelType.MediapipePersonDetect]);
|
||||||
if (string.IsNullOrEmpty(personDetectModelPath))
|
if (string.IsNullOrEmpty(personDetectModelPath))
|
||||||
{
|
{
|
||||||
Debug.LogError(YogaConfig.MODEL_PATHS[ModelType.MediapipePersonDetect] + " is not loaded. Please read “StreamingAssets/OpenCVForUnity/dnn/setup_dnn_module.pdf” to make the necessary setup.");
|
LogPrint.Error(YogaConfig.MODEL_PATHS[ModelType.MediapipePersonDetect] + " is not loaded. Please read “StreamingAssets/OpenCVForUnity/dnn/setup_dnn_module.pdf” to make the necessary setup.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ public class MediaPipeEstimator : Estimator
|
||||||
var poseModelPath = Utils.getFilePath(YogaConfig.MODEL_PATHS[ModelType.MediapipePose]);
|
var poseModelPath = Utils.getFilePath(YogaConfig.MODEL_PATHS[ModelType.MediapipePose]);
|
||||||
if (string.IsNullOrEmpty(poseModelPath))
|
if (string.IsNullOrEmpty(poseModelPath))
|
||||||
{
|
{
|
||||||
Debug.LogError(YogaConfig.MODEL_PATHS[ModelType.MediapipePose] + " is not loaded. Please read “StreamingAssets/OpenCVForUnity/dnn/setup_dnn_module.pdf” to make the necessary setup.");
|
LogPrint.Error(YogaConfig.MODEL_PATHS[ModelType.MediapipePose] + " is not loaded. Please read “StreamingAssets/OpenCVForUnity/dnn/setup_dnn_module.pdf” to make the necessary setup.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class OpenPoseEsimater : Estimator
|
||||||
var modelFilePath = Utils.getFilePath(YogaConfig.MODEL_PATHS[ModelType.OpenPose]);
|
var modelFilePath = Utils.getFilePath(YogaConfig.MODEL_PATHS[ModelType.OpenPose]);
|
||||||
if (string.IsNullOrEmpty(modelFilePath))
|
if (string.IsNullOrEmpty(modelFilePath))
|
||||||
{
|
{
|
||||||
Debug.LogError("modelFilePath is empty. Please copy from “OpenCVForUnity/StreamingAssets/” to “Assets/StreamingAssets/” folder. ");
|
LogPrint.Error("modelFilePath is empty. Please copy from “OpenCVForUnity/StreamingAssets/” to “Assets/StreamingAssets/” folder. ");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class OpenPoseEsimater : Estimator
|
||||||
points = null;
|
points = null;
|
||||||
if (_objectDetector == null)
|
if (_objectDetector == null)
|
||||||
{
|
{
|
||||||
Debug.LogWarning("ObjectDetector is not ready. ");
|
LogPrint.Warning("ObjectDetector is not ready. ");
|
||||||
return false; //重新检测
|
return false; //重新检测
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ public class OpenPoseEsimater : Estimator
|
||||||
|
|
||||||
if (!hasValidObject) //没有检测到人体
|
if (!hasValidObject) //没有检测到人体
|
||||||
{
|
{
|
||||||
Debug.Log("No person block found. Re-Estimation.");
|
LogPrint.Log("No person block found. Re-Estimation.");
|
||||||
return false; //重新检测
|
return false; //重新检测
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ public class OpenPoseEsimater : Estimator
|
||||||
|
|
||||||
if (!YogaManager.Instance.ActionCheckPoints(points))
|
if (!YogaManager.Instance.ActionCheckPoints(points))
|
||||||
{
|
{
|
||||||
Debug.Log("ActionCheckPoints failed. Re-Estimation.");
|
LogPrint.Log("ActionCheckPoints failed. Re-Estimation.");
|
||||||
return false; //重新检测
|
return false; //重新检测
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class HandsUp : PoseBase
|
||||||
var angleR = Vector3.Angle(rArmVector, rArmBaseVector);
|
var angleR = Vector3.Angle(rArmVector, rArmBaseVector);
|
||||||
var angleL = Vector3.Angle(lArmVector, lArmBaseVector);
|
var angleL = Vector3.Angle(lArmVector, lArmBaseVector);
|
||||||
|
|
||||||
Debug.LogWarning("angleR:" + angleR + " angleL:" + angleL);
|
LogPrint.Warning("angleR:" + angleR + " angleL:" + angleL);
|
||||||
|
|
||||||
if (angleR < 10 || angleL < 10)
|
if (angleR < 10 || angleL < 10)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
using OpenCVForUnity.ImgprocModule;
|
using OpenCVForUnity.ImgprocModule;
|
||||||
using OpenCVForUnity.UnityUtils;
|
using OpenCVForUnity.UnityUtils;
|
||||||
using OpenCVForUnity.UnityUtils.Helper;
|
using OpenCVForUnity.UnityUtils.Helper;
|
||||||
using Serenegiant.UVC;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -10,24 +10,31 @@ using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
using Serenegiant.UVC;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Yoga
|
namespace Yoga
|
||||||
{
|
{
|
||||||
public class MotionCaptureManager : CameraCaptureManagerBase, IUVCDrawer
|
public class MotionCaptureManager : CameraCaptureManagerBase
|
||||||
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
, IUVCDrawer
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
public WebCamTextureToMatHelper _webCamTextureToMatHelper;
|
public WebCamTextureToMatHelper _webCamTextureToMatHelper;
|
||||||
private Texture2D texture;
|
|
||||||
|
|
||||||
public float SamplingRate = 0.3f;
|
public float SamplingRate = 0.3f;
|
||||||
public RawImage TargetDisplayer;
|
public RawImage TargetDisplayer;
|
||||||
|
|
||||||
private Mat _bgrMat;
|
|
||||||
|
|
||||||
private bool _isOnCamCapture = false;
|
private bool _isOnCamCapture = false;
|
||||||
|
private Mat _bgrMat;
|
||||||
|
private Texture2D _displayTexture;
|
||||||
|
private bool _isCorrectAction = false;
|
||||||
|
|
||||||
|
private Material _flipImg;
|
||||||
|
|
||||||
public bool IsOnCamCapture { get => _isOnCamCapture; internal set => _isOnCamCapture = value; }
|
public bool IsOnCamCapture { get => _isOnCamCapture; internal set => _isOnCamCapture = value; }
|
||||||
public WebCamTextureToMatHelper WebCamTextureToMatHelper => _webCamTextureToMatHelper;
|
public WebCamTextureToMatHelper WebCamTextureToMatHelper => _webCamTextureToMatHelper;
|
||||||
|
|
||||||
private bool _isCorrectAction = false;
|
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
EventManager.Instance.AddEventListener(YogaEventType.StartMotionCapture, OnStartMotionCapture);
|
EventManager.Instance.AddEventListener(YogaEventType.StartMotionCapture, OnStartMotionCapture);
|
||||||
|
@ -38,7 +45,6 @@ namespace Yoga
|
||||||
EventManager.Instance.AddEventListener(YogaEventType.ChangeCaptureCameraDevice, ChangeCaptureCameraDevice);
|
EventManager.Instance.AddEventListener(YogaEventType.ChangeCaptureCameraDevice, ChangeCaptureCameraDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
{
|
{
|
||||||
EventManager.Instance.RemoveEventListener(YogaEventType.StartMotionCapture, OnStartMotionCapture);
|
EventManager.Instance.RemoveEventListener(YogaEventType.StartMotionCapture, OnStartMotionCapture);
|
||||||
|
@ -58,17 +64,19 @@ namespace Yoga
|
||||||
// Avoids the front camera low light issue that occurs in only some Android devices (e.g. Google Pixel, Pixel2).
|
// Avoids the front camera low light issue that occurs in only some Android devices (e.g. Google Pixel, Pixel2).
|
||||||
_webCamTextureToMatHelper.avoidAndroidFrontCameraLowLightIssue = true;
|
_webCamTextureToMatHelper.avoidAndroidFrontCameraLowLightIssue = true;
|
||||||
#endif
|
#endif
|
||||||
|
//tool loading
|
||||||
|
_flipImg = Resources.Load<Material>("Materials/Unlit_FlipHorizontal");
|
||||||
|
|
||||||
_webCamTextureToMatHelper.Initialize();
|
_webCamTextureToMatHelper.Initialize();
|
||||||
|
|
||||||
Utils.setDebugMode(true); //打印日志
|
Utils.setDebugMode(true); //打印日志
|
||||||
|
|
||||||
GlobalData.Instance.CameraDeviceType = CameraDeviceType.USB; //test
|
GlobalData.Instance.CameraDeviceType = CameraDeviceType.USB; //test
|
||||||
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||||
var devices = UVCManager.Instance.GetAttachedDevices();
|
var devices = UVCManager.Instance.GetAttachedDevices();
|
||||||
|
#endif
|
||||||
CVEstimator.Instance.Init();//初始化姿态检测
|
CVEstimator.Instance.Init();//初始化姿态检测
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||||
#region UVC
|
#region UVC
|
||||||
public UVCFilter[] UVCFilters;
|
public UVCFilter[] UVCFilters;
|
||||||
private Texture SavedTexture;
|
private Texture SavedTexture;
|
||||||
|
@ -83,7 +91,7 @@ namespace Yoga
|
||||||
|
|
||||||
public void OnUVCDetachEvent(UVCManager manager, UVCDevice device)
|
public void OnUVCDetachEvent(UVCManager manager, UVCDevice device)
|
||||||
{
|
{
|
||||||
Debug.Log("OnUVCDetachEvent " + device);
|
LogPrint.Log("OnUVCDetachEvent " + device);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanDraw(UVCManager manager, UVCDevice device)
|
public bool CanDraw(UVCManager manager, UVCDevice device)
|
||||||
|
@ -104,7 +112,7 @@ namespace Yoga
|
||||||
private void HandleOnStartPreview(Texture tex)
|
private void HandleOnStartPreview(Texture tex)
|
||||||
{
|
{
|
||||||
SavedTexture = TargetDisplayer.texture;
|
SavedTexture = TargetDisplayer.texture;
|
||||||
TargetDisplayer.texture = texture;
|
TargetDisplayer.texture = _displayTexture;
|
||||||
}
|
}
|
||||||
private void HandleOnStopPreview()
|
private void HandleOnStopPreview()
|
||||||
{
|
{
|
||||||
|
@ -124,42 +132,44 @@ namespace Yoga
|
||||||
SavedTexture = null;
|
SavedTexture = null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public Texture2D HorizontalFlipTexture(Texture2D texture)
|
||||||
public static Texture2D HorizontalFlipTexture(Texture2D texture)
|
|
||||||
{
|
{
|
||||||
//得到图片的宽高
|
//得到图片的宽高
|
||||||
int width = texture.width;
|
Texture2D retVal = new Texture2D(texture.width, texture.height);
|
||||||
int height = texture.height;
|
RenderTexture tmp = RenderTexture.GetTemporary(texture.width, texture.height, 0, RenderTextureFormat.ARGB32);
|
||||||
|
Graphics.Blit(texture, tmp, _flipImg);
|
||||||
Texture2D flipTexture = new Texture2D(width, height);
|
RenderTexture.active = tmp;
|
||||||
|
retVal.ReadPixels(new UnityEngine.Rect(0, 0, texture.width, texture.height), 0, 0);
|
||||||
for (int i = 0; i < width; i++)
|
RenderTexture.ReleaseTemporary(tmp);
|
||||||
{
|
return retVal;
|
||||||
flipTexture.SetPixels(i, 0, 1, height, texture.GetPixels(width - i - 1, 0, 1, height));
|
|
||||||
}
|
|
||||||
flipTexture.Apply();
|
|
||||||
|
|
||||||
return flipTexture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Mat GetMat()
|
private Mat GetMat()
|
||||||
{
|
{
|
||||||
Mat img = null;
|
Mat img = null;
|
||||||
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||||
if (GlobalData.Instance.CameraDeviceType == CameraDeviceType.USB &&
|
if (GlobalData.Instance.CameraDeviceType == CameraDeviceType.USB &&
|
||||||
UVCManager.Instance != null &&
|
UVCManager.Instance != null &&
|
||||||
UVCManager.Instance.GetAttachedDevices() != null && UVCManager.Instance.GetAttachedDevices().Count > 0)
|
UVCManager.Instance.GetAttachedDevices() != null && UVCManager.Instance.GetAttachedDevices().Count > 0)
|
||||||
{
|
{
|
||||||
var devices = UVCManager.Instance.GetAttachedDevices();
|
var devices = UVCManager.Instance.GetAttachedDevices();
|
||||||
|
for (int i = 0; i < devices.Count; i++)
|
||||||
|
{
|
||||||
|
UVCManager.CameraInfo device = devices[i];
|
||||||
|
LogPrint.Error($"id:{i},pid:{device.Pid},vid:{device.Vid},deviceName:{device.DeviceName}");
|
||||||
|
}
|
||||||
var formatRefMat = _webCamTextureToMatHelper.GetMat();
|
var formatRefMat = _webCamTextureToMatHelper.GetMat();
|
||||||
var picCaptured = devices.FirstOrDefault().previewTexture;
|
var picCaptured = devices.FirstOrDefault().previewTexture;
|
||||||
Texture2D tmpTex = new Texture2D(picCaptured.width, picCaptured.height);
|
Texture2D tmpTex = new Texture2D(picCaptured.width, picCaptured.height);
|
||||||
Utils.textureToTexture2D(picCaptured, tmpTex);
|
Utils.textureToTexture2D(picCaptured, tmpTex);
|
||||||
tmpTex = HorizontalFlipTexture(tmpTex);//picCaptured texture水平反转
|
tmpTex = HorizontalFlipTexture(tmpTex);//picCaptured texture水平反转
|
||||||
img = new Mat(formatRefMat.rows(), formatRefMat.cols(), formatRefMat.type());
|
img = new Mat(formatRefMat.rows(), formatRefMat.cols(), formatRefMat.type());
|
||||||
Utils.texture2DToMat(tmpTex, img);
|
Utils.texture2DToMat(tmpTex, img);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (_webCamTextureToMatHelper.IsPlaying() && _webCamTextureToMatHelper.DidUpdateThisFrame())
|
if (_webCamTextureToMatHelper.IsPlaying() && _webCamTextureToMatHelper.DidUpdateThisFrame())
|
||||||
{
|
{
|
||||||
|
@ -217,7 +227,7 @@ namespace Yoga
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.matToTexture2D(img, texture);
|
Utils.matToTexture2D(img, _displayTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Event Func
|
#region Event Func
|
||||||
|
@ -247,7 +257,7 @@ namespace Yoga
|
||||||
|
|
||||||
if (startTime.AddMilliseconds(100) < DateTime.Now)
|
if (startTime.AddMilliseconds(100) < DateTime.Now)
|
||||||
{
|
{
|
||||||
Debug.LogError("GetActionBasePoint timeout");
|
LogPrint.Error("GetActionBasePoint timeout");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,7 +268,7 @@ namespace Yoga
|
||||||
var type = args.FirstOrDefault();
|
var type = args.FirstOrDefault();
|
||||||
if (type == null)
|
if (type == null)
|
||||||
{
|
{
|
||||||
Debug.LogError("EstimateAction type is null");
|
LogPrint.Error("EstimateAction type is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AvatarAction actionType = (AvatarAction)args.FirstOrDefault();
|
AvatarAction actionType = (AvatarAction)args.FirstOrDefault();
|
||||||
|
@ -276,8 +286,8 @@ namespace Yoga
|
||||||
}
|
}
|
||||||
if (startTime.AddMilliseconds(100) < DateTime.Now)
|
if (startTime.AddMilliseconds(100) < DateTime.Now)
|
||||||
{
|
{
|
||||||
Debug.LogWarning("请摆正姿势");
|
LogPrint.Warning("请摆正姿势");
|
||||||
Debug.LogWarning("EstimateAction timeout");
|
LogPrint.Warning("EstimateAction timeout");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,18 +332,18 @@ namespace Yoga
|
||||||
|
|
||||||
public void OnWebCamTextureToMatHelperInitialized()
|
public void OnWebCamTextureToMatHelperInitialized()
|
||||||
{
|
{
|
||||||
Debug.Log("OnWebCamTextureToMatHelperInitialized");
|
LogPrint.Log("OnWebCamTextureToMatHelperInitialized");
|
||||||
|
|
||||||
Mat webCamTextureMat = _webCamTextureToMatHelper.GetMat();
|
Mat webCamTextureMat = _webCamTextureToMatHelper.GetMat();
|
||||||
|
|
||||||
texture = new Texture2D(webCamTextureMat.cols(), webCamTextureMat.rows(), TextureFormat.RGB24, false);
|
_displayTexture = new Texture2D(webCamTextureMat.cols(), webCamTextureMat.rows(), TextureFormat.RGB24, false);
|
||||||
Utils.matToTexture2D(webCamTextureMat, texture);
|
Utils.matToTexture2D(webCamTextureMat, _displayTexture);
|
||||||
|
|
||||||
//gameObject.GetComponent<Renderer>().material.mainTexture = texture;
|
//gameObject.GetComponent<Renderer>().material.mainTexture = texture;
|
||||||
TargetDisplayer.texture = texture;
|
TargetDisplayer.texture = _displayTexture;
|
||||||
|
|
||||||
gameObject.transform.localScale = new Vector3(webCamTextureMat.cols() / 10, webCamTextureMat.rows() / 10, 1);
|
gameObject.transform.localScale = new Vector3(webCamTextureMat.cols() / 10, webCamTextureMat.rows() / 10, 1);
|
||||||
Debug.Log("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
|
LogPrint.Log("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
|
||||||
|
|
||||||
float width = webCamTextureMat.width();
|
float width = webCamTextureMat.width();
|
||||||
float height = webCamTextureMat.height();
|
float height = webCamTextureMat.height();
|
||||||
|
@ -355,21 +365,21 @@ namespace Yoga
|
||||||
//event call
|
//event call
|
||||||
public void OnWebCamTextureToMatHelperDisposed()
|
public void OnWebCamTextureToMatHelperDisposed()
|
||||||
{
|
{
|
||||||
Debug.Log("OnWebCamTextureToMatHelperDisposed");
|
LogPrint.Log("OnWebCamTextureToMatHelperDisposed");
|
||||||
|
|
||||||
if (_bgrMat != null)
|
if (_bgrMat != null)
|
||||||
_bgrMat.Dispose();
|
_bgrMat.Dispose();
|
||||||
|
|
||||||
if (texture != null)
|
if (_displayTexture != null)
|
||||||
{
|
{
|
||||||
Texture2D.Destroy(texture);
|
Texture2D.Destroy(_displayTexture);
|
||||||
texture = null;
|
_displayTexture = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnWebCamTextureToMatHelperErrorOccurred(WebCamTextureToMatHelper.ErrorCode errorCode)
|
public void OnWebCamTextureToMatHelperErrorOccurred(WebCamTextureToMatHelper.ErrorCode errorCode)
|
||||||
{
|
{
|
||||||
Debug.Log("OnWebCamTextureToMatHelperErrorOccurred " + errorCode);
|
LogPrint.Log("OnWebCamTextureToMatHelperErrorOccurred " + errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ScoreUpdate()
|
public void ScoreUpdate()
|
||||||
|
|
|
@ -107,7 +107,7 @@ namespace Yoga
|
||||||
// cheack
|
// cheack
|
||||||
if (image.channels() != 3)
|
if (image.channels() != 3)
|
||||||
{
|
{
|
||||||
Debug.Log("The input image must be in BGR format.");
|
LogPrint.Log("The input image must be in BGR format.");
|
||||||
return new Mat();
|
return new Mat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ namespace Yoga
|
||||||
sb.AppendLine(String.Format("box: {0:0} {1:0} {2:0} {3:0}", box[0], box[1], box[2], box[3]));
|
sb.AppendLine(String.Format("box: {0:0} {1:0} {2:0} {3:0}", box[0], box[1], box[2], box[3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log(sb);
|
LogPrint.Log(sb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ namespace Yoga
|
||||||
}
|
}
|
||||||
catch (System.Exception ex)
|
catch (System.Exception ex)
|
||||||
{
|
{
|
||||||
Debug.LogError(ex.Message);
|
LogPrint.Error(ex.Message);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
|
@ -11,7 +11,7 @@ public partial class SROptions
|
||||||
var devices = WebCamTexture.devices;
|
var devices = WebCamTexture.devices;
|
||||||
if (devices.Length == 0)
|
if (devices.Length == 0)
|
||||||
{
|
{
|
||||||
Debug.LogError("No camera detected!");
|
LogPrint.Error("No camera detected!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GlobalData.Instance.CameraIndex++;
|
GlobalData.Instance.CameraIndex++;
|
||||||
|
@ -29,14 +29,14 @@ public partial class SROptions
|
||||||
var devices = WebCamTexture.devices;
|
var devices = WebCamTexture.devices;
|
||||||
if (devices.Length == 0)
|
if (devices.Length == 0)
|
||||||
{
|
{
|
||||||
Debug.LogError("No camera detected!");
|
LogPrint.Error("No camera detected!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.LogWarning($"Current camera: {devices[GlobalData.Instance.CameraIndex].name}");
|
LogPrint.Warning($"Current camera: {devices[GlobalData.Instance.CameraIndex].name}");
|
||||||
foreach (var device in devices)
|
foreach (var device in devices)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"Camera: {device.name}");
|
LogPrint.Warning($"Camera: {device.name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class LogPrint
|
||||||
|
{
|
||||||
|
public static PrintLevel Level = PrintLevel.Normal;
|
||||||
|
public static void Log(object message, PrintLevel logLevel = PrintLevel.Details)
|
||||||
|
{
|
||||||
|
if (logLevel >= Level)
|
||||||
|
{
|
||||||
|
Debug.Log(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Log(object message, UnityEngine.Object sender, PrintLevel logLevel = PrintLevel.Details)
|
||||||
|
{
|
||||||
|
if (logLevel >= Level)
|
||||||
|
{
|
||||||
|
Debug.Log(message, sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Warning(object message, PrintLevel level = PrintLevel.Details)
|
||||||
|
{
|
||||||
|
if (level >= Level)
|
||||||
|
{
|
||||||
|
Debug.LogWarning(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Warning(object message, UnityEngine.Object sender, PrintLevel logLevel = PrintLevel.Details)
|
||||||
|
{
|
||||||
|
if (logLevel >= Level)
|
||||||
|
{
|
||||||
|
Debug.LogWarning(message, sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Error(object message, PrintLevel level = PrintLevel.Details)
|
||||||
|
{
|
||||||
|
if (level >= Level)
|
||||||
|
{
|
||||||
|
Debug.LogError(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Exception(Exception ex, PrintLevel level = PrintLevel.Details)
|
||||||
|
{
|
||||||
|
if (level >= Level)
|
||||||
|
{
|
||||||
|
Debug.LogException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public enum PrintLevel
|
||||||
|
{
|
||||||
|
Details = 0,
|
||||||
|
Normal = 10,
|
||||||
|
Important = 100,
|
||||||
|
Critical = 200,
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4e022dee4b9ec8b4facc2144669a1cf8
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -129,8 +129,8 @@ public class FaceDetectManager : MonoBehaviour
|
||||||
initFaceLndmrkRes = dnnUtils.InitFaceLandmarkDetect(dnnLndmrkDetectModelFilePath);
|
initFaceLndmrkRes = dnnUtils.InitFaceLandmarkDetect(dnnLndmrkDetectModelFilePath);
|
||||||
if (initFaceLndmrkRes == false)
|
if (initFaceLndmrkRes == false)
|
||||||
{
|
{
|
||||||
Debug.LogError(dnnLndmrkDetectModelFilePath + " file is not loaded.");
|
LogPrint.Error(dnnLndmrkDetectModelFilePath + " file is not loaded.");
|
||||||
Debug.LogError(dnnLndmrkDetectModelFilePath + " file is not existed on StreamingAssets Folder. Please copy from “Assets/FaceAnalyzer/StreamingAssets/” to “Assets/StreamingAssets/” folder.");
|
LogPrint.Error(dnnLndmrkDetectModelFilePath + " file is not existed on StreamingAssets Folder. Please copy from “Assets/FaceAnalyzer/StreamingAssets/” to “Assets/StreamingAssets/” folder.");
|
||||||
}
|
}
|
||||||
|
|
||||||
dnnUtils.InitHeadPoseEstimation();
|
dnnUtils.InitHeadPoseEstimation();
|
||||||
|
@ -138,34 +138,34 @@ public class FaceDetectManager : MonoBehaviour
|
||||||
int initFaceAttrRes = dnnUtils.InitFaceAttribNet_7(dnnFaceAttr7ModelFilePath);
|
int initFaceAttrRes = dnnUtils.InitFaceAttribNet_7(dnnFaceAttr7ModelFilePath);
|
||||||
if (initFaceAttrRes <= 0)
|
if (initFaceAttrRes <= 0)
|
||||||
{
|
{
|
||||||
Debug.LogError(dnnFaceAttr7ModelFilePath + " file is not loaded.");
|
LogPrint.Error(dnnFaceAttr7ModelFilePath + " file is not loaded.");
|
||||||
Debug.LogError(dnnFaceAttr7ModelFilePath + " file is not existed on StreamingAssets Folder. Please copy from “Assets/FaceAnalyzer/StreamingAssets/” to “Assets/StreamingAssets/” folder.");
|
LogPrint.Error(dnnFaceAttr7ModelFilePath + " file is not existed on StreamingAssets Folder. Please copy from “Assets/FaceAnalyzer/StreamingAssets/” to “Assets/StreamingAssets/” folder.");
|
||||||
}
|
}
|
||||||
|
|
||||||
int initFaceExpRes = dnnUtils.InitFaceExpressionNet_7(dnnFaceExpModelFilePath);
|
int initFaceExpRes = dnnUtils.InitFaceExpressionNet_7(dnnFaceExpModelFilePath);
|
||||||
if (initFaceExpRes <= 0)
|
if (initFaceExpRes <= 0)
|
||||||
{
|
{
|
||||||
Debug.LogError(dnnFaceExpModelFilePath + " file is not loaded.");
|
LogPrint.Error(dnnFaceExpModelFilePath + " file is not loaded.");
|
||||||
Debug.LogError(dnnFaceExpModelFilePath + " file is not existed on StreamingAssets Folder. Please copy from “Assets/FaceAnalyzer/StreamingAssets/” to “Assets/StreamingAssets/” folder.");
|
LogPrint.Error(dnnFaceExpModelFilePath + " file is not existed on StreamingAssets Folder. Please copy from “Assets/FaceAnalyzer/StreamingAssets/” to “Assets/StreamingAssets/” folder.");
|
||||||
}
|
}
|
||||||
|
|
||||||
int initMultiTinyFaceDetectRes = dnnUtils.InitMultiTinyFaceDetector(multiTinyFaceDetectModelFilePath);
|
int initMultiTinyFaceDetectRes = dnnUtils.InitMultiTinyFaceDetector(multiTinyFaceDetectModelFilePath);
|
||||||
if (initMultiTinyFaceDetectRes <= 0)
|
if (initMultiTinyFaceDetectRes <= 0)
|
||||||
{
|
{
|
||||||
Debug.LogError(multiTinyFaceDetectModelFilePath + " file is not loaded.");
|
LogPrint.Error(multiTinyFaceDetectModelFilePath + " file is not loaded.");
|
||||||
Debug.LogError(multiTinyFaceDetectModelFilePath + " file is not existed on StreamingAssets Folder. Please copy from “Assets/FaceAnalyzer/StreamingAssets/” to “Assets/StreamingAssets/” folder.");
|
LogPrint.Error(multiTinyFaceDetectModelFilePath + " file is not existed on StreamingAssets Folder. Please copy from “Assets/FaceAnalyzer/StreamingAssets/” to “Assets/StreamingAssets/” folder.");
|
||||||
}
|
}
|
||||||
|
|
||||||
int initYOLOV3DetectRes = dnnUtils.InitYOLOV3Detector(YOLOV3DetectModelFilePath, YOLOV3DetectParamFilePath);
|
int initYOLOV3DetectRes = dnnUtils.InitYOLOV3Detector(YOLOV3DetectModelFilePath, YOLOV3DetectParamFilePath);
|
||||||
if (initYOLOV3DetectRes == -1)
|
if (initYOLOV3DetectRes == -1)
|
||||||
{
|
{
|
||||||
Debug.LogError(YOLOV3DetectModelFilePath + " file is not loaded.");
|
LogPrint.Error(YOLOV3DetectModelFilePath + " file is not loaded.");
|
||||||
Debug.LogError(YOLOV3DetectModelFilePath + " file is not existed on StreamingAssets Folder. Please copy from “Assets/FaceAnalyzer/StreamingAssets/” to “Assets/StreamingAssets/” folder.");
|
LogPrint.Error(YOLOV3DetectModelFilePath + " file is not existed on StreamingAssets Folder. Please copy from “Assets/FaceAnalyzer/StreamingAssets/” to “Assets/StreamingAssets/” folder.");
|
||||||
}
|
}
|
||||||
else if (initYOLOV3DetectRes == -2)
|
else if (initYOLOV3DetectRes == -2)
|
||||||
{
|
{
|
||||||
Debug.LogError(YOLOV3DetectParamFilePath + " file is not loaded.");
|
LogPrint.Error(YOLOV3DetectParamFilePath + " file is not loaded.");
|
||||||
Debug.LogError(YOLOV3DetectParamFilePath + " file is not existed on StreamingAssets Folder. Please copy from “Assets/FaceAnalyzer/StreamingAssets/” to “Assets/StreamingAssets/” folder.");
|
LogPrint.Error(YOLOV3DetectParamFilePath + " file is not existed on StreamingAssets Folder. Please copy from “Assets/FaceAnalyzer/StreamingAssets/” to “Assets/StreamingAssets/” folder.");
|
||||||
}
|
}
|
||||||
|
|
||||||
dnnUtils.InitLabels_7();
|
dnnUtils.InitLabels_7();
|
||||||
|
@ -242,7 +242,7 @@ public class FaceDetectManager : MonoBehaviour
|
||||||
|
|
||||||
idx = idx + 1;
|
idx = idx + 1;
|
||||||
}
|
}
|
||||||
Debug.LogWarning(text.Substring(0, text.Length - 1));
|
LogPrint.Warning(text.Substring(0, text.Length - 1));
|
||||||
}
|
}
|
||||||
prob.Dispose();
|
prob.Dispose();
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ public class FaceDetectManager : MonoBehaviour
|
||||||
mat4Display = new Mat(webCamTextureMat.rows(), webCamTextureMat.cols(), CvType.CV_8UC4);
|
mat4Display = new Mat(webCamTextureMat.rows(), webCamTextureMat.cols(), CvType.CV_8UC4);
|
||||||
mat4DisplayTexture = new Mat(webCamTextureMat.rows(), webCamTextureMat.cols(), CvType.CV_8UC4);
|
mat4DisplayTexture = new Mat(webCamTextureMat.rows(), webCamTextureMat.cols(), CvType.CV_8UC4);
|
||||||
|
|
||||||
Debug.Log("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
|
LogPrint.Log("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
|
||||||
|
|
||||||
float width = webCamTextureMat.width();
|
float width = webCamTextureMat.width();
|
||||||
float height = webCamTextureMat.height();
|
float height = webCamTextureMat.height();
|
||||||
|
@ -279,18 +279,18 @@ public class FaceDetectManager : MonoBehaviour
|
||||||
dnnUtils.InitHeadPoseEstimationCameraInfo(webCamTextureMat.cols(), webCamTextureMat.rows());
|
dnnUtils.InitHeadPoseEstimationCameraInfo(webCamTextureMat.cols(), webCamTextureMat.rows());
|
||||||
|
|
||||||
webCamReady = true;
|
webCamReady = true;
|
||||||
Debug.Log("OnWebCamTextureToMatHelperInitialized");
|
LogPrint.Log("OnWebCamTextureToMatHelperInitialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void OnWebCamTextureToMatHelperDisposed()
|
public void OnWebCamTextureToMatHelperDisposed()
|
||||||
{
|
{
|
||||||
Debug.Log("OnWebCamTextureToMatHelperDisposed");
|
LogPrint.Log("OnWebCamTextureToMatHelperDisposed");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnWebCamTextureToMatHelperErrorOccurred(OpenCVCompact.WebCamTextureToMatHelper.ErrorCode errorCode)
|
public void OnWebCamTextureToMatHelperErrorOccurred(OpenCVCompact.WebCamTextureToMatHelper.ErrorCode errorCode)
|
||||||
{
|
{
|
||||||
Debug.Log("OnWebCamTextureToMatHelperErrorOccurred " + errorCode);
|
LogPrint.Log("OnWebCamTextureToMatHelperErrorOccurred " + errorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class GuideUI : UIPanelBase
|
||||||
_guide = GameObject.FindWithTag("Guide");
|
_guide = GameObject.FindWithTag("Guide");
|
||||||
if (_guide == null)
|
if (_guide == null)
|
||||||
{
|
{
|
||||||
Debug.LogError("Guide is null");
|
LogPrint.Error("Guide is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
_effectAnimator = transform.Find("Content").GetComponentInChildren<Animator>();
|
_effectAnimator = transform.Find("Content").GetComponentInChildren<Animator>();
|
||||||
|
@ -63,7 +63,7 @@ public class GuideUI : UIPanelBase
|
||||||
var animeType = args.FirstOrDefault();
|
var animeType = args.FirstOrDefault();
|
||||||
if (animeType == null)
|
if (animeType == null)
|
||||||
{
|
{
|
||||||
Debug.LogError("PlayAnimation animeType is null");
|
LogPrint.Error("PlayAnimation animeType is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public class GuideUI : UIPanelBase
|
||||||
//args[0] = successCount args[1] = excutedCount args[2] = totalCount
|
//args[0] = successCount args[1] = excutedCount args[2] = totalCount
|
||||||
if (args.Length < 3)
|
if (args.Length < 3)
|
||||||
{
|
{
|
||||||
Debug.LogError("UpdateSuccessCount args is not enough");
|
LogPrint.Error("UpdateSuccessCount args is not enough");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public class GuideUI : UIPanelBase
|
||||||
|
|
||||||
if (pageData[0] == null)
|
if (pageData[0] == null)
|
||||||
{
|
{
|
||||||
Debug.LogError("Guide is null");
|
LogPrint.Error("Guide is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ public class GuideUI : UIPanelBase
|
||||||
_totalSeconds = data.TotalSeconds;
|
_totalSeconds = data.TotalSeconds;
|
||||||
if (_totalSeconds == 0)
|
if (_totalSeconds == 0)
|
||||||
{
|
{
|
||||||
Debug.LogError("TotalSeconds is 0");
|
LogPrint.Error("TotalSeconds is 0");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ public static class YogaConfig
|
||||||
{
|
{
|
||||||
if (!BODY_PARTS.ContainsKey(tagName))
|
if (!BODY_PARTS.ContainsKey(tagName))
|
||||||
{
|
{
|
||||||
Debug.LogError("TagName is not exist");
|
LogPrint.Error("TagName is not exist");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return BODY_PARTS[tagName];
|
return BODY_PARTS[tagName];
|
||||||
|
@ -76,7 +76,7 @@ public static class YogaConfig
|
||||||
{
|
{
|
||||||
if (index < 0 || index >= BODY_PARTS.Count)
|
if (index < 0 || index >= BODY_PARTS.Count)
|
||||||
{
|
{
|
||||||
Debug.LogError("Index is not exist");
|
LogPrint.Error("Index is not exist");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return BODY_PARTS.FirstOrDefault(x => x.Value == index).Key;
|
return BODY_PARTS.FirstOrDefault(x => x.Value == index).Key;
|
||||||
|
@ -86,7 +86,7 @@ public static class YogaConfig
|
||||||
{
|
{
|
||||||
if (!BODY_PARTS.ContainsKey(tagName))
|
if (!BODY_PARTS.ContainsKey(tagName))
|
||||||
{
|
{
|
||||||
Debug.LogError("TagName is not exist");
|
LogPrint.Error("TagName is not exist");
|
||||||
return new Point(-1, -1);
|
return new Point(-1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ public static class YogaConfig
|
||||||
{
|
{
|
||||||
if (!BODY_PARTS.ContainsKey(tagName))
|
if (!BODY_PARTS.ContainsKey(tagName))
|
||||||
{
|
{
|
||||||
Debug.LogError("TagName is not exist");
|
LogPrint.Error("TagName is not exist");
|
||||||
return new Point(-1, -1);
|
return new Point(-1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ public static class YogaConfig
|
||||||
{
|
{
|
||||||
if (!BODY_PARTS.ContainsKey(tagName))
|
if (!BODY_PARTS.ContainsKey(tagName))
|
||||||
{
|
{
|
||||||
Debug.LogError("TagName is not exist");
|
LogPrint.Error("TagName is not exist");
|
||||||
return new Vector2(-1, -1);
|
return new Vector2(-1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ public static class YogaConfig
|
||||||
var point = points[BODY_PARTS[partName]];
|
var point = points[BODY_PARTS[partName]];
|
||||||
if (point == new Point(-1, -1))
|
if (point == new Point(-1, -1))
|
||||||
{
|
{
|
||||||
Debug.Log($"{partName}不在画面中");
|
LogPrint.Log($"{partName}不在画面中");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class YogaDataLoader
|
||||||
return data[index];
|
return data[index];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.LogError("YogaDataLoader.LoadData: index out of range");
|
LogPrint.Error("YogaDataLoader.LoadData: index out of range");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class YogaManager : MonoSingleton<YogaManager>
|
||||||
{
|
{
|
||||||
if (!_actions.ContainsKey(actionType))
|
if (!_actions.ContainsKey(actionType))
|
||||||
{
|
{
|
||||||
Debug.LogError("ActionType is not exist");
|
LogPrint.Error("ActionType is not exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var result = _actions[actionType].CheckPose(personPoints);
|
var result = _actions[actionType].CheckPose(personPoints);
|
||||||
|
@ -131,7 +131,7 @@ public class YogaManager : MonoSingleton<YogaManager>
|
||||||
{
|
{
|
||||||
if (points == null || points.Count == 0)
|
if (points == null || points.Count == 0)
|
||||||
{
|
{
|
||||||
//Debug.Log("ActionCheckPoints points is null");
|
//LogPrint.Log("ActionCheckPoints points is null");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,14 +139,14 @@ public class YogaManager : MonoSingleton<YogaManager>
|
||||||
//{
|
//{
|
||||||
// Point p = points[i];
|
// Point p = points[i];
|
||||||
// if (p != new Point(-1, -1))
|
// if (p != new Point(-1, -1))
|
||||||
// Debug.LogWarning($"ActionPoints p({i}): {i.tagName()}, value: {p.x},{p.y}");
|
// LogPrint.Warning($"ActionPoints p({i}): {i.tagName()}, value: {p.x},{p.y}");
|
||||||
//}
|
//}
|
||||||
|
|
||||||
foreach (var p in Action.MustPoints)
|
foreach (var p in Action.MustPoints)
|
||||||
{
|
{
|
||||||
if (!p.IsValid(points)) //有一个点不符合 返回false
|
if (!p.IsValid(points)) //有一个点不符合 返回false
|
||||||
{
|
{
|
||||||
//Debug.LogError($"ActionCheckPoints failed, {p} is not valid");
|
//LogPrint.Error($"ActionCheckPoints failed, {p} is not valid");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class CubeHandler : MonoBehaviour,
|
||||||
public void OnPointerClick(PointerEventData eventData)
|
public void OnPointerClick(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log("OnClick:");
|
LogPrint.Log("OnClick:");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ namespace Serenegiant {
|
||||||
{ // タッチしたとき
|
{ // タッチしたとき
|
||||||
touchEvent.state = TouchState.Began;
|
touchEvent.state = TouchState.Began;
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log("タッチした:");
|
LogPrint.Log("タッチした:");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ namespace Serenegiant {
|
||||||
{ // 離したとき
|
{ // 離したとき
|
||||||
touchEvent.state = TouchState.Ended;
|
touchEvent.state = TouchState.Ended;
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log("タッチした:");
|
LogPrint.Log("タッチした:");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ namespace Serenegiant {
|
||||||
{ // 押し続けているとき
|
{ // 押し続けているとき
|
||||||
touchEvent.state = TouchState.Moved;
|
touchEvent.state = TouchState.Moved;
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log("押し続けている");
|
LogPrint.Log("押し続けている");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace Serenegiant
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}Awake:");
|
LogPrint.Log($"{TAG}Awake:");
|
||||||
#endif
|
#endif
|
||||||
#if UNITY_ANDROID
|
#if UNITY_ANDROID
|
||||||
Input.backButtonLeavesApp = true; // 端末のバックキーでアプリを終了できるようにする
|
Input.backButtonLeavesApp = true; // 端末のバックキーでアプリを終了できるようにする
|
||||||
|
@ -78,7 +78,7 @@ namespace Serenegiant
|
||||||
public void OnStartEvent()
|
public void OnStartEvent()
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}OnStartEvent:");
|
LogPrint.Log($"{TAG}OnStartEvent:");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ namespace Serenegiant
|
||||||
public void OnResumeEvent()
|
public void OnResumeEvent()
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}OnResumeEvent:");
|
LogPrint.Log($"{TAG}OnResumeEvent:");
|
||||||
#endif
|
#endif
|
||||||
LifecycleEvent?.Invoke(true);
|
LifecycleEvent?.Invoke(true);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ namespace Serenegiant
|
||||||
public void OnPauseEvent()
|
public void OnPauseEvent()
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}OnPauseEvent:");
|
LogPrint.Log($"{TAG}OnPauseEvent:");
|
||||||
#endif
|
#endif
|
||||||
LifecycleEvent?.Invoke(false);
|
LifecycleEvent?.Invoke(false);
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ namespace Serenegiant
|
||||||
public void OnStopEvent()
|
public void OnStopEvent()
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}OnStopEvent:");
|
LogPrint.Log($"{TAG}OnStopEvent:");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ namespace Serenegiant
|
||||||
public void OnPermissionGrant()
|
public void OnPermissionGrant()
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}OnPermissionGrant:");
|
LogPrint.Log($"{TAG}OnPermissionGrant:");
|
||||||
#endif
|
#endif
|
||||||
grantResult = PermissionGrantResult.PERMISSION_GRANT;
|
grantResult = PermissionGrantResult.PERMISSION_GRANT;
|
||||||
isPermissionRequesting = false;
|
isPermissionRequesting = false;
|
||||||
|
@ -132,7 +132,7 @@ namespace Serenegiant
|
||||||
public void OnPermissionDeny()
|
public void OnPermissionDeny()
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}OnPermissionDeny:");
|
LogPrint.Log($"{TAG}OnPermissionDeny:");
|
||||||
#endif
|
#endif
|
||||||
grantResult = PermissionGrantResult.PERMISSION_DENY;
|
grantResult = PermissionGrantResult.PERMISSION_DENY;
|
||||||
isPermissionRequesting = false;
|
isPermissionRequesting = false;
|
||||||
|
@ -144,7 +144,7 @@ namespace Serenegiant
|
||||||
public void OnPermissionDenyAndNeverAskAgain()
|
public void OnPermissionDenyAndNeverAskAgain()
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}OnPermissionDenyAndNeverAskAgain:");
|
LogPrint.Log($"{TAG}OnPermissionDenyAndNeverAskAgain:");
|
||||||
#endif
|
#endif
|
||||||
grantResult = PermissionGrantResult.PERMISSION_DENY_AND_NEVER_ASK_AGAIN;
|
grantResult = PermissionGrantResult.PERMISSION_DENY_AND_NEVER_ASK_AGAIN;
|
||||||
isPermissionRequesting = false;
|
isPermissionRequesting = false;
|
||||||
|
@ -158,7 +158,7 @@ namespace Serenegiant
|
||||||
private void Initialize()
|
private void Initialize()
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}Initialize:{gameObject.name}");
|
LogPrint.Log($"{TAG}Initialize:{gameObject.name}");
|
||||||
#endif
|
#endif
|
||||||
using (AndroidJavaClass clazz = new AndroidJavaClass(FQCN_PLUGIN))
|
using (AndroidJavaClass clazz = new AndroidJavaClass(FQCN_PLUGIN))
|
||||||
{
|
{
|
||||||
|
@ -204,7 +204,7 @@ namespace Serenegiant
|
||||||
public static IEnumerator RequestPermission(string permission, OnPermission callback)
|
public static IEnumerator RequestPermission(string permission, OnPermission callback)
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}GrantPermission:{permission}");
|
LogPrint.Log($"{TAG}GrantPermission:{permission}");
|
||||||
#endif
|
#endif
|
||||||
if (!HasPermission(permission))
|
if (!HasPermission(permission))
|
||||||
{
|
{
|
||||||
|
@ -245,7 +245,7 @@ namespace Serenegiant
|
||||||
public static IEnumerator GrantPermission(string permission, OnPermission callback)
|
public static IEnumerator GrantPermission(string permission, OnPermission callback)
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}GrantPermission:{permission}");
|
LogPrint.Log($"{TAG}GrantPermission:{permission}");
|
||||||
#endif
|
#endif
|
||||||
if (!HasPermission(permission))
|
if (!HasPermission(permission))
|
||||||
{
|
{
|
||||||
|
@ -284,7 +284,7 @@ namespace Serenegiant
|
||||||
public static IEnumerator GrantCameraPermission(OnPermission callback)
|
public static IEnumerator GrantCameraPermission(OnPermission callback)
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}GrantCameraPermission:");
|
LogPrint.Log($"{TAG}GrantCameraPermission:");
|
||||||
#endif
|
#endif
|
||||||
if (CheckAndroidVersion(23))
|
if (CheckAndroidVersion(23))
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,7 +67,7 @@ namespace Serenegiant.UVC
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}Start:");
|
LogPrint.Log($"{TAG}Start:");
|
||||||
#endif
|
#endif
|
||||||
UpdateTarget();
|
UpdateTarget();
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ namespace Serenegiant.UVC
|
||||||
public bool OnUVCAttachEvent(UVCManager manager, UVCDevice device)
|
public bool OnUVCAttachEvent(UVCManager manager, UVCDevice device)
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}OnUVCAttachEvent:{device}");
|
LogPrint.Log($"{TAG}OnUVCAttachEvent:{device}");
|
||||||
#endif
|
#endif
|
||||||
// XXX 今の実装では基本的に全てのUVC機器を受け入れる
|
// XXX 今の実装では基本的に全てのUVC機器を受け入れる
|
||||||
// ただしTHETA SとTHETA VとTHETA Z1は映像を取得できないインターフェースがあるのでオミットする
|
// ただしTHETA SとTHETA VとTHETA Z1は映像を取得できないインターフェースがあるのでオミットする
|
||||||
|
@ -112,7 +112,7 @@ namespace Serenegiant.UVC
|
||||||
public void OnUVCDetachEvent(UVCManager manager, UVCDevice device)
|
public void OnUVCDetachEvent(UVCManager manager, UVCDevice device)
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}OnUVCDetachEvent:{device}");
|
LogPrint.Log($"{TAG}OnUVCDetachEvent:{device}");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,26 +126,26 @@ namespace Serenegiant.UVC
|
||||||
// public SupportedFormats.Size OnUVCSelectSize(UVCManager manager, UVCDevice device, SupportedFormats formats)
|
// public SupportedFormats.Size OnUVCSelectSize(UVCManager manager, UVCDevice device, SupportedFormats formats)
|
||||||
// {
|
// {
|
||||||
//#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
//#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
// Debug.Log($"{TAG}OnUVCSelectSize:{device}");
|
// LogPrint.Log($"{TAG}OnUVCSelectSize:{device}");
|
||||||
//#endif
|
//#endif
|
||||||
// if (device.IsTHETA_V || device.IsTHETA_Z1)
|
// if (device.IsTHETA_V || device.IsTHETA_Z1)
|
||||||
// {
|
// {
|
||||||
//#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
//#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
// Debug.Log($"{TAG}OnUVCSelectSize:THETA V/Z1");
|
// LogPrint.Log($"{TAG}OnUVCSelectSize:THETA V/Z1");
|
||||||
//#endif
|
//#endif
|
||||||
// return FindSize(formats, 3840, 1920);
|
// return FindSize(formats, 3840, 1920);
|
||||||
// }
|
// }
|
||||||
// else if (device.IsTHETA_S)
|
// else if (device.IsTHETA_S)
|
||||||
// {
|
// {
|
||||||
//#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
//#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
// Debug.Log($"{TAG}OnUVCSelectSize:THETA S");
|
// LogPrint.Log($"{TAG}OnUVCSelectSize:THETA S");
|
||||||
//#endif
|
//#endif
|
||||||
// return FindSize(formats, 1920, 1080);
|
// return FindSize(formats, 1920, 1080);
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
//#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
//#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
// Debug.Log($"{TAG}OnUVCSelectSize:other UVC device,{device}");
|
// LogPrint.Log($"{TAG}OnUVCSelectSize:other UVC device,{device}");
|
||||||
//#endif
|
//#endif
|
||||||
// return formats.Find(DefaultWidth, DefaultHeight);
|
// return formats.Find(DefaultWidth, DefaultHeight);
|
||||||
// }
|
// }
|
||||||
|
@ -172,7 +172,7 @@ namespace Serenegiant.UVC
|
||||||
public void OnUVCStartEvent(UVCManager manager, UVCDevice device, Texture tex)
|
public void OnUVCStartEvent(UVCManager manager, UVCDevice device, Texture tex)
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}OnUVCStartEvent:{device}");
|
LogPrint.Log($"{TAG}OnUVCStartEvent:{device}");
|
||||||
#endif
|
#endif
|
||||||
HandleOnStartPreview(tex);
|
HandleOnStartPreview(tex);
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ namespace Serenegiant.UVC
|
||||||
public void OnUVCStopEvent(UVCManager manager, UVCDevice device)
|
public void OnUVCStopEvent(UVCManager manager, UVCDevice device)
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}OnUVCStopEvent:{device}");
|
LogPrint.Log($"{TAG}OnUVCStopEvent:{device}");
|
||||||
#endif
|
#endif
|
||||||
HandleOnStopPreview();
|
HandleOnStopPreview();
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ namespace Serenegiant.UVC
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}UpdateTarget:material={material}");
|
LogPrint.Log($"{TAG}UpdateTarget:material={material}");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
@ -313,7 +313,7 @@ namespace Serenegiant.UVC
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Debug.Log($"{TAG}RestoreTexture:Exception cought");
|
LogPrint.Log($"{TAG}RestoreTexture:Exception cought");
|
||||||
}
|
}
|
||||||
SavedTextures[i] = null;
|
SavedTextures[i] = null;
|
||||||
quaternions[i] = Quaternion.identity;
|
quaternions[i] = Quaternion.identity;
|
||||||
|
@ -335,7 +335,7 @@ namespace Serenegiant.UVC
|
||||||
private void HandleOnStartPreview(Texture tex)
|
private void HandleOnStartPreview(Texture tex)
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}HandleOnStartPreview:({tex})");
|
LogPrint.Log($"{TAG}HandleOnStartPreview:({tex})");
|
||||||
#endif
|
#endif
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var target in TargetMaterials)
|
foreach (var target in TargetMaterials)
|
||||||
|
@ -343,7 +343,7 @@ namespace Serenegiant.UVC
|
||||||
if (target is Material)
|
if (target is Material)
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}HandleOnStartPreview:assign Texture to Material({target})");
|
LogPrint.Log($"{TAG}HandleOnStartPreview:assign Texture to Material({target})");
|
||||||
#endif
|
#endif
|
||||||
SavedTextures[i++] = (target as Material).mainTexture;
|
SavedTextures[i++] = (target as Material).mainTexture;
|
||||||
(target as Material).mainTexture = tex;
|
(target as Material).mainTexture = tex;
|
||||||
|
@ -351,7 +351,7 @@ namespace Serenegiant.UVC
|
||||||
else if (target is RawImage)
|
else if (target is RawImage)
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}HandleOnStartPreview:assign Texture to RawImage({target})");
|
LogPrint.Log($"{TAG}HandleOnStartPreview:assign Texture to RawImage({target})");
|
||||||
#endif
|
#endif
|
||||||
SavedTextures[i++] = (target as RawImage).texture;
|
SavedTextures[i++] = (target as RawImage).texture;
|
||||||
(target as RawImage).texture = tex;
|
(target as RawImage).texture = tex;
|
||||||
|
@ -365,12 +365,12 @@ namespace Serenegiant.UVC
|
||||||
private void HandleOnStopPreview()
|
private void HandleOnStopPreview()
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}HandleOnStopPreview:");
|
LogPrint.Log($"{TAG}HandleOnStopPreview:");
|
||||||
#endif
|
#endif
|
||||||
// 描画先のテクスチャをもとに戻す
|
// 描画先のテクスチャをもとに戻す
|
||||||
RestoreTexture();
|
RestoreTexture();
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}HandleOnStopPreview:finished");
|
LogPrint.Log($"{TAG}HandleOnStopPreview:finished");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ namespace Serenegiant.UVC
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}Match({device}):result={result}");
|
LogPrint.Log($"{TAG}Match({device}):result={result}");
|
||||||
#endif
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@ namespace Serenegiant.UVC
|
||||||
{
|
{
|
||||||
DontDestroyOnLoad(gameObject);
|
DontDestroyOnLoad(gameObject);
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}Start:");
|
LogPrint.Log($"{TAG}Start:");
|
||||||
#endif
|
#endif
|
||||||
mainContext = SynchronizationContext.Current;
|
mainContext = SynchronizationContext.Current;
|
||||||
callback = OnDeviceChangedCallbackManager.Add(this);
|
callback = OnDeviceChangedCallbackManager.Add(this);
|
||||||
|
@ -262,28 +262,28 @@ namespace Serenegiant.UVC
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
void OnApplicationFocus()
|
void OnApplicationFocus()
|
||||||
{
|
{
|
||||||
Debug.Log($"{TAG}OnApplicationFocus:");
|
LogPrint.Log($"{TAG}OnApplicationFocus:");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
void OnApplicationPause(bool pauseStatus)
|
void OnApplicationPause(bool pauseStatus)
|
||||||
{
|
{
|
||||||
Debug.Log($"{TAG}OnApplicationPause:{pauseStatus}");
|
LogPrint.Log($"{TAG}OnApplicationPause:{pauseStatus}");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
void OnApplicationQuits()
|
void OnApplicationQuits()
|
||||||
{
|
{
|
||||||
Debug.Log($"{TAG}OnApplicationQuits:");
|
LogPrint.Log($"{TAG}OnApplicationQuits:");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void OnDestroy()
|
void OnDestroy()
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}OnDestroy:");
|
LogPrint.Log($"{TAG}OnDestroy:");
|
||||||
#endif
|
#endif
|
||||||
StopAll();
|
StopAll();
|
||||||
OnDeviceChangedCallbackManager.Remove(this);
|
OnDeviceChangedCallbackManager.Remove(this);
|
||||||
|
@ -296,13 +296,13 @@ namespace Serenegiant.UVC
|
||||||
{
|
{
|
||||||
var id = UVCDevice.GetId(devicePtr);
|
var id = UVCDevice.GetId(devicePtr);
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}OnDeviceChangedInternal:id={id},attached={attached}");
|
LogPrint.Log($"{TAG}OnDeviceChangedInternal:id={id},attached={attached}");
|
||||||
#endif
|
#endif
|
||||||
if (attached)
|
if (attached)
|
||||||
{
|
{
|
||||||
UVCDevice device = new UVCDevice(devicePtr);
|
UVCDevice device = new UVCDevice(devicePtr);
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}OnDeviceChangedInternal:device={device.ToString()}");
|
LogPrint.Log($"{TAG}OnDeviceChangedInternal:device={device.ToString()}");
|
||||||
#endif
|
#endif
|
||||||
if (HandleOnAttachEvent(device))
|
if (HandleOnAttachEvent(device))
|
||||||
{
|
{
|
||||||
|
@ -407,7 +407,7 @@ namespace Serenegiant.UVC
|
||||||
// {
|
// {
|
||||||
// var size = (drawer as IUVCDrawer).OnUVCSelectSize(this, info.device, supportedVideoSize);
|
// var size = (drawer as IUVCDrawer).OnUVCSelectSize(this, info.device, supportedVideoSize);
|
||||||
//#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
//#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
// Debug.Log($"{TAG}StartPreview:selected={size}");
|
// LogPrint.Log($"{TAG}StartPreview:selected={size}");
|
||||||
//#endif
|
//#endif
|
||||||
// if (size != null)
|
// if (size != null)
|
||||||
// { // 一番最初に見つかった描画可能なIUVCDrawersがnull以外を返せばそれを使う
|
// { // 一番最初に見つかった描画可能なIUVCDrawersがnull以外を返せばそれを使う
|
||||||
|
@ -421,7 +421,7 @@ namespace Serenegiant.UVC
|
||||||
|
|
||||||
// FIXME 対応解像度の確認処理
|
// FIXME 対応解像度の確認処理
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}StartPreview:({width}x{height}),id={device.id}");
|
LogPrint.Log($"{TAG}StartPreview:({width}x{height}),id={device.id}");
|
||||||
#endif
|
#endif
|
||||||
int[] frameTypes = {
|
int[] frameTypes = {
|
||||||
PreferH264 ? FRAME_TYPE_H264 : FRAME_TYPE_MJPEG,
|
PreferH264 ? FRAME_TYPE_H264 : FRAME_TYPE_MJPEG,
|
||||||
|
@ -441,7 +441,7 @@ namespace Serenegiant.UVC
|
||||||
mainContext.Post(__ =>
|
mainContext.Post(__ =>
|
||||||
{ // テクスチャの生成はメインスレッドで行わないといけない
|
{ // テクスチャの生成はメインスレッドで行わないといけない
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}映像受け取り用テクスチャ生成:({width}x{height})");
|
LogPrint.Log($"{TAG}映像受け取り用テクスチャ生成:({width}x{height})");
|
||||||
#endif
|
#endif
|
||||||
Texture2D tex = new Texture2D(
|
Texture2D tex = new Texture2D(
|
||||||
width, height,
|
width, height,
|
||||||
|
@ -501,7 +501,7 @@ namespace Serenegiant.UVC
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool hasDrawer = false;
|
bool hasDrawer = false;
|
||||||
Debug.LogWarning("UVCDrawers: " + UVCDrawers.Length);
|
LogPrint.Warning("UVCDrawers: " + UVCDrawers.Length);
|
||||||
foreach (var drawer in UVCDrawers)
|
foreach (var drawer in UVCDrawers)
|
||||||
{
|
{
|
||||||
if (drawer is IUVCDrawer)
|
if (drawer is IUVCDrawer)
|
||||||
|
@ -525,7 +525,7 @@ namespace Serenegiant.UVC
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
bool FilterDevice(string deviceName)
|
bool FilterDevice(string deviceName)
|
||||||
{
|
{
|
||||||
Debug.Log(deviceName+" :"+ (deviceName == "/dev/bus/usb/002/008"));
|
LogPrint.Log(deviceName+" :"+ (deviceName == "/dev/bus/usb/002/008"));
|
||||||
return deviceName == "/dev/bus/usb/002/008";
|
return deviceName == "/dev/bus/usb/002/008";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,7 +554,7 @@ namespace Serenegiant.UVC
|
||||||
void HandleOnStartPreviewEvent(CameraInfo info)
|
void HandleOnStartPreviewEvent(CameraInfo info)
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}HandleOnStartPreviewEvent:({info})");
|
LogPrint.Log($"{TAG}HandleOnStartPreviewEvent:({info})");
|
||||||
#endif
|
#endif
|
||||||
if ((info != null) && info.IsPreviewing && (UVCDrawers != null))
|
if ((info != null) && info.IsPreviewing && (UVCDrawers != null))
|
||||||
{
|
{
|
||||||
|
@ -569,7 +569,7 @@ namespace Serenegiant.UVC
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}HandleOnStartPreviewEvent:No UVCDrawers");
|
LogPrint.Log($"{TAG}HandleOnStartPreviewEvent:No UVCDrawers");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -581,7 +581,7 @@ namespace Serenegiant.UVC
|
||||||
void HandleOnStopPreviewEvent(CameraInfo info)
|
void HandleOnStopPreviewEvent(CameraInfo info)
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}HandleOnStopPreviewEvent:({info})");
|
LogPrint.Log($"{TAG}HandleOnStopPreviewEvent:({info})");
|
||||||
#endif
|
#endif
|
||||||
if (UVCDrawers != null)
|
if (UVCDrawers != null)
|
||||||
{
|
{
|
||||||
|
@ -632,14 +632,14 @@ namespace Serenegiant.UVC
|
||||||
private IEnumerator Initialize()
|
private IEnumerator Initialize()
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}Initialize:");
|
LogPrint.Log($"{TAG}Initialize:");
|
||||||
#endif
|
#endif
|
||||||
if (AndroidUtils.CheckAndroidVersion(28))
|
if (AndroidUtils.CheckAndroidVersion(28))
|
||||||
{
|
{
|
||||||
yield return AndroidUtils.GrantCameraPermission((string permission, AndroidUtils.PermissionGrantResult result) =>
|
yield return AndroidUtils.GrantCameraPermission((string permission, AndroidUtils.PermissionGrantResult result) =>
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}OnPermission:{permission}={result}");
|
LogPrint.Log($"{TAG}OnPermission:{permission}={result}");
|
||||||
#endif
|
#endif
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
|
@ -673,7 +673,7 @@ namespace Serenegiant.UVC
|
||||||
private void InitPlugin()
|
private void InitPlugin()
|
||||||
{
|
{
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}InitPlugin:");
|
LogPrint.Log($"{TAG}InitPlugin:");
|
||||||
#endif
|
#endif
|
||||||
// IUVCDrawersが割り当てられているかどうかをチェック
|
// IUVCDrawersが割り当てられているかどうかをチェック
|
||||||
var hasDrawer = false;
|
var hasDrawer = false;
|
||||||
|
@ -692,7 +692,7 @@ namespace Serenegiant.UVC
|
||||||
{ // インスペクタでIUVCDrawerが設定されていないときは
|
{ // インスペクタでIUVCDrawerが設定されていないときは
|
||||||
// このスクリプトがaddされているゲームオブジェクトからの取得を試みる
|
// このスクリプトがaddされているゲームオブジェクトからの取得を試みる
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}InitPlugin:has no IUVCDrawer, try to get from gameObject");
|
LogPrint.Log($"{TAG}InitPlugin:has no IUVCDrawer, try to get from gameObject");
|
||||||
#endif
|
#endif
|
||||||
var objs = FindObjectsByType<CameraCaptureManagerBase>(FindObjectsSortMode.None);
|
var objs = FindObjectsByType<CameraCaptureManagerBase>(FindObjectsSortMode.None);
|
||||||
List<Component> drawers = new List<Component>();
|
List<Component> drawers = new List<Component>();
|
||||||
|
@ -701,7 +701,7 @@ namespace Serenegiant.UVC
|
||||||
drawers.AddRange(obj.GetComponents(typeof(IUVCDrawer)));
|
drawers.AddRange(obj.GetComponents(typeof(IUVCDrawer)));
|
||||||
|
|
||||||
}
|
}
|
||||||
Debug.LogWarning("drawers: " + drawers.Count);
|
LogPrint.Warning("drawers: " + drawers.Count);
|
||||||
if ((drawers != null) && (drawers.Count > 0))
|
if ((drawers != null) && (drawers.Count > 0))
|
||||||
{
|
{
|
||||||
UVCDrawers = new Component[drawers.Count];
|
UVCDrawers = new Component[drawers.Count];
|
||||||
|
@ -713,7 +713,7 @@ namespace Serenegiant.UVC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
#if (!NDEBUG && DEBUG && ENABLE_LOG)
|
||||||
Debug.Log($"{TAG}InitPlugin:num drawers={UVCDrawers.Length}");
|
LogPrint.Log($"{TAG}InitPlugin:num drawers={UVCDrawers.Length}");
|
||||||
#endif
|
#endif
|
||||||
// aandusbのDeviceDetectorを読み込み要求
|
// aandusbのDeviceDetectorを読み込み要求
|
||||||
using (AndroidJavaClass clazz = new AndroidJavaClass(FQCN_DETECTOR))
|
using (AndroidJavaClass clazz = new AndroidJavaClass(FQCN_DETECTOR))
|
||||||
|
@ -806,7 +806,7 @@ namespace Serenegiant.UVC
|
||||||
var manager = sManagers.ContainsKey(id) ? sManagers[id] : null;
|
var manager = sManagers.ContainsKey(id) ? sManagers[id] : null;
|
||||||
if (manager != null)
|
if (manager != null)
|
||||||
{
|
{
|
||||||
Debug.Log($"OnDeviceChanged{id} attached:{attached}");
|
LogPrint.Log($"OnDeviceChanged{id} attached:{attached}");
|
||||||
manager.OnDeviceChanged(devicePtr, attached);
|
manager.OnDeviceChanged(devicePtr, attached);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue