|
|
@@ -11,6 +11,8 @@ using InfraredManager;
|
|
|
using Org.BouncyCastle.Asn1.Crmf;
|
|
|
using ZIM.Unity;
|
|
|
using o0.Project;
|
|
|
+using System;
|
|
|
+using o0.Num;
|
|
|
|
|
|
public class LinePosition
|
|
|
{
|
|
|
@@ -73,6 +75,8 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
|
|
|
[SerializeField] Color normalTextColor = Color.black;
|
|
|
[SerializeField] Color highlightedTextColor = Color.white;
|
|
|
|
|
|
+ [SerializeField] Text QuadInfo;
|
|
|
+
|
|
|
bool doLocateAuto;
|
|
|
|
|
|
int DefaultResolutionIndex;
|
|
|
@@ -99,29 +103,20 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
|
|
|
//手动不高亮
|
|
|
//ResetButton(btnHandMovement);
|
|
|
|
|
|
- //quadUnityVectorList.Clear();
|
|
|
- //quadUnityVectorList.Add(new Vector2(16.39f, 35.91f));
|
|
|
- //quadUnityVectorList.Add(new Vector2(233.35f, 51.08f));
|
|
|
- //quadUnityVectorList.Add(new Vector2(94.15f, 219.11f));
|
|
|
- //quadUnityVectorList.Add(new Vector2(243.12f, 237.40f));
|
|
|
- Debug.Log("quadUnityVectorList count:" + ScreenLocate.quadUnityVectorList.Count);
|
|
|
- if (ScreenLocate.quadUnityVectorList.Count == 0)
|
|
|
- {
|
|
|
- Debug.Log("GetLocalPos");
|
|
|
- GetLocalPos();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Vector2 texSize = ScreenLocate.Main.getUVCCameraInfoSize;
|
|
|
- Debug.Log("texSize:" + texSize + " = " + canvasRectTransform.rect);
|
|
|
- //自动识别时候四个点
|
|
|
- SyncQuadUnityVectorListToPos();
|
|
|
- //pos1.anchoredPosition = ScreenLocate.quadUnityVectorList[0].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
- //pos2.anchoredPosition = ScreenLocate.quadUnityVectorList[1].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
- //pos4.anchoredPosition = ScreenLocate.quadUnityVectorList[2].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
- //pos3.anchoredPosition = ScreenLocate.quadUnityVectorList[3].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
- }
|
|
|
-
|
|
|
+ Debug.Log("GetDefalutPos"); // ZIM 改成加载默认(读数据或者手动数据)
|
|
|
+ GetDefalutPos();
|
|
|
+ //if (ScreenLocate.quadUnityVectorList.Count == 0)
|
|
|
+ //{
|
|
|
+ // Debug.Log("GetLocalPos");
|
|
|
+ // GetLocalPos();
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // Vector2 texSize = ScreenLocate.Main.getUVCCameraInfoSize;
|
|
|
+ // Debug.Log("texSize:" + texSize + " = " + canvasRectTransform.rect);
|
|
|
+ // //自动识别时候四个点
|
|
|
+ // SyncQuadUnityVectorListToPos();
|
|
|
+ //}
|
|
|
|
|
|
//记录操作的位置信息
|
|
|
oldLinePosition = new List<LinePosition>();
|
|
|
@@ -181,6 +176,11 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if (ScreenLocate.Main.DebugOnZIMDemo)
|
|
|
+ {
|
|
|
+ onHandMovement(); // 默认启用手动定位
|
|
|
+ GameObject.Find("DropdownQuad").GetComponent<Dropdown>().onValueChanged.AddListener(OnLoadQuadChanged);
|
|
|
+ }
|
|
|
|
|
|
//if (ScreenLocate.Main.getUVCTexture)
|
|
|
//{
|
|
|
@@ -526,6 +526,31 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // by zim, 加载数据
|
|
|
+ public void OnLoadQuadChanged(int value)
|
|
|
+ {
|
|
|
+ if (!doLocateAuto)
|
|
|
+ {
|
|
|
+ var quadTag = value switch
|
|
|
+ {
|
|
|
+ 0 => ScreenLocate.ScreenIdentificationTag.Manual,
|
|
|
+ 1 => ScreenLocate.ScreenIdentificationTag.Auto,
|
|
|
+ 2 => ScreenLocate.ScreenIdentificationTag.SemiAuto,
|
|
|
+ _ => ScreenLocate.ScreenIdentificationTag.Manual,
|
|
|
+ };
|
|
|
+
|
|
|
+ var quad = ScreenLocate.Main.GetScreenAfterLocate(quadTag);
|
|
|
+ if (quad != null)
|
|
|
+ {
|
|
|
+ AddOldLinePosition();
|
|
|
+ GetQuadPos(quad);
|
|
|
+ QuadInfo.text = "加载成功";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ QuadInfo.text = "加载失败";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@@ -607,8 +632,25 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
|
|
|
|
|
|
setPointsLocation(_locatePointList,pointsParent.gameObject,!bAuto);
|
|
|
if (!doLocateAuto) // 设置手动定位数据
|
|
|
+ {
|
|
|
setPointsManual(_locatePointList, GameObject.Find("WebCameraView/CameraImage0/ScreenQuad"));
|
|
|
|
|
|
+ var size = ScreenLocate.Main.getUVCCameraInfoSize;
|
|
|
+ var quad = new QuadrilateralInCamera(
|
|
|
+ new o0.Geometry2D.Float.Vector(_locatePointList[0].x * size.x, _locatePointList[0].y * size.y),
|
|
|
+ new o0.Geometry2D.Float.Vector(_locatePointList[1].x * size.x, _locatePointList[1].y * size.y),
|
|
|
+ new o0.Geometry2D.Float.Vector(_locatePointList[3].x * size.x, _locatePointList[3].y * size.y),
|
|
|
+ new o0.Geometry2D.Float.Vector(_locatePointList[2].x * size.x, _locatePointList[2].y * size.y),
|
|
|
+ size.o0Vector());
|
|
|
+
|
|
|
+ if (ScreenLocate.Main.ScreenIdentification!=null)
|
|
|
+ {
|
|
|
+ ScreenLocate.Main.ScreenIdentification.SetScreenQuad(quad);
|
|
|
+ ScreenLocate.Main.ScreenIdentification.QuadManual = quad;
|
|
|
+ Debug.Log($"[ScreenLocate] 记录手动数据: {quad}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//同步数据
|
|
|
ScreenLocate.quadUnityVectorList.Clear();
|
|
|
ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[0].x, _locatePointList[0].y));
|
|
|
@@ -663,6 +705,34 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // by zim
|
|
|
+ void GetDefalutPos()
|
|
|
+ {
|
|
|
+ if (ScreenLocate.Main.DebugOnZIMDemo)
|
|
|
+ {
|
|
|
+ var quad = ScreenLocate.Main.GetScreenAfterLocate(ScreenLocate.ScreenIdentificationTag.Manual);
|
|
|
+ if (quad != null)
|
|
|
+ GetQuadPos(quad);
|
|
|
+ else
|
|
|
+ GetLocalPos();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ GetLocalPos();
|
|
|
+ }
|
|
|
+
|
|
|
+ void GetQuadPos(QuadrilateralInCamera quad)
|
|
|
+ {
|
|
|
+ var qPos1 = quad.Quad.A.pixelToLocalPosition_AnchorCenter(quad.CameraSize, Bg.rectTransform.rect);
|
|
|
+ var qPos2 = quad.Quad.B.pixelToLocalPosition_AnchorCenter(quad.CameraSize, Bg.rectTransform.rect);
|
|
|
+ var qPos4 = quad.Quad.C.pixelToLocalPosition_AnchorCenter(quad.CameraSize, Bg.rectTransform.rect);
|
|
|
+ var qPos3 = quad.Quad.D.pixelToLocalPosition_AnchorCenter(quad.CameraSize, Bg.rectTransform.rect);
|
|
|
+ pos1.anchoredPosition = qPos1;
|
|
|
+ pos2.anchoredPosition = qPos2;
|
|
|
+ pos3.anchoredPosition = qPos3;
|
|
|
+ pos4.anchoredPosition = qPos4;
|
|
|
+ SetRectanglePoints(linePosConversion(qPos1, qPos2, qPos3, qPos4));
|
|
|
+ }
|
|
|
+
|
|
|
void GetLocalPos()
|
|
|
{
|
|
|
string posListStr = PlayerPrefs.GetString("ScreenPositioningView", "");
|