Commit 708d3dee authored by BlackAngle233's avatar BlackAngle233
Browse files

update final design

parent 1444629e
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using System;
using System.IO;
using UnityEditor;
using UnityEngine;
namespace easyar
{
public class ImageTargetDataGenerator : EditorWindow
{
private GenerateType generateType;
private string outputPathDir;
private string imagePaths = "Try drop images here";
private Texture2D texture;
private float targetScale = 0.1f;
private string targetName = string.Empty;
enum GenerateType
{
Image,
ImageList,
Texture,
}
[MenuItem("EasyAR/Image Target Data")]
private static void OpenTheWindow()
{
var win = GetWindow(typeof(ImageTargetDataGenerator));
win.minSize = new Vector2(250, 400);
win.titleContent = new GUIContent("ImageTarget");
win.Show();
}
private void OnEnable()
{
if (!EasyARController.Initialized)
{
EasyARController.GlobalInitialization();
}
outputPathDir = Application.streamingAssetsPath;
}
private void OnGUI()
{
if (!EasyARController.Initialized || !string.IsNullOrEmpty(Engine.errorMessage()))
{
if (GUI.Button(new Rect(20, 20, position.width - 40, 30), "Apply License Key Change"))
{
Selection.SetActiveObjectWithContext(EasyARController.Settings, null);
EasyARController.GlobalInitialization();
}
var textStyle = new GUIStyle(EditorStyles.label);
textStyle.normal.textColor = Color.red;
EditorGUI.LabelField(new Rect(20, 60, position.width - 40, 20), Engine.errorMessage(), textStyle);
return;
}
if (generateType == GenerateType.Image || generateType == GenerateType.ImageList)
{
if (Event.current.type == EventType.DragUpdated)
{
foreach (var path in DragAndDrop.paths)
{
var ext = Path.GetExtension(path).ToLower();
if (ext == ".jpg" || ext == ".png" || ext == ".bmp")
{
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
break;
}
}
}
}
var yPosition = 20;
EditorGUI.LabelField(new Rect(20, yPosition, 100, 30), "Generate From");
generateType = (GenerateType)EditorGUI.EnumPopup(new Rect(120, yPosition, 100, 30), generateType);
yPosition += 30;
switch (generateType)
{
case GenerateType.Image:
if (Event.current.type == EventType.DragExited)
{
imagePaths = string.Empty;
foreach (var path in DragAndDrop.paths)
{
var ext = Path.GetExtension(path).ToLower();
if (ext == ".jpg" || ext == ".png" || ext == ".bmp")
{
imagePaths = path;
if (File.Exists(path))
{
targetName = GetNameFromPath(path);
}
break;
}
}
Repaint();
}
GUI.Label(new Rect(20, yPosition, 120, 20), "Image Path");
yPosition += 20;
imagePaths = EditorGUI.TextArea(new Rect(20, yPosition, position.width - 40, 30), imagePaths);
yPosition += 30 + 30;
if (string.IsNullOrEmpty(targetName))
{
foreach (var path in imagePaths.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{
if (File.Exists(path))
{
targetName = GetNameFromPath(path);
}
break;
}
}
targetName = EditorGUI.TextField(new Rect(20, yPosition, position.width - 40, 20), "Name:", targetName);
yPosition += 20;
targetScale = EditorGUI.FloatField(new Rect(20, yPosition, position.width - 40, 20), "Scale (m):", targetScale);
break;
case GenerateType.ImageList:
if (Event.current.type == EventType.DragExited)
{
imagePaths = string.Empty;
foreach (var path in DragAndDrop.paths)
{
var ext = Path.GetExtension(path).ToLower();
if (ext == ".jpg" || ext == ".png" || ext == ".bmp")
{
imagePaths += path + Environment.NewLine;
}
}
Repaint();
}
GUI.Label(new Rect(20, yPosition, 120, 20), "Image Paths");
yPosition += 20;
imagePaths = EditorGUI.TextArea(new Rect(20, yPosition, position.width - 40, 100), imagePaths);
yPosition += 100 + 30;
EditorGUI.LabelField(new Rect(20, yPosition, position.width - 40, 20), "Name: (Filename is Used)");
yPosition += 20;
targetScale = EditorGUI.FloatField(new Rect(20, yPosition, position.width - 40, 20), "Scale (m):", targetScale);
break;
case GenerateType.Texture:
GUI.Label(new Rect(20, yPosition, 120, 20), "Texture");
yPosition += 20;
texture = EditorGUI.ObjectField(new Rect(20, yPosition, 80, 80), texture, typeof(Texture2D), false) as Texture2D;
yPosition += 80 + 30;
if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(texture)))
{
targetName = GetNameFromPath(AssetDatabase.GetAssetPath(texture));
}
targetName = EditorGUI.TextField(new Rect(20, yPosition, position.width - 40, 20), "Name:", targetName);
yPosition += 20;
targetScale = EditorGUI.FloatField(new Rect(20, yPosition, position.width - 40, 20), "Scale (m):", targetScale);
break;
default:
break;
}
EditorGUI.LabelField(new Rect(20, position.height - 50 - 40 - 20, 160, 20), "Generate To");
outputPathDir = EditorGUI.TextArea(new Rect(20, position.height - 50 - 40, position.width - 40, 20), outputPathDir);
if (GUI.Button(new Rect(20, position.height - 50, position.width - 40, 30), "Generate"))
{
try
{
switch (generateType)
{
case GenerateType.Image:
foreach (var path in imagePaths.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{
CreateTargetFileByByteArray(File.ReadAllBytes(path), targetName);
break;
}
break;
case GenerateType.ImageList:
foreach (var path in imagePaths.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{
if (!File.Exists(path))
{
continue;
}
var ext = Path.GetExtension(path).ToLower();
if (ext == ".jpg" || ext == ".png" || ext == ".bmp")
{
CreateTargetFileByByteArray(File.ReadAllBytes(path), GetNameFromPath(path));
}
}
break;
case GenerateType.Texture:
var filePath = AssetDatabase.GetAssetPath(texture);
if (filePath.StartsWith("Assets/"))
{
filePath = filePath.Substring(6);
}
else
{
throw new Exception("invalid image file: " + filePath);
}
var texturePath = Application.dataPath + filePath;
CreateTargetFileByByteArray(File.ReadAllBytes(texturePath), targetName);
break;
default:
break;
}
}
catch (Exception e)
{
Debug.LogError(e.Message);
}
}
}
private string GetNameFromPath(string path)
{
var name = string.Empty;
try
{
name = Path.GetFileNameWithoutExtension(path);
}
catch (Exception)
{
}
if (name == null)
{
name = string.Empty;
}
return name;
}
private void CreateTargetFileByByteArray(byte[] data, string name)
{
using (Buffer buffer = Buffer.wrapByteArray(data))
{
var imageOptional = ImageHelper.decode(buffer);
if (imageOptional.OnNone)
{
throw new Exception("invalid image data");
}
using (var image = imageOptional.Value)
using (var param = new ImageTargetParameters())
{
var uid = Guid.NewGuid().ToString();
param.setImage(image);
param.setName(name);
param.setScale(targetScale);
param.setUid(uid);
param.setMeta(string.Empty);
var targetOptional = ImageTarget.createFromParameters(param);
if (targetOptional.OnNone)
{
throw new Exception("invalid parameter");
}
if (!Directory.Exists(outputPathDir))
{
Directory.CreateDirectory(outputPathDir);
}
var path = outputPathDir + "/" + (string.IsNullOrEmpty(name) ? uid : name) + ".etd";
if (targetOptional.Value.save(path))
{
Debug.Log("Created etd: " + path);
}
else
{
Debug.LogWarning("Fail to create etd: " + path);
}
}
}
}
}
}
fileFormatVersion: 2
guid: 69a1d1d74f79a8a419e7a382cba24299
timeCreated: 1574928649
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using UnityEngine;
using UnityEditor;
namespace easyar
{
[CustomEditor(typeof (ImageTrackerFrameFilter), true)]
public class ImageTrackerFrameFilterEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
var simultaneousNum = serializedObject.FindProperty("simultaneousNum");
EditorGUILayout.PropertyField(simultaneousNum, new GUIContent("Simultaneous Target Number"), true);
serializedObject.ApplyModifiedProperties();
((ImageTrackerFrameFilter)target).SimultaneousNum = simultaneousNum.intValue;
}
}
}
fileFormatVersion: 2
guid: 29faf2373231f534cbadab21ad23a522
timeCreated: 1572665360
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using System;
using UnityEditor;
using UnityEngine;
namespace easyar
{
[CustomEditor(typeof(ObjectTargetController), true)]
public class ObjectTargetControllerEditor : Editor
{
private float scale = 1;
private float scaleX = 1;
private bool horizontalFlip;
public void OnEnable()
{
UpdateScale((ObjectTargetController)target, scale);
}
public override void OnInspectorGUI()
{
DrawDefaultInspector();
var controller = (ObjectTargetController)target;
switch (controller.SourceType)
{
case ObjectTargetController.DataSource.ObjFile:
var imageFileSource = serializedObject.FindProperty("ObjFileSource");
imageFileSource.isExpanded = EditorGUILayout.Foldout(imageFileSource.isExpanded, "Obj File Source");
EditorGUI.indentLevel += 1;
if (imageFileSource.isExpanded)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("ObjFileSource.PathType"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("ObjFileSource.ObjPath"), true);
ShowListPropertyField("ObjFileSource.ExtraFilePaths", "Extra File Paths");
EditorGUILayout.PropertyField(serializedObject.FindProperty("ObjFileSource.Name"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("ObjFileSource.Scale"), true);
}
EditorGUI.indentLevel -= 1;
break;
default:
break;
}
var tracker = serializedObject.FindProperty("tracker");
EditorGUILayout.PropertyField(tracker, new GUIContent("Tracker"), true);
var trackerHasSet = serializedObject.FindProperty("trackerHasSet");
if (!trackerHasSet.boolValue)
{
if (!tracker.objectReferenceValue)
{
tracker.objectReferenceValue = FindObjectOfType<ObjectTrackerFrameFilter>();
}
if (tracker.objectReferenceValue)
{
trackerHasSet.boolValue = true;
}
}
serializedObject.ApplyModifiedProperties();
controller.Tracker = (ObjectTrackerFrameFilter)tracker.objectReferenceValue;
if (Event.current.type == EventType.Used)
{
foreach (var obj in DragAndDrop.objectReferences)
{
var objg = obj as GameObject;
if (objg && objg.GetComponent<ObjectTrackerFrameFilter>() && !AssetDatabase.GetAssetPath(obj).Equals(""))
DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
}
}
CheckScale();
}
void CheckScale()
{
if (Application.isPlaying)
{
return;
}
var controller = (ObjectTargetController)target;
if (controller.SourceType == ObjectTargetController.DataSource.ObjFile)
{
if (scale != controller.ObjFileSource.Scale)
{
UpdateScale(controller, controller.ObjFileSource.Scale);
}
else if (scaleX != controller.transform.localScale.x)
{
controller.ObjFileSource.Scale = Math.Abs(controller.transform.localScale.x);
UpdateScale(controller, controller.ObjFileSource.Scale);
}
else if (scale != controller.transform.localScale.y)
{
controller.ObjFileSource.Scale = Math.Abs(controller.transform.localScale.y);
UpdateScale(controller, controller.ObjFileSource.Scale);
}
else if (scale != controller.transform.localScale.z)
{
controller.ObjFileSource.Scale = Math.Abs(controller.transform.localScale.z);
UpdateScale(controller, controller.ObjFileSource.Scale);
}
else if (horizontalFlip != controller.HorizontalFlip)
{
UpdateScale(controller, controller.ObjFileSource.Scale);
}
}
else
{
if (horizontalFlip != controller.HorizontalFlip || scaleX != controller.transform.localScale.x || scale != controller.transform.localScale.y || scale != controller.transform.localScale.z)
{
UpdateScale(controller, scale);
}
}
}
private void UpdateScale(ObjectTargetController controller, float s)
{
if (Application.isPlaying)
{
return;
}
var vec3Unit = Vector3.one;
if (controller.HorizontalFlip)
{
vec3Unit.x = -vec3Unit.x;
}
controller.transform.localScale = vec3Unit * s;
scale = s;
scaleX = controller.transform.localScale.x;
horizontalFlip = controller.HorizontalFlip;
}
private void ShowListPropertyField(string propertyPath, string label)
{
var list = serializedObject.FindProperty(propertyPath);
list.isExpanded = EditorGUILayout.Foldout(list.isExpanded, label);
EditorGUI.indentLevel += 1;
if (list.isExpanded)
{
int count = Mathf.Max(0, EditorGUILayout.IntField("Size", list.arraySize));
while (count < list.arraySize) { list.DeleteArrayElementAtIndex(list.arraySize - 1); }
while (count > list.arraySize) { list.InsertArrayElementAtIndex(list.arraySize); }
for (int i = 0; i < list.arraySize; i++) { EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i)); }
}
EditorGUI.indentLevel -= 1;
}
[DrawGizmo(GizmoType.Active | GizmoType.Pickable | GizmoType.NotInSelectionHierarchy | GizmoType.InSelectionHierarchy)]
static void DrawGizmo(ObjectTargetController scr, GizmoType gizmoType)
{
if (!EasyARController.Settings.GizmoConfig.ObjectTarget.Enable) { return; }
Gizmos.color = Color.white;
var boundingBox = scr.BoundingBox;
if (boundingBox.Count == 8)
{
var scale = scr.Target.scale();
for (int i = 0; i < 8; ++i)
{
boundingBox[i] = scr.transform.localToWorldMatrix.MultiplyPoint(boundingBox[i] / scale);
}
Gizmos.DrawLine(boundingBox[0], boundingBox[1]);
Gizmos.DrawLine(boundingBox[1], boundingBox[2]);
Gizmos.DrawLine(boundingBox[2], boundingBox[3]);
Gizmos.DrawLine(boundingBox[3], boundingBox[0]);
Gizmos.DrawLine(boundingBox[4], boundingBox[5]);
Gizmos.DrawLine(boundingBox[5], boundingBox[6]);
Gizmos.DrawLine(boundingBox[6], boundingBox[7]);
Gizmos.DrawLine(boundingBox[7], boundingBox[4]);
Gizmos.DrawLine(boundingBox[0], boundingBox[4]);
Gizmos.DrawLine(boundingBox[1], boundingBox[5]);
Gizmos.DrawLine(boundingBox[2], boundingBox[6]);
Gizmos.DrawLine(boundingBox[3], boundingBox[7]);
}
}
}
}
fileFormatVersion: 2
guid: e733e5d3075c320428c67c345d3cacc3
timeCreated: 1572770743
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using UnityEngine;
using UnityEditor;
namespace easyar
{
[CustomEditor(typeof (ObjectTrackerFrameFilter), true)]
public class ObjectTrackerFrameFilterEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
var simultaneousNum = serializedObject.FindProperty("simultaneousNum");
EditorGUILayout.PropertyField(simultaneousNum, new GUIContent("Simultaneous Target Number"), true);
serializedObject.ApplyModifiedProperties();
((ObjectTrackerFrameFilter)target).SimultaneousNum = simultaneousNum.intValue;
}
}
}
fileFormatVersion: 2
guid: 584fbe416a6c68f409311888020f0607
timeCreated: 1572669788
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b9c30c584e29b8a43a394a71a5d770b8
folderAsset: yes
timeCreated: 1594183966
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using UnityEditor;
using UnityEngine;
namespace easyar
{
[CustomEditor(typeof(ARSession), true)]
public class ARSessionEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
if (((ARSession)target).AssembleMode == ARAssembly.AssembleMode.Manual)
{
var assembly = serializedObject.FindProperty("Assembly");
assembly.isExpanded = EditorGUILayout.Foldout(assembly.isExpanded, "Assembly");
EditorGUI.indentLevel += 1;
if (assembly.isExpanded)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("Assembly.Camera"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("Assembly.CameraRoot"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("Assembly.FrameSource"), true);
ShowListPropertyField("Assembly.RenderCameras", "Render Cameras");
ShowListPropertyField("Assembly.FrameFilters", "Frame Filters");
}
EditorGUI.indentLevel -= 1;
}
serializedObject.ApplyModifiedProperties();
}
private void ShowListPropertyField(string propertyPath, string label)
{
var list = serializedObject.FindProperty(propertyPath);
list.isExpanded = EditorGUILayout.Foldout(list.isExpanded, label);
EditorGUI.indentLevel += 1;
if (list.isExpanded)
{
int count = Mathf.Max(0, EditorGUILayout.IntField("Size", list.arraySize));
while (count < list.arraySize) { list.DeleteArrayElementAtIndex(list.arraySize - 1); }
while (count > list.arraySize) { list.InsertArrayElementAtIndex(list.arraySize); }
for (int i = 0; i < list.arraySize; i++) { EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i)); }
}
EditorGUI.indentLevel -= 1;
}
}
}
fileFormatVersion: 2
guid: bb8f8a0954007294f85977d149b67e4a
timeCreated: 1572355570
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 2b40389b3ed3d1640ae0c1c3b1e19a8b
folderAsset: yes
timeCreated: 1594183914
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using UnityEditor;
using UnityEngine;
namespace easyar
{
[CustomEditor(typeof(SparseSpatialMapController), true)]
public class SparseSpatialMapControllerEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
var controller = (SparseSpatialMapController)target;
switch (controller.SourceType)
{
case SparseSpatialMapController.DataSource.MapManager:
var mapManagerSource = serializedObject.FindProperty("MapManagerSource");
mapManagerSource.isExpanded = EditorGUILayout.Foldout(mapManagerSource.isExpanded, "Map Manager Source");
EditorGUI.indentLevel += 1;
if (mapManagerSource.isExpanded)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("MapManagerSource.ID"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("MapManagerSource.Name"), true);
}
EditorGUI.indentLevel -= 1;
break;
default:
break;
}
var mapWorker = serializedObject.FindProperty("mapWorker");
EditorGUILayout.PropertyField(mapWorker, new GUIContent("Map Worker"), true);
var mapWorkerHasSet = serializedObject.FindProperty("mapWorkerHasSet");
if (!mapWorkerHasSet.boolValue)
{
if (!mapWorker.objectReferenceValue)
{
mapWorker.objectReferenceValue = FindObjectOfType<SparseSpatialMapWorkerFrameFilter>();
}
if (mapWorker.objectReferenceValue)
{
mapWorkerHasSet.boolValue = true;
}
}
var showPointCloud = serializedObject.FindProperty("showPointCloud");
EditorGUILayout.PropertyField(showPointCloud, true);
var pointCloudParticleParameter = serializedObject.FindProperty("pointCloudParticleParameter");
pointCloudParticleParameter.isExpanded = EditorGUILayout.Foldout(pointCloudParticleParameter.isExpanded, "Point Cloud Particle Parameter");
EditorGUI.indentLevel += 1;
if (pointCloudParticleParameter.isExpanded)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("pointCloudParticleParameter.StartColor"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("pointCloudParticleParameter.StartSize"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("pointCloudParticleParameter.StartLifetime"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("pointCloudParticleParameter.RemainingLifetime"), true);
}
EditorGUI.indentLevel -= 1;
serializedObject.ApplyModifiedProperties();
controller.MapWorker = (SparseSpatialMapWorkerFrameFilter)mapWorker.objectReferenceValue;
controller.ShowPointCloud = showPointCloud.boolValue;
}
}
}
fileFormatVersion: 2
guid: bc6628e4d66d0894094265600273e319
timeCreated: 1573228571
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using UnityEditor;
namespace easyar
{
[CustomEditor(typeof(SparseSpatialMapWorkerFrameFilter), true)]
public class SparseSpatialMapWorkerFrameFilterEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
if (!((SparseSpatialMapWorkerFrameFilter)target).UseGlobalServiceConfig)
{
var serviceConfig = serializedObject.FindProperty("ServiceConfig");
serviceConfig.isExpanded = EditorGUILayout.Foldout(serviceConfig.isExpanded, "Service Config");
EditorGUI.indentLevel += 1;
if (serviceConfig.isExpanded)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("ServiceConfig.APIKey"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("ServiceConfig.APISecret"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("ServiceConfig.SparseSpatialMapAppID"), true);
}
EditorGUI.indentLevel -= 1;
}
serializedObject.ApplyModifiedProperties();
}
}
}
fileFormatVersion: 2
guid: 8bc27e7143a446441aba7e1d1690d784
timeCreated: 1576549452
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using UnityEngine;
using UnityEditor;
namespace easyar
{
[CustomEditor(typeof (VideoCameraDevice), true)]
public class VideoCameraDeviceEditor : Editor
{
CameraDevicePreference preference;
public void OnEnable()
{
preference = ((VideoCameraDevice)target).CameraPreference;
}
public override void OnInspectorGUI()
{
DrawDefaultInspector();
if (((VideoCameraDevice)target).CameraOpenMethod == VideoCameraDevice.CameraDeviceOpenMethod.DeviceType)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("CameraType"), true);
}
else
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("CameraIndex"), true);
}
var cameraPreference = serializedObject.FindProperty("cameraPreference");
EditorGUILayout.PropertyField(cameraPreference, new GUIContent("Camera Preference"), true);
serializedObject.ApplyModifiedProperties();
if(preference != (CameraDevicePreference)cameraPreference.enumValueIndex)
{
((VideoCameraDevice)target).CameraPreference = (CameraDevicePreference)cameraPreference.enumValueIndex;
preference = (CameraDevicePreference)cameraPreference.enumValueIndex;
}
}
}
}
fileFormatVersion: 2
guid: f9504a50c0216cf49bcbdd6c621b66c2
timeCreated: 1571997682
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 22a10de4c94493f4d93357a04f97e1d3
folderAsset: yes
timeCreated: 1594182956
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using System;
using System.Collections.Generic;
using UnityEngine;
namespace easyar
{
/// <summary>
/// <para xml:lang="en"><see cref="MonoBehaviour"/> which controls <see cref="easyar.CloudRecognizer"/> in the scene, providing a few extensions in the Unity environment. Use <see cref="CloudRecognizer"/> directly when necessary.</para>
/// <para xml:lang="zh">在场景中控制<see cref="easyar.CloudRecognizer"/>的<see cref="MonoBehaviour"/>,在Unity环境下提供功能扩展。如有需要可以直接使用<see cref="CloudRecognizer"/>。</para>
/// </summary>
public class CloudRecognizerFrameFilter : FrameFilter
{
/// <summary>
/// <para xml:lang="en">EasyAR Sense API. Accessible after Start if available.</para>
/// <para xml:lang="zh">EasyAR Sense API,如果功能可以使用,可以在Start之后访问。</para>
/// </summary>
public CloudRecognizer CloudRecognizer { get; private set; }
/// <summary>
/// <para xml:lang="en">Use global service config or not. The global service config can be changed on the inspector after click Unity menu EasyAR -> Change Global Cloud Recognizer Service Config.</para>
/// <para xml:lang="zh">是否使用全局服务器配置。全局配置可以点击Unity菜单EasyAR -> Change Global Cloud Recognizer Service Config可以在属性面板里面进行填写。</para>
/// </summary>
public bool UseGlobalServiceConfig = true;
/// <summary>
/// <para xml:lang="en">Cloud recognizer key type.</para>
/// <para xml:lang="zh">云识别服务密钥类型。</para>
/// </summary>
[HideInInspector]
public KeyType ServerKeyType = KeyType.Public;
/// <summary>
/// <para xml:lang="en">Service config when <see cref="UseGlobalServiceConfig"/> == false, only valid for this object.</para>
/// <para xml:lang="zh"><see cref="UseGlobalServiceConfig"/> == false时使用的服务器配置,只对该物体有效。</para>
/// </summary>
[HideInInspector, SerializeField]
public CloudRecognizerServiceConfig ServiceConfig = new CloudRecognizerServiceConfig();
/// <summary>
/// <para xml:lang="en">Service config when <see cref="UseGlobalServiceConfig"/> == false, only valid for this object.</para>
/// <para xml:lang="zh"><see cref="UseGlobalServiceConfig"/> == false时使用的服务器配置,只对该物体有效。</para>
/// </summary>
[HideInInspector, SerializeField]
public PrivateCloudRecognizerServiceConfig PrivateServiceConfig = new PrivateCloudRecognizerServiceConfig();
private Queue<Request> pendingRequets = new Queue<Request>();
/// <summary>
/// <para xml:lang="en">Cloud recognizer key type.</para>
/// <para xml:lang="zh">云识别服务密钥类型。</para>
/// </summary>
public enum KeyType
{
Public,
Private
}
public override int BufferRequirement
{
get { return 0; }
}
/// <summary>
/// MonoBehaviour Start
/// </summary>
protected virtual void Start()
{
if (!EasyARController.Initialized)
{
return;
}
if (!CloudRecognizer.isAvailable())
{
throw new UIPopupException(typeof(CloudRecognizer) + " not available");
}
if (UseGlobalServiceConfig)
{
ServiceConfig = EasyARController.Settings.GlobalCloudRecognizerServiceConfig;
NotifyEmptyConfig(ServiceConfig);
CloudRecognizer = CloudRecognizer.create(ServiceConfig.ServerAddress, ServiceConfig.APIKey, ServiceConfig.APISecret, ServiceConfig.CloudRecognizerAppID);
}
else
{
if (ServerKeyType == KeyType.Public)
{
NotifyEmptyConfig(ServiceConfig);
CloudRecognizer = CloudRecognizer.create(ServiceConfig.ServerAddress, ServiceConfig.APIKey, ServiceConfig.APISecret, ServiceConfig.CloudRecognizerAppID);
}
else if (ServerKeyType == KeyType.Private)
{
NotifyEmptyPrivateConfig(PrivateServiceConfig);
CloudRecognizer = CloudRecognizer.createByCloudSecret(PrivateServiceConfig.ServerAddress, PrivateServiceConfig.CloudRecognitionServiceSecret, PrivateServiceConfig.CloudRecognizerAppID);
}
}
}
/// <summary>
/// MonoBehaviour OnDestroy
/// </summary>
protected virtual void OnDestroy()
{
if (CloudRecognizer != null)
{
CloudRecognizer.Dispose();
}
}
/// <summary>
/// <para xml:lang="en">Send recognition request. The lowest available request interval is 300ms</para>
/// <para xml:lang="zh">发送云识别请求。最低可用请求间隔是300ms。</para>
/// </summary>
public void Resolve(Action<InputFrame> start, Action<CloudRecognizationResult> done)
{
if (CloudRecognizer != null && enabled)
{
pendingRequets.Enqueue(new Request
{
StartCallback = start,
DoneCallback = done,
});
}
}
public override void OnAssemble(ARSession session)
{
session.FrameUpdate += OnFrameUpdate;
}
private void OnFrameUpdate(OutputFrame outputFrame)
{
if (CloudRecognizer == null)
{
return;
}
while (pendingRequets.Count > 0)
{
using (var iFrame = outputFrame.inputFrame())
{
var request = pendingRequets.Dequeue();
if (request.StartCallback != null)
{
request.StartCallback(iFrame);
}
{
CloudRecognizer.resolve(iFrame, EasyARController.Scheduler, request.DoneCallback);
}
}
}
}
private void NotifyEmptyConfig(CloudRecognizerServiceConfig config)
{
if (string.IsNullOrEmpty(config.ServerAddress) ||
string.IsNullOrEmpty(config.APIKey) ||
string.IsNullOrEmpty(config.APISecret) ||
string.IsNullOrEmpty(config.CloudRecognizerAppID))
{
throw new UIPopupException(
"Service config (for authentication) NOT set, please set" + Environment.NewLine +
"globally on <EasyAR Settings> Asset or" + Environment.NewLine +
"locally on <CloudRecognizerFrameFilter> Component." + Environment.NewLine +
"Get from EasyAR Develop Center (www.easyar.com) -> CRS -> Database Details.");
}
}
private void NotifyEmptyPrivateConfig(PrivateCloudRecognizerServiceConfig config)
{
if (string.IsNullOrEmpty(config.ServerAddress) ||
string.IsNullOrEmpty(config.CloudRecognitionServiceSecret) ||
string.IsNullOrEmpty(config.CloudRecognizerAppID))
{
throw new UIPopupException(
"Service config (for authentication) NOT set, please set" + Environment.NewLine +
"globally on <EasyAR Settings> Asset or" + Environment.NewLine +
"locally on <CloudRecognizerFrameFilter> Component." + Environment.NewLine +
"Get from EasyAR Develop Center (www.easyar.com) -> CRS -> Database Details.");
}
}
/// <summary>
/// <para xml:lang="en">Service config for <see cref="easyar.CloudRecognizer"/>.</para>
/// <para xml:lang="zh"><see cref="easyar.CloudRecognizer"/>服务器配置。</para>
/// </summary>
[Serializable]
public class CloudRecognizerServiceConfig
{
/// <summary>
/// <para xml:lang="en">Server Address, go to EasyAR Develop Center (https://www.easyar.com) for details.</para>
/// <para xml:lang="zh">服务器地址,详见EasyAR开发中心(https://www.easyar.cn)。</para>
/// </summary>
public string ServerAddress = string.Empty;
/// <summary>
/// <para xml:lang="en">API Key, go to EasyAR Develop Center (https://www.easyar.com) for details.</para>
/// <para xml:lang="zh">API Key,详见EasyAR开发中心(https://www.easyar.cn)。</para>
/// </summary>
public string APIKey = string.Empty;
/// <summary>
/// <para xml:lang="en">API Secret, go to EasyAR Develop Center (https://www.easyar.com) for details.</para>
/// <para xml:lang="zh">API Secret,详见EasyAR开发中心(https://www.easyar.cn)。</para>
/// </summary>
public string APISecret = string.Empty;
/// <summary>
/// <para xml:lang="en">Cloud Recognizer AppID, go to EasyAR Develop Center (https://www.easyar.com) for details.</para>
/// <para xml:lang="zh">云识别AppID,详见EasyAR开发中心(https://www.easyar.cn)。</para>
/// </summary>
public string CloudRecognizerAppID = string.Empty;
}
[Serializable]
public class PrivateCloudRecognizerServiceConfig
{
public string ServerAddress = string.Empty;
public string CloudRecognitionServiceSecret = string.Empty;
public string CloudRecognizerAppID = string.Empty;
}
private class Request
{
public Action<InputFrame> StartCallback;
public Action<CloudRecognizationResult> DoneCallback;
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment