|
|
@@ -102,7 +102,7 @@ public partial class ScreenLocate : MonoBehaviour
|
|
|
// output的图像
|
|
|
// 图0是摄像机原图,图1是屏幕识别的全部可选线段,图2是识别出的屏幕画面,图3是识别出的屏幕四条边,图4是图2和图3的叠加,图5显示3种不同颜色的算法识别线段
|
|
|
public List<RawImage> outputRawImages;
|
|
|
- [NonSerialized] public Texture[] outputTexture2D;
|
|
|
+ [NonSerialized] public Texture[] outputTexture2D = new Texture[8];
|
|
|
public RawImage FullScreenImage;
|
|
|
|
|
|
public PixelCheaker ScreenPixelCheaker;
|
|
|
@@ -111,7 +111,7 @@ public partial class ScreenLocate : MonoBehaviour
|
|
|
public o0.Geometry2D.Vector<int> CameraSize { get; set; }
|
|
|
|
|
|
public Texture2D DebugScreenImage;
|
|
|
- public bool DebugOnEditorWin = false;
|
|
|
+ public bool DebugOnZIMDemo = false;
|
|
|
|
|
|
// private SynchronizationContext mainContext;
|
|
|
|
|
|
@@ -176,15 +176,23 @@ public partial class ScreenLocate : MonoBehaviour
|
|
|
{
|
|
|
var newTex = pixels.zimAutoLightSimple(width, height);
|
|
|
DebugTexture(7, newTex);
|
|
|
- Main.FullScreenImage.texture = newTex;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ Main.FullScreenImage.texture = newTex;
|
|
|
+ }
|
|
|
+ catch { }
|
|
|
}
|
|
|
|
|
|
static public void DebugTexture(int index, Texture texture)
|
|
|
{
|
|
|
- LateDestory(Main.outputRawImages[index].texture);
|
|
|
- Main.outputRawImages[index].texture = texture;
|
|
|
- if (Main.outputTexture2D != null)
|
|
|
- Main.outputTexture2D[index] = texture;
|
|
|
+ LateDestory(Main.outputTexture2D[index]);
|
|
|
+
|
|
|
+ Main.outputTexture2D[index] = texture;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ Main.outputRawImages[index].texture = texture;
|
|
|
+ }
|
|
|
+ catch { }
|
|
|
}
|
|
|
static void LateDestory(UnityEngine.Object o) => Main.StartCoroutine(Main.LateDestoryIEnum(o));
|
|
|
|
|
|
@@ -270,12 +278,11 @@ public partial class ScreenLocate : MonoBehaviour
|
|
|
{
|
|
|
//mainContext = SynchronizationContext.Current;
|
|
|
|
|
|
- outputTexture2D = new Texture[8];
|
|
|
canvas = transform.GetComponent<RectTransform>();
|
|
|
|
|
|
mode = Mode.InfraredLocate;
|
|
|
|
|
|
- if (DebugScreenImage && DebugOnEditorWin)
|
|
|
+ if (DebugScreenImage && DebugOnZIMDemo)
|
|
|
{
|
|
|
screenIdentification = new o0.Project.ScreenIdentification();
|
|
|
screenIdentification.LocateScreen();
|
|
|
@@ -300,7 +307,7 @@ public partial class ScreenLocate : MonoBehaviour
|
|
|
|
|
|
IEnumerator LateDestoryIEnum(UnityEngine.Object o)
|
|
|
{
|
|
|
- while (true)
|
|
|
+ if (o)
|
|
|
{
|
|
|
yield return new WaitForEndOfFrame();
|
|
|
Destroy(o);
|
|
|
@@ -423,8 +430,7 @@ public partial class ScreenLocate : MonoBehaviour
|
|
|
Debug.LogError("[ScreenLocate] RefreshCameraSize 屏幕size改变,存在NaN值,重新校准:" + PrintVector2List(quadUnityVectorList));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if (DebugOnEditorWin)
|
|
|
+ if (DebugOnZIMDemo)
|
|
|
Main.ShowScreen(Main.ScreenQuad, screenIdentification.Screen.QuadInCamera);
|
|
|
|
|
|
}
|
|
|
@@ -463,7 +469,7 @@ public partial class ScreenLocate : MonoBehaviour
|
|
|
CreateUVCTexture2DIfNeeded((int)getUVCCameraInfoSize.x, (int)getUVCCameraInfoSize.y);
|
|
|
if (!screenIdentification.Update(mUVCTexture2D))
|
|
|
{
|
|
|
- CameraSize = new o0.Geometry2D.Vector<int>((int)getUVCCameraInfoSize.x, (int)getUVCCameraInfoSize.y);
|
|
|
+ CameraSize = new o0.Geometry2D.Vector<int>(mUVCTexture2D.width, mUVCTexture2D.height);
|
|
|
var pixels = mUVCTexture2D.GetPixels(); // 从左往右、从下往上
|
|
|
|
|
|
AutoLightPixels(pixels, CameraSize.x, CameraSize.y);
|
|
|
@@ -588,7 +594,7 @@ public partial class ScreenLocate : MonoBehaviour
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- else if (mode == Mode.ScreenMap && DebugOnEditorWin)
|
|
|
+ else if (mode == Mode.ScreenMap && DebugOnZIMDemo)
|
|
|
{
|
|
|
for (int i = 0; i < infraredSpotBuffer.Length; i++)
|
|
|
{
|
|
|
@@ -739,7 +745,7 @@ public partial class ScreenLocate : MonoBehaviour
|
|
|
Vector2 _HighResolution = mUVCCameraInfo.CurrentCalibrationResolution; //最高的分辨率
|
|
|
Resize((int)_HighResolution.x, (int)_HighResolution.y);
|
|
|
|
|
|
- if (DebugOnEditorWin)
|
|
|
+ if (DebugOnZIMDemo)
|
|
|
screenIdentification.LocateScreen();
|
|
|
|
|
|
//CreateUVCTexture2DIfNeeded();
|
|
|
@@ -906,7 +912,7 @@ public partial class ScreenLocate : MonoBehaviour
|
|
|
ScreenQuadObject.gameObject.SetActive(true);
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
{
|
|
|
- if (DebugOnEditorWin)
|
|
|
+ if (DebugOnZIMDemo)
|
|
|
{
|
|
|
RectTransform t = ScreenQuadObject.GetChild(i) as RectTransform;
|
|
|
t.anchoredPosition = screen.Quad[i].pixelToLocalPosition_AnchorCenter(screen.CameraSize, ScreenQuadObject.rect);
|
|
|
@@ -918,7 +924,7 @@ public partial class ScreenLocate : MonoBehaviour
|
|
|
{
|
|
|
SaveScreenLocateVectorList();
|
|
|
//SyncInfraredDemo();
|
|
|
- if (DebugOnEditorWin)
|
|
|
+ if (DebugOnZIMDemo)
|
|
|
SyncInfraredScreenPositioningView();
|
|
|
|
|
|
InfraredCameraHelper?.InvokeOnUVCPosUpdate(quadUnityVectorList);
|