update 1.0.2
До Ширина: | Высота: | Размер: 3.8 KiB После Ширина: | Высота: | Размер: 3.8 KiB |
До Ширина: | Высота: | Размер: 56 KiB После Ширина: | Высота: | Размер: 56 KiB |
До Ширина: | Высота: | Размер: 53 KiB После Ширина: | Высота: | Размер: 53 KiB |
До Ширина: | Высота: | Размер: 72 KiB После Ширина: | Высота: | Размер: 72 KiB |
До Ширина: | Высота: | Размер: 68 KiB После Ширина: | Высота: | Размер: 68 KiB |
До Ширина: | Высота: | Размер: 61 KiB После Ширина: | Высота: | Размер: 61 KiB |
|
@ -1839,7 +1839,7 @@ MonoBehaviour:
|
|||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
m_TypeName: MarkerLessARSample.WebCamTextureToMatHelper+ErrorUnityEvent, Assembly-CSharp,
|
||||
m_TypeName: MarkerLessARExample.WebCamTextureToMatHelper+ErrorUnityEvent, Assembly-CSharp,
|
||||
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
--- !u!1 &1592116327
|
||||
GameObject:
|
|
@ -260,7 +260,7 @@ GameObject:
|
|||
- 114: {fileID: 130009891}
|
||||
- 114: {fileID: 130009890}
|
||||
m_Layer: 5
|
||||
m_Name: WebCamTextureMarkerLessARSample
|
||||
m_Name: WebCamTextureMarkerLessARExample
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
|
@ -345,7 +345,7 @@ MonoBehaviour:
|
|||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 29440833}
|
||||
m_MethodName: WebCamTextureMarkerLessARSample
|
||||
m_MethodName: WebCamTextureMarkerLessARExample
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
|
@ -762,7 +762,7 @@ MonoBehaviour:
|
|||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: WebCamTextureMarkerLessARSample
|
||||
m_Text: WebCamTextureMarkerLessARExample
|
||||
--- !u!222 &1084706039
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1027,7 +1027,7 @@ GameObject:
|
|||
- 114: {fileID: 1867454789}
|
||||
- 114: {fileID: 1867454788}
|
||||
m_Layer: 5
|
||||
m_Name: Texture2DMarkerLessARSample
|
||||
m_Name: Texture2DMarkerLessARExample
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
|
@ -1112,7 +1112,7 @@ MonoBehaviour:
|
|||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 29440833}
|
||||
m_MethodName: Texture2DMarkerLessARSample
|
||||
m_MethodName: Texture2DMarkerLessARExample
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
|
@ -1215,7 +1215,7 @@ MonoBehaviour:
|
|||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Texture2DMarkerLessARSample
|
||||
m_Text: Texture2DMarkerLessARExample
|
||||
--- !u!222 &1869573385
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
|
@ -765,7 +765,7 @@ MonoBehaviour:
|
|||
m_HandleRect: {fileID: 2061365887}
|
||||
m_Direction: 2
|
||||
m_Value: 1
|
||||
m_Size: .579440713
|
||||
m_Size: .662424088
|
||||
m_NumberOfSteps: 0
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
|
@ -360,7 +360,6 @@ Prefab:
|
|||
objectReference: {fileID: 2100000, guid: 97400fd758b63ad4fb3e3ce693bde79c, type: 2}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: d607aa1e2987cf5448fca2348df9adb8, type: 2}
|
||||
m_RootGameObject: {fileID: 670952741}
|
||||
m_IsPrefabParent: 0
|
||||
--- !u!1 &218001137
|
||||
GameObject:
|
||||
|
@ -467,20 +466,11 @@ Prefab:
|
|||
objectReference: {fileID: 2100000, guid: 1b8b43d91d788ff40a57841b78265554, type: 2}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: 8233df8b16be6b541950a0cab104a705, type: 2}
|
||||
m_RootGameObject: {fileID: 1980521274}
|
||||
m_IsPrefabParent: 0
|
||||
--- !u!4 &366590740
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 400000, guid: 8233df8b16be6b541950a0cab104a705, type: 2}
|
||||
m_PrefabInternal: {fileID: 274035050}
|
||||
m_GameObject: {fileID: 1980521274}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: 0}
|
||||
m_LocalScale: {x: .100000001, y: 1, z: .100000001}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1955163577}
|
||||
m_RootOrder: 3
|
||||
--- !u!1001 &367435927
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -530,7 +520,6 @@ Prefab:
|
|||
objectReference: {fileID: 2100000, guid: 1160f0307b000334b8c1fe8fba48c8c0, type: 2}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: 9b9e77d1089cb5247aa00e2cb86a0960, type: 2}
|
||||
m_RootGameObject: {fileID: 1854143201}
|
||||
m_IsPrefabParent: 0
|
||||
--- !u!1 &538633486
|
||||
GameObject:
|
||||
|
@ -696,70 +685,6 @@ Canvas:
|
|||
m_OverridePixelPerfect: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!1 &670952741
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 100000, guid: d607aa1e2987cf5448fca2348df9adb8, type: 2}
|
||||
m_PrefabInternal: {fileID: 69047525}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 4: {fileID: 1282818104}
|
||||
- 33: {fileID: 670952744}
|
||||
- 65: {fileID: 670952743}
|
||||
- 23: {fileID: 670952742}
|
||||
m_Layer: 5
|
||||
m_Name: Cube
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!23 &670952742
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 2300000, guid: d607aa1e2987cf5448fca2348df9adb8,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 69047525}
|
||||
m_GameObject: {fileID: 670952741}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 97400fd758b63ad4fb3e3ce693bde79c, type: 2}
|
||||
m_SubsetIndices:
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_UseLightProbes: 0
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_PreserveUVs: 0
|
||||
m_ImportantGI: 0
|
||||
m_AutoUVMaxDistance: .5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!65 &670952743
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 6500000, guid: d607aa1e2987cf5448fca2348df9adb8,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 69047525}
|
||||
m_GameObject: {fileID: 670952741}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &670952744
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 3300000, guid: d607aa1e2987cf5448fca2348df9adb8,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 69047525}
|
||||
m_GameObject: {fileID: 670952741}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!1 &673136259
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -844,70 +769,6 @@ Transform:
|
|||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
--- !u!1 &716009041
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 100000, guid: 7369a346695228f41ab4f289dd5ba16d, type: 2}
|
||||
m_PrefabInternal: {fileID: 1014827335}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 4: {fileID: 1298675159}
|
||||
- 33: {fileID: 716009044}
|
||||
- 135: {fileID: 716009043}
|
||||
- 23: {fileID: 716009042}
|
||||
m_Layer: 5
|
||||
m_Name: Sphere
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
--- !u!23 &716009042
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 2300000, guid: 7369a346695228f41ab4f289dd5ba16d,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 1014827335}
|
||||
m_GameObject: {fileID: 716009041}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: d2e658dbdc1e3854bba57ba9d67076b4, type: 2}
|
||||
m_SubsetIndices:
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_UseLightProbes: 0
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_PreserveUVs: 0
|
||||
m_ImportantGI: 0
|
||||
m_AutoUVMaxDistance: .5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!135 &716009043
|
||||
SphereCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 13500000, guid: 7369a346695228f41ab4f289dd5ba16d,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 1014827335}
|
||||
m_GameObject: {fileID: 716009041}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Radius: .5
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &716009044
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 3300000, guid: 7369a346695228f41ab4f289dd5ba16d,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 1014827335}
|
||||
m_GameObject: {fileID: 716009041}
|
||||
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!1 &826264227
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1013,7 +874,6 @@ Prefab:
|
|||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: 88bd7da02dc70d2409c6d485c3020dab, type: 2}
|
||||
m_RootGameObject: {fileID: 1535692055}
|
||||
m_IsPrefabParent: 0
|
||||
--- !u!1001 &870740068
|
||||
Prefab:
|
||||
|
@ -1056,20 +916,11 @@ Prefab:
|
|||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: 83de61287d78dcf43a5e6e1522cdc711, type: 2}
|
||||
m_RootGameObject: {fileID: 1519318248}
|
||||
m_IsPrefabParent: 0
|
||||
--- !u!4 &1000071879
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 400000, guid: 83de61287d78dcf43a5e6e1522cdc711, type: 2}
|
||||
m_PrefabInternal: {fileID: 870740068}
|
||||
m_GameObject: {fileID: 1519318248}
|
||||
m_LocalRotation: {x: .707106829, y: 0, z: 0, w: .707106829}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 1}
|
||||
m_LocalScale: {x: .100000001, y: 1, z: .100000001}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1955163577}
|
||||
m_RootOrder: 4
|
||||
--- !u!1001 &1014827335
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1123,32 +974,15 @@ Prefab:
|
|||
objectReference: {fileID: 2100000, guid: d2e658dbdc1e3854bba57ba9d67076b4, type: 2}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: 7369a346695228f41ab4f289dd5ba16d, type: 2}
|
||||
m_RootGameObject: {fileID: 716009041}
|
||||
m_IsPrefabParent: 0
|
||||
--- !u!4 &1282818104
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 400000, guid: d607aa1e2987cf5448fca2348df9adb8, type: 2}
|
||||
m_PrefabInternal: {fileID: 69047525}
|
||||
m_GameObject: {fileID: 670952741}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: .0500000007}
|
||||
m_LocalScale: {x: 1, y: 1, z: .100000001}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1955163577}
|
||||
m_RootOrder: 0
|
||||
--- !u!4 &1298675159
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 400000, guid: 7369a346695228f41ab4f289dd5ba16d, type: 2}
|
||||
m_PrefabInternal: {fileID: 1014827335}
|
||||
m_GameObject: {fileID: 716009041}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: .5}
|
||||
m_LocalScale: {x: .800000012, y: .800000012, z: .800000012}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1955163577}
|
||||
m_RootOrder: 2
|
||||
--- !u!1 &1393514933
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1300,164 +1134,6 @@ Transform:
|
|||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
--- !u!1 &1519318248
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 100000, guid: 83de61287d78dcf43a5e6e1522cdc711, type: 2}
|
||||
m_PrefabInternal: {fileID: 870740068}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 4: {fileID: 1000071879}
|
||||
- 33: {fileID: 1519318251}
|
||||
- 136: {fileID: 1519318250}
|
||||
- 23: {fileID: 1519318249}
|
||||
m_Layer: 5
|
||||
m_Name: Axes_Z
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!23 &1519318249
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 2300000, guid: 83de61287d78dcf43a5e6e1522cdc711,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 870740068}
|
||||
m_GameObject: {fileID: 1519318248}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 743d24b6733e04e4ba34ac85ac3f15f2, type: 2}
|
||||
m_SubsetIndices:
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_UseLightProbes: 0
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_PreserveUVs: 0
|
||||
m_ImportantGI: 0
|
||||
m_AutoUVMaxDistance: .5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!136 &1519318250
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 13600000, guid: 83de61287d78dcf43a5e6e1522cdc711,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 870740068}
|
||||
m_GameObject: {fileID: 1519318248}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
m_Radius: .5
|
||||
m_Height: 2
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &1519318251
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 3300000, guid: 83de61287d78dcf43a5e6e1522cdc711,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 870740068}
|
||||
m_GameObject: {fileID: 1519318248}
|
||||
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!1 &1535692055
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 100000, guid: 88bd7da02dc70d2409c6d485c3020dab, type: 2}
|
||||
m_PrefabInternal: {fileID: 829811795}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 4: {fileID: 1535692056}
|
||||
- 20: {fileID: 1892028844}
|
||||
m_Layer: 5
|
||||
m_Name: ARCamera
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1535692056
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 400000, guid: 88bd7da02dc70d2409c6d485c3020dab, type: 2}
|
||||
m_PrefabInternal: {fileID: 829811795}
|
||||
m_GameObject: {fileID: 1535692055}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 5
|
||||
--- !u!1 &1854143201
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 100000, guid: 9b9e77d1089cb5247aa00e2cb86a0960, type: 2}
|
||||
m_PrefabInternal: {fileID: 367435927}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 4: {fileID: 2004008789}
|
||||
- 33: {fileID: 1854143204}
|
||||
- 136: {fileID: 1854143203}
|
||||
- 23: {fileID: 1854143202}
|
||||
m_Layer: 5
|
||||
m_Name: Axes_X
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!23 &1854143202
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 2300000, guid: 9b9e77d1089cb5247aa00e2cb86a0960,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 367435927}
|
||||
m_GameObject: {fileID: 1854143201}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 1160f0307b000334b8c1fe8fba48c8c0, type: 2}
|
||||
m_SubsetIndices:
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_UseLightProbes: 0
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_PreserveUVs: 0
|
||||
m_ImportantGI: 0
|
||||
m_AutoUVMaxDistance: .5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!136 &1854143203
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 13600000, guid: 9b9e77d1089cb5247aa00e2cb86a0960,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 367435927}
|
||||
m_GameObject: {fileID: 1854143201}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
m_Radius: .5
|
||||
m_Height: 2
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &1854143204
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 3300000, guid: 9b9e77d1089cb5247aa00e2cb86a0960,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 367435927}
|
||||
m_GameObject: {fileID: 1854143201}
|
||||
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!1 &1884164571
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1545,37 +1221,9 @@ Transform:
|
|||
m_RootOrder: 3
|
||||
--- !u!20 &1892028844
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 2000000, guid: 88bd7da02dc70d2409c6d485c3020dab,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 829811795}
|
||||
m_GameObject: {fileID: 1535692055}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 3
|
||||
m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438}
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: .300000012
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 32
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_HDR: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: .0219999999
|
||||
--- !u!1 &1955163576
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1608,80 +1256,7 @@ Transform:
|
|||
- {fileID: 1000071879}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 4
|
||||
--- !u!1 &1980521274
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 100000, guid: 8233df8b16be6b541950a0cab104a705, type: 2}
|
||||
m_PrefabInternal: {fileID: 274035050}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 4: {fileID: 366590740}
|
||||
- 33: {fileID: 1980521277}
|
||||
- 136: {fileID: 1980521276}
|
||||
- 23: {fileID: 1980521275}
|
||||
m_Layer: 5
|
||||
m_Name: Axes_Y
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!23 &1980521275
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 2300000, guid: 8233df8b16be6b541950a0cab104a705,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 274035050}
|
||||
m_GameObject: {fileID: 1980521274}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 1b8b43d91d788ff40a57841b78265554, type: 2}
|
||||
m_SubsetIndices:
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_UseLightProbes: 0
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_PreserveUVs: 0
|
||||
m_ImportantGI: 0
|
||||
m_AutoUVMaxDistance: .5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!136 &1980521276
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 13600000, guid: 8233df8b16be6b541950a0cab104a705,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 274035050}
|
||||
m_GameObject: {fileID: 1980521274}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
m_Radius: .5
|
||||
m_Height: 2
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &1980521277
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 3300000, guid: 8233df8b16be6b541950a0cab104a705,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 274035050}
|
||||
m_GameObject: {fileID: 1980521274}
|
||||
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &2004008789
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 400000, guid: 9b9e77d1089cb5247aa00e2cb86a0960, type: 2}
|
||||
m_PrefabInternal: {fileID: 367435927}
|
||||
m_GameObject: {fileID: 1854143201}
|
||||
m_LocalRotation: {x: 0, y: 0, z: .707106829, w: .707106829}
|
||||
m_LocalPosition: {x: 1, y: 0, z: 0}
|
||||
m_LocalScale: {x: .100000001, y: 1, z: .100000001}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1955163577}
|
||||
m_RootOrder: 1
|
|
@ -2436,7 +2436,7 @@ MonoBehaviour:
|
|||
requestIsFrontFacing: 0
|
||||
flipVertical: 0
|
||||
flipHorizontal: 0
|
||||
timeout: 100
|
||||
timeoutFrameCount: 300
|
||||
OnInitedEvent:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
|
@ -2486,7 +2486,7 @@ MonoBehaviour:
|
|||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
m_TypeName: MarkerLessARSample.WebCamTextureToMatHelper+ErrorUnityEvent, Assembly-CSharp,
|
||||
m_TypeName: MarkerLessARExample.WebCamTextureToMatHelper+ErrorUnityEvent, Assembly-CSharp,
|
||||
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
--- !u!1 &1508174468
|
||||
GameObject:
|
|
@ -1,282 +1,284 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
using UnityEngine.SceneManagement;
|
||||
#endif
|
||||
using OpenCVForUnity;
|
||||
|
||||
namespace MarkerLessARSample
|
||||
{
|
||||
/// <summary>
|
||||
/// Pattern capture.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(WebCamTextureToMatHelper))]
|
||||
public class CapturePattern : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The texture.
|
||||
/// </summary>
|
||||
Texture2D texture;
|
||||
|
||||
/// <summary>
|
||||
/// The web cam texture to mat helper.
|
||||
/// </summary>
|
||||
WebCamTextureToMatHelper webCamTextureToMatHelper;
|
||||
|
||||
/// <summary>
|
||||
/// The pattern rect.
|
||||
/// </summary>
|
||||
OpenCVForUnity.Rect patternRect;
|
||||
|
||||
/// <summary>
|
||||
/// The rgb mat.
|
||||
/// </summary>
|
||||
Mat rgbMat;
|
||||
|
||||
/// <summary>
|
||||
/// The pattern raw image.
|
||||
/// </summary>
|
||||
public RawImage patternRawImage;
|
||||
|
||||
/// <summary>
|
||||
/// The detector.
|
||||
/// </summary>
|
||||
ORB detector;
|
||||
|
||||
/// <summary>
|
||||
/// The keypoints.
|
||||
/// </summary>
|
||||
MatOfKeyPoint keypoints;
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
// Utils.setDebugMode(true);
|
||||
|
||||
using (Mat patternMat = Imgcodecs.imread (Application.persistentDataPath + "/patternImg.jpg")) {
|
||||
if (patternMat.empty ()) {
|
||||
|
||||
patternRawImage.gameObject.SetActive (false);
|
||||
|
||||
} else {
|
||||
|
||||
Imgproc.cvtColor (patternMat, patternMat, Imgproc.COLOR_BGR2RGB);
|
||||
|
||||
Texture2D patternTexture = new Texture2D (patternMat.width(), patternMat.height(), TextureFormat.RGBA32, false);
|
||||
|
||||
Utils.matToTexture2D (patternMat, patternTexture);
|
||||
|
||||
patternRawImage.texture = patternTexture;
|
||||
patternRawImage.rectTransform.localScale = new Vector3( 1.0f, (float)patternMat.height()/(float)patternMat.width(), 1.0f);
|
||||
|
||||
patternRawImage.gameObject.SetActive (true);
|
||||
}
|
||||
}
|
||||
|
||||
webCamTextureToMatHelper = gameObject.GetComponent<WebCamTextureToMatHelper> ();
|
||||
webCamTextureToMatHelper.Init ();
|
||||
|
||||
|
||||
detector = ORB.create ();
|
||||
detector.setMaxFeatures (1000);
|
||||
keypoints = new MatOfKeyPoint ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the web cam texture to mat helper inited event.
|
||||
/// </summary>
|
||||
public void OnWebCamTextureToMatHelperInited ()
|
||||
{
|
||||
Debug.Log ("OnWebCamTextureToMatHelperInited");
|
||||
|
||||
|
||||
Mat webCamTextureMat = webCamTextureToMatHelper.GetMat ();
|
||||
|
||||
texture = new Texture2D (webCamTextureMat.width(), webCamTextureMat.height(), TextureFormat.RGBA32, false);
|
||||
|
||||
rgbMat = new Mat (webCamTextureMat.rows (), webCamTextureMat.cols (), CvType.CV_8UC3);
|
||||
|
||||
|
||||
|
||||
gameObject.transform.localScale = new Vector3 (webCamTextureMat.width(), webCamTextureMat.height(), 1);
|
||||
|
||||
Debug.Log ("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
|
||||
|
||||
|
||||
float width = webCamTextureMat.width ();
|
||||
float height = webCamTextureMat.height ();
|
||||
|
||||
float widthScale = (float)Screen.width / width;
|
||||
float heightScale = (float)Screen.height / height;
|
||||
if (widthScale < heightScale) {
|
||||
Camera.main.orthographicSize = (width * (float)Screen.height / (float)Screen.width) / 2;
|
||||
} else {
|
||||
Camera.main.orthographicSize = height / 2;
|
||||
}
|
||||
|
||||
gameObject.GetComponent<Renderer> ().material.mainTexture = texture;
|
||||
|
||||
|
||||
|
||||
|
||||
//if WebCamera is frontFaceing,flip Mat.
|
||||
if (webCamTextureToMatHelper.GetWebCamDevice ().isFrontFacing) {
|
||||
webCamTextureToMatHelper.flipHorizontal = true;
|
||||
}
|
||||
|
||||
|
||||
int patternWidth = (int)(Mathf.Min (webCamTextureMat.width(), webCamTextureMat.height()) * 0.8f);
|
||||
|
||||
patternRect = new OpenCVForUnity.Rect (webCamTextureMat.width() / 2 - patternWidth / 2, webCamTextureMat.height() / 2 - patternWidth / 2, patternWidth, patternWidth);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the web cam texture to mat helper disposed event.
|
||||
/// </summary>
|
||||
public void OnWebCamTextureToMatHelperDisposed ()
|
||||
{
|
||||
Debug.Log ("OnWebCamTextureToMatHelperDisposed");
|
||||
|
||||
if (rgbMat != null) {
|
||||
rgbMat.Dispose ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the web cam texture to mat helper error occurred event.
|
||||
/// </summary>
|
||||
/// <param name="errorCode">Error code.</param>
|
||||
public void OnWebCamTextureToMatHelperErrorOccurred(WebCamTextureToMatHelper.ErrorCode errorCode){
|
||||
Debug.Log ("OnWebCamTextureToMatHelperErrorOccurred " + errorCode);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
if (webCamTextureToMatHelper.IsPlaying () && webCamTextureToMatHelper.DidUpdateThisFrame ()) {
|
||||
|
||||
Mat rgbaMat = webCamTextureToMatHelper.GetMat ();
|
||||
|
||||
Imgproc.cvtColor (rgbaMat, rgbMat, Imgproc.COLOR_RGBA2RGB);
|
||||
|
||||
|
||||
detector.detect (rgbaMat, keypoints);
|
||||
// Debug.Log ("keypoints.ToString() " + keypoints.ToString());
|
||||
Features2d.drawKeypoints(rgbMat, keypoints, rgbaMat, Scalar.all(-1), Features2d.NOT_DRAW_SINGLE_POINTS);
|
||||
|
||||
|
||||
|
||||
Imgproc.rectangle (rgbaMat, patternRect.tl (), patternRect.br (), new Scalar (255, 0, 0, 255), 5);
|
||||
|
||||
|
||||
Utils.matToTexture2D (rgbaMat, texture, webCamTextureToMatHelper.GetBufferColors());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void OnDisable ()
|
||||
{
|
||||
webCamTextureToMatHelper.Dispose ();
|
||||
|
||||
detector.Dispose();
|
||||
if(keypoints != null)keypoints.Dispose();
|
||||
|
||||
// Utils.setDebugMode(false);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Raises the back button event.
|
||||
/// </summary>
|
||||
public void OnBackButton ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("MarkerLessARSample");
|
||||
#else
|
||||
Application.LoadLevel ("MarkerLessARSample");
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the play button event.
|
||||
/// </summary>
|
||||
public void OnPlayButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Play ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the pause button event.
|
||||
/// </summary>
|
||||
public void OnPauseButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Pause ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the stop button event.
|
||||
/// </summary>
|
||||
public void OnStopButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Stop ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the change camera button event.
|
||||
/// </summary>
|
||||
public void OnChangeCameraButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Init (null, webCamTextureToMatHelper.requestWidth, webCamTextureToMatHelper.requestHeight, !webCamTextureToMatHelper.requestIsFrontFacing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the capture button event.
|
||||
/// </summary>
|
||||
public void OnCaptureButton ()
|
||||
{
|
||||
|
||||
Mat patternMat = new Mat (rgbMat, patternRect);
|
||||
|
||||
Texture2D patternTexture = new Texture2D (patternMat.width(), patternMat.height(), TextureFormat.RGBA32, false);
|
||||
|
||||
Utils.matToTexture2D (patternMat, patternTexture);
|
||||
|
||||
patternRawImage.texture = patternTexture;
|
||||
|
||||
patternRawImage.gameObject.SetActive (true);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the save button event.
|
||||
/// </summary>
|
||||
public void OnSaveButton ()
|
||||
{
|
||||
if (patternRawImage.texture != null) {
|
||||
Texture2D patternTexture = (Texture2D)patternRawImage.texture;
|
||||
Mat patternMat = new Mat (patternRect.size (), CvType.CV_8UC3);
|
||||
Utils.texture2DToMat (patternTexture, patternMat);
|
||||
Imgproc.cvtColor (patternMat, patternMat, Imgproc.COLOR_RGB2BGR);
|
||||
|
||||
string savePath = Application.persistentDataPath;
|
||||
Debug.Log ("savePath " + savePath);
|
||||
|
||||
Imgcodecs.imwrite (savePath + "/patternImg.jpg", patternMat);
|
||||
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("WebCamTextureMarkerLessARSample");
|
||||
#else
|
||||
Application.LoadLevel ("WebCamTextureMarkerLessARSample");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
using UnityEngine.SceneManagement;
|
||||
#endif
|
||||
using OpenCVForUnity;
|
||||
|
||||
namespace MarkerLessARExample
|
||||
{
|
||||
/// <summary>
|
||||
/// Pattern capture.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(WebCamTextureToMatHelper))]
|
||||
public class CapturePattern : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The texture.
|
||||
/// </summary>
|
||||
Texture2D texture;
|
||||
|
||||
/// <summary>
|
||||
/// The web cam texture to mat helper.
|
||||
/// </summary>
|
||||
WebCamTextureToMatHelper webCamTextureToMatHelper;
|
||||
|
||||
/// <summary>
|
||||
/// The pattern rect.
|
||||
/// </summary>
|
||||
OpenCVForUnity.Rect patternRect;
|
||||
|
||||
/// <summary>
|
||||
/// The rgb mat.
|
||||
/// </summary>
|
||||
Mat rgbMat;
|
||||
|
||||
/// <summary>
|
||||
/// The pattern raw image.
|
||||
/// </summary>
|
||||
public RawImage patternRawImage;
|
||||
|
||||
/// <summary>
|
||||
/// The detector.
|
||||
/// </summary>
|
||||
ORB detector;
|
||||
|
||||
/// <summary>
|
||||
/// The keypoints.
|
||||
/// </summary>
|
||||
MatOfKeyPoint keypoints;
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
// Utils.setDebugMode(true);
|
||||
|
||||
using (Mat patternMat = Imgcodecs.imread (Application.persistentDataPath + "/patternImg.jpg")) {
|
||||
if (patternMat.empty ()) {
|
||||
|
||||
patternRawImage.gameObject.SetActive (false);
|
||||
|
||||
} else {
|
||||
|
||||
Imgproc.cvtColor (patternMat, patternMat, Imgproc.COLOR_BGR2RGB);
|
||||
|
||||
Texture2D patternTexture = new Texture2D (patternMat.width (), patternMat.height (), TextureFormat.RGBA32, false);
|
||||
|
||||
Utils.matToTexture2D (patternMat, patternTexture);
|
||||
|
||||
patternRawImage.texture = patternTexture;
|
||||
patternRawImage.rectTransform.localScale = new Vector3 (1.0f, (float)patternMat.height () / (float)patternMat.width (), 1.0f);
|
||||
|
||||
patternRawImage.gameObject.SetActive (true);
|
||||
}
|
||||
}
|
||||
|
||||
webCamTextureToMatHelper = gameObject.GetComponent<WebCamTextureToMatHelper> ();
|
||||
webCamTextureToMatHelper.Init ();
|
||||
|
||||
|
||||
detector = ORB.create ();
|
||||
detector.setMaxFeatures (1000);
|
||||
keypoints = new MatOfKeyPoint ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the web cam texture to mat helper inited event.
|
||||
/// </summary>
|
||||
public void OnWebCamTextureToMatHelperInited ()
|
||||
{
|
||||
Debug.Log ("OnWebCamTextureToMatHelperInited");
|
||||
|
||||
|
||||
Mat webCamTextureMat = webCamTextureToMatHelper.GetMat ();
|
||||
|
||||
texture = new Texture2D (webCamTextureMat.width (), webCamTextureMat.height (), TextureFormat.RGBA32, false);
|
||||
|
||||
rgbMat = new Mat (webCamTextureMat.rows (), webCamTextureMat.cols (), CvType.CV_8UC3);
|
||||
|
||||
|
||||
|
||||
gameObject.transform.localScale = new Vector3 (webCamTextureMat.width (), webCamTextureMat.height (), 1);
|
||||
|
||||
Debug.Log ("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
|
||||
|
||||
|
||||
float width = webCamTextureMat.width ();
|
||||
float height = webCamTextureMat.height ();
|
||||
|
||||
float widthScale = (float)Screen.width / width;
|
||||
float heightScale = (float)Screen.height / height;
|
||||
if (widthScale < heightScale) {
|
||||
Camera.main.orthographicSize = (width * (float)Screen.height / (float)Screen.width) / 2;
|
||||
} else {
|
||||
Camera.main.orthographicSize = height / 2;
|
||||
}
|
||||
|
||||
gameObject.GetComponent<Renderer> ().material.mainTexture = texture;
|
||||
|
||||
|
||||
|
||||
|
||||
//if WebCamera is frontFaceing,flip Mat.
|
||||
if (webCamTextureToMatHelper.GetWebCamDevice ().isFrontFacing) {
|
||||
webCamTextureToMatHelper.flipHorizontal = true;
|
||||
}
|
||||
|
||||
|
||||
int patternWidth = (int)(Mathf.Min (webCamTextureMat.width (), webCamTextureMat.height ()) * 0.8f);
|
||||
|
||||
patternRect = new OpenCVForUnity.Rect (webCamTextureMat.width () / 2 - patternWidth / 2, webCamTextureMat.height () / 2 - patternWidth / 2, patternWidth, patternWidth);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the web cam texture to mat helper disposed event.
|
||||
/// </summary>
|
||||
public void OnWebCamTextureToMatHelperDisposed ()
|
||||
{
|
||||
Debug.Log ("OnWebCamTextureToMatHelperDisposed");
|
||||
|
||||
if (rgbMat != null) {
|
||||
rgbMat.Dispose ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the web cam texture to mat helper error occurred event.
|
||||
/// </summary>
|
||||
/// <param name="errorCode">Error code.</param>
|
||||
public void OnWebCamTextureToMatHelperErrorOccurred (WebCamTextureToMatHelper.ErrorCode errorCode)
|
||||
{
|
||||
Debug.Log ("OnWebCamTextureToMatHelperErrorOccurred " + errorCode);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
if (webCamTextureToMatHelper.IsPlaying () && webCamTextureToMatHelper.DidUpdateThisFrame ()) {
|
||||
|
||||
Mat rgbaMat = webCamTextureToMatHelper.GetMat ();
|
||||
|
||||
Imgproc.cvtColor (rgbaMat, rgbMat, Imgproc.COLOR_RGBA2RGB);
|
||||
|
||||
|
||||
detector.detect (rgbaMat, keypoints);
|
||||
// Debug.Log ("keypoints.ToString() " + keypoints.ToString());
|
||||
Features2d.drawKeypoints (rgbMat, keypoints, rgbaMat, Scalar.all (-1), Features2d.NOT_DRAW_SINGLE_POINTS);
|
||||
|
||||
|
||||
|
||||
Imgproc.rectangle (rgbaMat, patternRect.tl (), patternRect.br (), new Scalar (255, 0, 0, 255), 5);
|
||||
|
||||
|
||||
Utils.matToTexture2D (rgbaMat, texture, webCamTextureToMatHelper.GetBufferColors ());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void OnDisable ()
|
||||
{
|
||||
webCamTextureToMatHelper.Dispose ();
|
||||
|
||||
detector.Dispose ();
|
||||
if (keypoints != null)
|
||||
keypoints.Dispose ();
|
||||
|
||||
// Utils.setDebugMode(false);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Raises the back button event.
|
||||
/// </summary>
|
||||
public void OnBackButton ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("MarkerLessARExample");
|
||||
#else
|
||||
Application.LoadLevel ("MarkerLessARExample");
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the play button event.
|
||||
/// </summary>
|
||||
public void OnPlayButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Play ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the pause button event.
|
||||
/// </summary>
|
||||
public void OnPauseButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Pause ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the stop button event.
|
||||
/// </summary>
|
||||
public void OnStopButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Stop ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the change camera button event.
|
||||
/// </summary>
|
||||
public void OnChangeCameraButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Init (null, webCamTextureToMatHelper.requestWidth, webCamTextureToMatHelper.requestHeight, !webCamTextureToMatHelper.requestIsFrontFacing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the capture button event.
|
||||
/// </summary>
|
||||
public void OnCaptureButton ()
|
||||
{
|
||||
|
||||
Mat patternMat = new Mat (rgbMat, patternRect);
|
||||
|
||||
Texture2D patternTexture = new Texture2D (patternMat.width (), patternMat.height (), TextureFormat.RGBA32, false);
|
||||
|
||||
Utils.matToTexture2D (patternMat, patternTexture);
|
||||
|
||||
patternRawImage.texture = patternTexture;
|
||||
|
||||
patternRawImage.gameObject.SetActive (true);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the save button event.
|
||||
/// </summary>
|
||||
public void OnSaveButton ()
|
||||
{
|
||||
if (patternRawImage.texture != null) {
|
||||
Texture2D patternTexture = (Texture2D)patternRawImage.texture;
|
||||
Mat patternMat = new Mat (patternRect.size (), CvType.CV_8UC3);
|
||||
Utils.texture2DToMat (patternTexture, patternMat);
|
||||
Imgproc.cvtColor (patternMat, patternMat, Imgproc.COLOR_RGB2BGR);
|
||||
|
||||
string savePath = Application.persistentDataPath;
|
||||
Debug.Log ("savePath " + savePath);
|
||||
|
||||
Imgcodecs.imwrite (savePath + "/patternImg.jpg", patternMat);
|
||||
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("WebCamTextureMarkerLessARExample");
|
||||
#else
|
||||
Application.LoadLevel ("WebCamTextureMarkerLessARExample");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,52 +1,52 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
using UnityEngine.SceneManagement;
|
||||
#endif
|
||||
|
||||
namespace MarkerLessARSample
|
||||
{
|
||||
public class MarkerLessARSample : MonoBehaviour
|
||||
{
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnShowLicenseButton ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("ShowLicense");
|
||||
#else
|
||||
Application.LoadLevel ("ShowLicense");
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Texture2DMarkerLessARSample ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("Texture2DMarkerLessARSample");
|
||||
#else
|
||||
Application.LoadLevel ("Texture2DMarkerLessARSample");
|
||||
#endif
|
||||
}
|
||||
|
||||
public void WebCamTextureMarkerLessARSample ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("WebCamTextureMarkerLessARSample");
|
||||
#else
|
||||
Application.LoadLevel ("WebCamTextureMarkerLessARSample");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
using UnityEngine.SceneManagement;
|
||||
#endif
|
||||
|
||||
namespace MarkerLessARExample
|
||||
{
|
||||
public class MarkerLessARExample : MonoBehaviour
|
||||
{
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnShowLicenseButton ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("ShowLicense");
|
||||
#else
|
||||
Application.LoadLevel ("ShowLicense");
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Texture2DMarkerLessARExample ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("Texture2DMarkerLessARExample");
|
||||
#else
|
||||
Application.LoadLevel ("Texture2DMarkerLessARExample");
|
||||
#endif
|
||||
}
|
||||
|
||||
public void WebCamTextureMarkerLessARExample ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("WebCamTextureMarkerLessARExample");
|
||||
#else
|
||||
Application.LoadLevel ("WebCamTextureMarkerLessARExample");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,34 +1,34 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
using UnityEngine.SceneManagement;
|
||||
#endif
|
||||
|
||||
namespace MarkerLessARSample
|
||||
{
|
||||
public class ShowLicense : MonoBehaviour
|
||||
{
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnBackButton ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("MarkerLessARSample");
|
||||
#else
|
||||
Application.LoadLevel ("MarkerLessARSample");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
using UnityEngine.SceneManagement;
|
||||
#endif
|
||||
|
||||
namespace MarkerLessARSample
|
||||
{
|
||||
public class ShowLicense : MonoBehaviour
|
||||
{
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnBackButton ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("MarkerLessARExample");
|
||||
#else
|
||||
Application.LoadLevel ("MarkerLessARExample");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,213 +1,213 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
using UnityEngine.SceneManagement;
|
||||
#endif
|
||||
using OpenCVForUnity;
|
||||
|
||||
namespace MarkerLessARSample
|
||||
{
|
||||
/// <summary>
|
||||
/// Marker Less AR sample from Texture2D.
|
||||
/// https://github.com/MasteringOpenCV/code/tree/master/Chapter3_MarkerlessAR by using "OpenCV for Unity"
|
||||
/// </summary>
|
||||
public class Texture2DMarkerLessARSample : MonoBehaviour
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The pattern texture.
|
||||
/// </summary>
|
||||
public Texture2D patternTexture;
|
||||
|
||||
/// <summary>
|
||||
/// The pattern raw image.
|
||||
/// </summary>
|
||||
public RawImage patternRawImage;
|
||||
|
||||
/// <summary>
|
||||
/// The image texture.
|
||||
/// </summary>
|
||||
public Texture2D imgTexture;
|
||||
|
||||
/// <summary>
|
||||
/// The AR camera.
|
||||
/// </summary>
|
||||
public Camera ARCamera;
|
||||
|
||||
/// <summary>
|
||||
/// The should move AR camera.
|
||||
/// </summary>
|
||||
public bool
|
||||
shouldMoveARCamera;
|
||||
|
||||
/// <summary>
|
||||
/// The AR game object.
|
||||
/// </summary>
|
||||
public GameObject ARGameObject;
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
|
||||
Mat patternMat = new Mat (patternTexture.height, patternTexture.width, CvType.CV_8UC4);
|
||||
|
||||
Utils.texture2DToMat (patternTexture, patternMat);
|
||||
Debug.Log ("patternMat dst ToString " + patternMat.ToString ());
|
||||
|
||||
patternRawImage.texture = patternTexture;
|
||||
patternRawImage.rectTransform.localScale = new Vector3 (1.0f, (float)patternMat.height () / (float)patternMat.width (), 1.0f);
|
||||
|
||||
|
||||
Mat imgMat = new Mat (imgTexture.height, imgTexture.width, CvType.CV_8UC4);
|
||||
|
||||
Utils.texture2DToMat (imgTexture, imgMat);
|
||||
Debug.Log ("imgMat dst ToString " + imgMat.ToString ());
|
||||
|
||||
gameObject.transform.localScale = new Vector3 (imgTexture.width, imgTexture.height, 1);
|
||||
Debug.Log ("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
|
||||
|
||||
|
||||
float width = imgMat.width ();
|
||||
float height = imgMat.height ();
|
||||
|
||||
float imageSizeScale = 1.0f;
|
||||
float widthScale = (float)Screen.width / width;
|
||||
float heightScale = (float)Screen.height / height;
|
||||
if (widthScale < heightScale) {
|
||||
Camera.main.orthographicSize = (width * (float)Screen.height / (float)Screen.width) / 2;
|
||||
imageSizeScale = (float)Screen.height / (float)Screen.width;
|
||||
} else {
|
||||
Camera.main.orthographicSize = height / 2;
|
||||
}
|
||||
|
||||
|
||||
//set cameraparam
|
||||
int max_d = (int)Mathf.Max (width, height);
|
||||
double fx = max_d;
|
||||
double fy = max_d;
|
||||
double cx = width / 2.0f;
|
||||
double cy = height / 2.0f;
|
||||
Mat camMatrix = new Mat (3, 3, CvType.CV_64FC1);
|
||||
camMatrix.put (0, 0, fx);
|
||||
camMatrix.put (0, 1, 0);
|
||||
camMatrix.put (0, 2, cx);
|
||||
camMatrix.put (1, 0, 0);
|
||||
camMatrix.put (1, 1, fy);
|
||||
camMatrix.put (1, 2, cy);
|
||||
camMatrix.put (2, 0, 0);
|
||||
camMatrix.put (2, 1, 0);
|
||||
camMatrix.put (2, 2, 1.0f);
|
||||
Debug.Log ("camMatrix " + camMatrix.dump ());
|
||||
|
||||
|
||||
MatOfDouble distCoeffs = new MatOfDouble (0, 0, 0, 0);
|
||||
Debug.Log ("distCoeffs " + distCoeffs.dump ());
|
||||
|
||||
|
||||
//calibration camera
|
||||
Size imageSize = new Size (width * imageSizeScale, height * imageSizeScale);
|
||||
double apertureWidth = 0;
|
||||
double apertureHeight = 0;
|
||||
double[] fovx = new double[1];
|
||||
double[] fovy = new double[1];
|
||||
double[] focalLength = new double[1];
|
||||
Point principalPoint = new Point (0, 0);
|
||||
double[] aspectratio = new double[1];
|
||||
|
||||
Calib3d.calibrationMatrixValues (camMatrix, imageSize, apertureWidth, apertureHeight, fovx, fovy, focalLength, principalPoint, aspectratio);
|
||||
|
||||
Debug.Log ("imageSize " + imageSize.ToString ());
|
||||
Debug.Log ("apertureWidth " + apertureWidth);
|
||||
Debug.Log ("apertureHeight " + apertureHeight);
|
||||
Debug.Log ("fovx " + fovx [0]);
|
||||
Debug.Log ("fovy " + fovy [0]);
|
||||
Debug.Log ("focalLength " + focalLength [0]);
|
||||
Debug.Log ("principalPoint " + principalPoint.ToString ());
|
||||
Debug.Log ("aspectratio " + aspectratio [0]);
|
||||
|
||||
|
||||
//To convert the difference of the FOV value of the OpenCV and Unity.
|
||||
double fovXScale = (2.0 * Mathf.Atan ((float)(imageSize.width / (2.0 * fx)))) / (Mathf.Atan2 ((float)cx, (float)fx) + Mathf.Atan2 ((float)(imageSize.width - cx), (float)fx));
|
||||
double fovYScale = (2.0 * Mathf.Atan ((float)(imageSize.height / (2.0 * fy)))) / (Mathf.Atan2 ((float)cy, (float)fy) + Mathf.Atan2 ((float)(imageSize.height - cy), (float)fy));
|
||||
|
||||
Debug.Log ("fovXScale " + fovXScale);
|
||||
Debug.Log ("fovYScale " + fovYScale);
|
||||
|
||||
|
||||
//Adjust Unity Camera FOV https://github.com/opencv/opencv/commit/8ed1945ccd52501f5ab22bdec6aa1f91f1e2cfd4
|
||||
if (widthScale < heightScale) {
|
||||
ARCamera.fieldOfView = (float)(fovx [0] * fovXScale);
|
||||
} else {
|
||||
ARCamera.fieldOfView = (float)(fovy [0] * fovYScale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Learning the feature points of the pattern image.
|
||||
Pattern pattern = new Pattern ();
|
||||
PatternTrackingInfo patternTrackingInfo = new PatternTrackingInfo ();
|
||||
|
||||
PatternDetector patternDetector = new PatternDetector (null, null, null, true);
|
||||
|
||||
patternDetector.buildPatternFromImage (patternMat, pattern);
|
||||
patternDetector.train (pattern);
|
||||
|
||||
|
||||
|
||||
bool patternFound = patternDetector.findPattern (imgMat, patternTrackingInfo);
|
||||
|
||||
Debug.Log ("patternFound " + patternFound);
|
||||
|
||||
if (patternFound) {
|
||||
patternTrackingInfo.computePose (pattern, camMatrix, distCoeffs);
|
||||
|
||||
Matrix4x4 transformationM = patternTrackingInfo.pose3d;
|
||||
Debug.Log ("transformationM " + transformationM.ToString ());
|
||||
|
||||
Matrix4x4 invertZM = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, new Vector3 (1, 1, -1));
|
||||
Debug.Log ("invertZM " + invertZM.ToString ());
|
||||
|
||||
Matrix4x4 invertYM = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, new Vector3 (1, -1, 1));
|
||||
Debug.Log ("invertYM " + invertYM.ToString ());
|
||||
|
||||
|
||||
if (shouldMoveARCamera) {
|
||||
Matrix4x4 ARM = ARGameObject.transform.localToWorldMatrix * invertZM * transformationM.inverse * invertYM;
|
||||
Debug.Log ("ARM " + ARM.ToString ());
|
||||
|
||||
ARUtils.SetTransformFromMatrix (ARCamera.transform, ref ARM);
|
||||
} else {
|
||||
|
||||
Matrix4x4 ARM = ARCamera.transform.localToWorldMatrix * invertYM * transformationM * invertZM;
|
||||
Debug.Log ("ARM " + ARM.ToString ());
|
||||
|
||||
ARUtils.SetTransformFromMatrix (ARGameObject.transform, ref ARM);
|
||||
}
|
||||
}
|
||||
|
||||
Texture2D texture = new Texture2D (imgMat.cols (), imgMat.rows (), TextureFormat.RGBA32, false);
|
||||
|
||||
Utils.matToTexture2D (imgMat, texture);
|
||||
|
||||
gameObject.GetComponent<Renderer> ().material.mainTexture = texture;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnBackButton ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("MarkerLessARSample");
|
||||
#else
|
||||
Application.LoadLevel ("MarkerLessARSample");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
using UnityEngine.SceneManagement;
|
||||
#endif
|
||||
using OpenCVForUnity;
|
||||
|
||||
namespace MarkerLessARExample
|
||||
{
|
||||
/// <summary>
|
||||
/// Marker Less AR example from Texture2D.
|
||||
/// https://github.com/MasteringOpenCV/code/tree/master/Chapter3_MarkerlessAR by using "OpenCV for Unity"
|
||||
/// </summary>
|
||||
public class Texture2DMarkerLessARExample : MonoBehaviour
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The pattern texture.
|
||||
/// </summary>
|
||||
public Texture2D patternTexture;
|
||||
|
||||
/// <summary>
|
||||
/// The pattern raw image.
|
||||
/// </summary>
|
||||
public RawImage patternRawImage;
|
||||
|
||||
/// <summary>
|
||||
/// The image texture.
|
||||
/// </summary>
|
||||
public Texture2D imgTexture;
|
||||
|
||||
/// <summary>
|
||||
/// The AR camera.
|
||||
/// </summary>
|
||||
public Camera ARCamera;
|
||||
|
||||
/// <summary>
|
||||
/// The should move AR camera.
|
||||
/// </summary>
|
||||
public bool
|
||||
shouldMoveARCamera;
|
||||
|
||||
/// <summary>
|
||||
/// The AR game object.
|
||||
/// </summary>
|
||||
public GameObject ARGameObject;
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
|
||||
Mat patternMat = new Mat (patternTexture.height, patternTexture.width, CvType.CV_8UC4);
|
||||
|
||||
Utils.texture2DToMat (patternTexture, patternMat);
|
||||
Debug.Log ("patternMat dst ToString " + patternMat.ToString ());
|
||||
|
||||
patternRawImage.texture = patternTexture;
|
||||
patternRawImage.rectTransform.localScale = new Vector3 (1.0f, (float)patternMat.height () / (float)patternMat.width (), 1.0f);
|
||||
|
||||
|
||||
Mat imgMat = new Mat (imgTexture.height, imgTexture.width, CvType.CV_8UC4);
|
||||
|
||||
Utils.texture2DToMat (imgTexture, imgMat);
|
||||
Debug.Log ("imgMat dst ToString " + imgMat.ToString ());
|
||||
|
||||
gameObject.transform.localScale = new Vector3 (imgTexture.width, imgTexture.height, 1);
|
||||
Debug.Log ("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
|
||||
|
||||
|
||||
float width = imgMat.width ();
|
||||
float height = imgMat.height ();
|
||||
|
||||
float imageSizeScale = 1.0f;
|
||||
float widthScale = (float)Screen.width / width;
|
||||
float heightScale = (float)Screen.height / height;
|
||||
if (widthScale < heightScale) {
|
||||
Camera.main.orthographicSize = (width * (float)Screen.height / (float)Screen.width) / 2;
|
||||
imageSizeScale = (float)Screen.height / (float)Screen.width;
|
||||
} else {
|
||||
Camera.main.orthographicSize = height / 2;
|
||||
}
|
||||
|
||||
|
||||
//set cameraparam
|
||||
int max_d = (int)Mathf.Max (width, height);
|
||||
double fx = max_d;
|
||||
double fy = max_d;
|
||||
double cx = width / 2.0f;
|
||||
double cy = height / 2.0f;
|
||||
Mat camMatrix = new Mat (3, 3, CvType.CV_64FC1);
|
||||
camMatrix.put (0, 0, fx);
|
||||
camMatrix.put (0, 1, 0);
|
||||
camMatrix.put (0, 2, cx);
|
||||
camMatrix.put (1, 0, 0);
|
||||
camMatrix.put (1, 1, fy);
|
||||
camMatrix.put (1, 2, cy);
|
||||
camMatrix.put (2, 0, 0);
|
||||
camMatrix.put (2, 1, 0);
|
||||
camMatrix.put (2, 2, 1.0f);
|
||||
Debug.Log ("camMatrix " + camMatrix.dump ());
|
||||
|
||||
|
||||
MatOfDouble distCoeffs = new MatOfDouble (0, 0, 0, 0);
|
||||
Debug.Log ("distCoeffs " + distCoeffs.dump ());
|
||||
|
||||
|
||||
//calibration camera
|
||||
Size imageSize = new Size (width * imageSizeScale, height * imageSizeScale);
|
||||
double apertureWidth = 0;
|
||||
double apertureHeight = 0;
|
||||
double[] fovx = new double[1];
|
||||
double[] fovy = new double[1];
|
||||
double[] focalLength = new double[1];
|
||||
Point principalPoint = new Point (0, 0);
|
||||
double[] aspectratio = new double[1];
|
||||
|
||||
Calib3d.calibrationMatrixValues (camMatrix, imageSize, apertureWidth, apertureHeight, fovx, fovy, focalLength, principalPoint, aspectratio);
|
||||
|
||||
Debug.Log ("imageSize " + imageSize.ToString ());
|
||||
Debug.Log ("apertureWidth " + apertureWidth);
|
||||
Debug.Log ("apertureHeight " + apertureHeight);
|
||||
Debug.Log ("fovx " + fovx [0]);
|
||||
Debug.Log ("fovy " + fovy [0]);
|
||||
Debug.Log ("focalLength " + focalLength [0]);
|
||||
Debug.Log ("principalPoint " + principalPoint.ToString ());
|
||||
Debug.Log ("aspectratio " + aspectratio [0]);
|
||||
|
||||
|
||||
//To convert the difference of the FOV value of the OpenCV and Unity.
|
||||
double fovXScale = (2.0 * Mathf.Atan ((float)(imageSize.width / (2.0 * fx)))) / (Mathf.Atan2 ((float)cx, (float)fx) + Mathf.Atan2 ((float)(imageSize.width - cx), (float)fx));
|
||||
double fovYScale = (2.0 * Mathf.Atan ((float)(imageSize.height / (2.0 * fy)))) / (Mathf.Atan2 ((float)cy, (float)fy) + Mathf.Atan2 ((float)(imageSize.height - cy), (float)fy));
|
||||
|
||||
Debug.Log ("fovXScale " + fovXScale);
|
||||
Debug.Log ("fovYScale " + fovYScale);
|
||||
|
||||
|
||||
//Adjust Unity Camera FOV https://github.com/opencv/opencv/commit/8ed1945ccd52501f5ab22bdec6aa1f91f1e2cfd4
|
||||
if (widthScale < heightScale) {
|
||||
ARCamera.fieldOfView = (float)(fovx [0] * fovXScale);
|
||||
} else {
|
||||
ARCamera.fieldOfView = (float)(fovy [0] * fovYScale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Learning the feature points of the pattern image.
|
||||
Pattern pattern = new Pattern ();
|
||||
PatternTrackingInfo patternTrackingInfo = new PatternTrackingInfo ();
|
||||
|
||||
PatternDetector patternDetector = new PatternDetector (null, null, null, true);
|
||||
|
||||
patternDetector.buildPatternFromImage (patternMat, pattern);
|
||||
patternDetector.train (pattern);
|
||||
|
||||
|
||||
|
||||
bool patternFound = patternDetector.findPattern (imgMat, patternTrackingInfo);
|
||||
|
||||
Debug.Log ("patternFound " + patternFound);
|
||||
|
||||
if (patternFound) {
|
||||
patternTrackingInfo.computePose (pattern, camMatrix, distCoeffs);
|
||||
|
||||
Matrix4x4 transformationM = patternTrackingInfo.pose3d;
|
||||
Debug.Log ("transformationM " + transformationM.ToString ());
|
||||
|
||||
Matrix4x4 invertZM = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, new Vector3 (1, 1, -1));
|
||||
Debug.Log ("invertZM " + invertZM.ToString ());
|
||||
|
||||
Matrix4x4 invertYM = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, new Vector3 (1, -1, 1));
|
||||
Debug.Log ("invertYM " + invertYM.ToString ());
|
||||
|
||||
|
||||
if (shouldMoveARCamera) {
|
||||
Matrix4x4 ARM = ARGameObject.transform.localToWorldMatrix * invertZM * transformationM.inverse * invertYM;
|
||||
Debug.Log ("ARM " + ARM.ToString ());
|
||||
|
||||
ARUtils.SetTransformFromMatrix (ARCamera.transform, ref ARM);
|
||||
} else {
|
||||
|
||||
Matrix4x4 ARM = ARCamera.transform.localToWorldMatrix * invertYM * transformationM * invertZM;
|
||||
Debug.Log ("ARM " + ARM.ToString ());
|
||||
|
||||
ARUtils.SetTransformFromMatrix (ARGameObject.transform, ref ARM);
|
||||
}
|
||||
}
|
||||
|
||||
Texture2D texture = new Texture2D (imgMat.cols (), imgMat.rows (), TextureFormat.RGBA32, false);
|
||||
|
||||
Utils.matToTexture2D (imgMat, texture);
|
||||
|
||||
gameObject.GetComponent<Renderer> ().material.mainTexture = texture;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnBackButton ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("MarkerLessARExample");
|
||||
#else
|
||||
Application.LoadLevel ("MarkerLessARExample");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 58676de949dc2e645a1f61fe2785773d
|
||||
folderAsset: yes
|
||||
timeCreated: 1486749544
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,7 +1,7 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace MarkerLessARSample
|
||||
namespace MarkerLessARExample
|
||||
{
|
||||
/// <summary>
|
||||
/// AR utils.
|
|
@ -1,71 +1,71 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace MarkerLessARSample
|
||||
{
|
||||
public class DelayableSetActive : MonoBehaviour
|
||||
{
|
||||
|
||||
// private Coroutine activateCoroutine;
|
||||
private Coroutine deactivateCoroutine;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the active.
|
||||
/// </summary>
|
||||
/// <param name="value">If set to <c>true</c> value.</param>
|
||||
/// <param name="delayTime">Delay time.</param>
|
||||
public void SetActive (bool value, float delayTime = 0.0f)
|
||||
{
|
||||
|
||||
if (value) {
|
||||
if (deactivateCoroutine != null) {
|
||||
StopCoroutine (deactivateCoroutine);
|
||||
deactivateCoroutine = null;
|
||||
}
|
||||
|
||||
|
||||
gameObject.SetActive (value);
|
||||
|
||||
|
||||
// if (!gameObject.activeSelf && activateCoroutine == null)
|
||||
// activateCoroutine = StartCoroutine (ActivateGameObject (delayTime));
|
||||
|
||||
} else {
|
||||
// if (activateCoroutine != null) {
|
||||
// StopCoroutine (activateCoroutine);
|
||||
// activateCoroutine = null;
|
||||
// }
|
||||
|
||||
if (delayTime == 0.0f) {
|
||||
gameObject.SetActive (value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameObject.activeSelf && deactivateCoroutine == null)
|
||||
deactivateCoroutine = StartCoroutine (DeactivateGameObject (delayTime));
|
||||
}
|
||||
}
|
||||
|
||||
// private IEnumerator ActivateGameObject (float delayTime)
|
||||
// {
|
||||
// Debug.Log ("ActivateGameObject start");
|
||||
//
|
||||
// yield return new WaitForSeconds (delayTime);
|
||||
//
|
||||
// gameObject.SetActive (true);
|
||||
// activateCoroutine = null;
|
||||
//
|
||||
// Debug.Log ("ActivateGameObject end");
|
||||
// }
|
||||
|
||||
private IEnumerator DeactivateGameObject (float delayTime)
|
||||
{
|
||||
|
||||
yield return new WaitForSeconds (delayTime);
|
||||
|
||||
gameObject.SetActive (false);
|
||||
deactivateCoroutine = null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace MarkerLessARExample
|
||||
{
|
||||
public class DelayableSetActive : MonoBehaviour
|
||||
{
|
||||
|
||||
// private Coroutine activateCoroutine;
|
||||
private Coroutine deactivateCoroutine;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the active.
|
||||
/// </summary>
|
||||
/// <param name="value">If set to <c>true</c> value.</param>
|
||||
/// <param name="delayTime">Delay time.</param>
|
||||
public void SetActive (bool value, float delayTime = 0.0f)
|
||||
{
|
||||
|
||||
if (value) {
|
||||
if (deactivateCoroutine != null) {
|
||||
StopCoroutine (deactivateCoroutine);
|
||||
deactivateCoroutine = null;
|
||||
}
|
||||
|
||||
|
||||
gameObject.SetActive (value);
|
||||
|
||||
|
||||
// if (!gameObject.activeSelf && activateCoroutine == null)
|
||||
// activateCoroutine = StartCoroutine (ActivateGameObject (delayTime));
|
||||
|
||||
} else {
|
||||
// if (activateCoroutine != null) {
|
||||
// StopCoroutine (activateCoroutine);
|
||||
// activateCoroutine = null;
|
||||
// }
|
||||
|
||||
if (delayTime == 0.0f) {
|
||||
gameObject.SetActive (value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameObject.activeSelf && deactivateCoroutine == null)
|
||||
deactivateCoroutine = StartCoroutine (DeactivateGameObject (delayTime));
|
||||
}
|
||||
}
|
||||
|
||||
// private IEnumerator ActivateGameObject (float delayTime)
|
||||
// {
|
||||
// Debug.Log ("ActivateGameObject start");
|
||||
//
|
||||
// yield return new WaitForSeconds (delayTime);
|
||||
//
|
||||
// gameObject.SetActive (true);
|
||||
// activateCoroutine = null;
|
||||
//
|
||||
// Debug.Log ("ActivateGameObject end");
|
||||
// }
|
||||
|
||||
private IEnumerator DeactivateGameObject (float delayTime)
|
||||
{
|
||||
|
||||
yield return new WaitForSeconds (delayTime);
|
||||
|
||||
gameObject.SetActive (false);
|
||||
deactivateCoroutine = null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,10 +3,10 @@ using System.Collections;
|
|||
|
||||
using OpenCVForUnity;
|
||||
|
||||
namespace MarkerLessARSample
|
||||
namespace MarkerLessARExample
|
||||
{
|
||||
/// <summary>
|
||||
/// VideoCapture sample.
|
||||
/// VideoCapture example.
|
||||
/// </summary>
|
||||
public class DisplayVideo : MonoBehaviour
|
||||
{
|
|
@ -4,7 +4,7 @@ using System.Collections;
|
|||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace MarkerLessARSample
|
||||
namespace MarkerLessARExample
|
||||
{
|
||||
/// <summary>
|
||||
/// Web cam texture to mat helper.
|
|
@ -1,489 +1,489 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
using UnityEngine.SceneManagement;
|
||||
#endif
|
||||
using OpenCVForUnity;
|
||||
|
||||
namespace MarkerLessARSample
|
||||
{
|
||||
/// <summary>
|
||||
/// Marker Less AR sample from WebCamTexture.
|
||||
/// https://github.com/MasteringOpenCV/code/tree/master/Chapter3_MarkerlessAR by using "OpenCV for Unity"
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(WebCamTextureToMatHelper))]
|
||||
public class WebCamTextureMarkerLessARSample : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// The pattern mat.
|
||||
/// </summary>
|
||||
Mat patternMat;
|
||||
|
||||
/// <summary>
|
||||
/// The pattern raw image.
|
||||
/// </summary>
|
||||
public RawImage patternRawImage;
|
||||
|
||||
/// <summary>
|
||||
/// The texture.
|
||||
/// </summary>
|
||||
Texture2D texture;
|
||||
|
||||
/// <summary>
|
||||
/// The web cam texture to mat helper.
|
||||
/// </summary>
|
||||
WebCamTextureToMatHelper webCamTextureToMatHelper;
|
||||
|
||||
/// <summary>
|
||||
/// The gray mat.
|
||||
/// </summary>
|
||||
Mat grayMat;
|
||||
|
||||
/// <summary>
|
||||
/// The AR game object.
|
||||
/// </summary>
|
||||
public GameObject ARGameObject;
|
||||
|
||||
/// <summary>
|
||||
/// The AR camera.
|
||||
/// </summary>
|
||||
public Camera ARCamera;
|
||||
|
||||
/// <summary>
|
||||
/// The cam matrix.
|
||||
/// </summary>
|
||||
Mat camMatrix;
|
||||
|
||||
/// <summary>
|
||||
/// The dist coeffs.
|
||||
/// </summary>
|
||||
MatOfDouble distCoeffs;
|
||||
|
||||
/// <summary>
|
||||
/// The invert Y.
|
||||
/// </summary>
|
||||
Matrix4x4 invertYM;
|
||||
|
||||
/// <summary>
|
||||
/// The transformation m.
|
||||
/// </summary>
|
||||
Matrix4x4 transformationM;
|
||||
|
||||
/// <summary>
|
||||
/// The invert Z.
|
||||
/// </summary>
|
||||
Matrix4x4 invertZM;
|
||||
|
||||
/// <summary>
|
||||
/// The ar m.
|
||||
/// </summary>
|
||||
Matrix4x4 ARM;
|
||||
|
||||
/// <summary>
|
||||
/// The should move AR camera.
|
||||
/// </summary>
|
||||
public bool shouldMoveARCamera;
|
||||
|
||||
/// <summary>
|
||||
/// The pattern.
|
||||
/// </summary>
|
||||
Pattern pattern;
|
||||
|
||||
/// <summary>
|
||||
/// The pattern tracking info.
|
||||
/// </summary>
|
||||
PatternTrackingInfo patternTrackingInfo;
|
||||
|
||||
/// <summary>
|
||||
/// The pattern detector.
|
||||
/// </summary>
|
||||
PatternDetector patternDetector;
|
||||
|
||||
/// <summary>
|
||||
/// The is showing axes.
|
||||
/// </summary>
|
||||
public bool isShowingAxes = false;
|
||||
|
||||
/// <summary>
|
||||
/// The is showing axes toggle.
|
||||
/// </summary>
|
||||
public Toggle isShowingAxesToggle;
|
||||
|
||||
/// <summary>
|
||||
/// The axes.
|
||||
/// </summary>
|
||||
public GameObject axes;
|
||||
|
||||
/// <summary>
|
||||
/// The is showing cube.
|
||||
/// </summary>
|
||||
public bool isShowingCube = false;
|
||||
|
||||
/// <summary>
|
||||
/// The is showing cube toggle.
|
||||
/// </summary>
|
||||
public Toggle isShowingCubeToggle;
|
||||
|
||||
/// <summary>
|
||||
/// The cube.
|
||||
/// </summary>
|
||||
public GameObject cube;
|
||||
|
||||
/// <summary>
|
||||
/// The is showing video.
|
||||
/// </summary>
|
||||
public bool isShowingVideo = false;
|
||||
|
||||
/// <summary>
|
||||
/// The is showing video toggle.
|
||||
/// </summary>
|
||||
public Toggle isShowingVideoToggle;
|
||||
|
||||
/// <summary>
|
||||
/// The video.
|
||||
/// </summary>
|
||||
public GameObject video;
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
|
||||
isShowingAxesToggle.isOn = isShowingAxes;
|
||||
axes.SetActive (isShowingAxes);
|
||||
isShowingCubeToggle.isOn = isShowingCube;
|
||||
cube.SetActive (isShowingCube);
|
||||
isShowingVideoToggle.isOn = isShowingVideo;
|
||||
video.SetActive (isShowingVideo);
|
||||
|
||||
ARGameObject.gameObject.SetActive (false);
|
||||
|
||||
|
||||
|
||||
webCamTextureToMatHelper = gameObject.GetComponent<WebCamTextureToMatHelper> ();
|
||||
|
||||
patternMat = Imgcodecs.imread (Application.persistentDataPath + "/patternImg.jpg");
|
||||
|
||||
if (patternMat.empty ()) {
|
||||
|
||||
OnPatternCaptureButton ();
|
||||
} else {
|
||||
|
||||
Imgproc.cvtColor (patternMat, patternMat, Imgproc.COLOR_BGR2RGB);
|
||||
|
||||
Texture2D patternTexture = new Texture2D (patternMat.width (), patternMat.height (), TextureFormat.RGBA32, false);
|
||||
Utils.matToTexture2D (patternMat, patternTexture);
|
||||
Debug.Log ("patternMat dst ToString " + patternMat.ToString ());
|
||||
|
||||
patternRawImage.texture = patternTexture;
|
||||
patternRawImage.rectTransform.localScale = new Vector3 (1.0f, (float)patternMat.height () / (float)patternMat.width (), 1.0f);
|
||||
|
||||
pattern = new Pattern ();
|
||||
patternTrackingInfo = new PatternTrackingInfo ();
|
||||
|
||||
patternDetector = new PatternDetector (null, null, null, true);
|
||||
|
||||
patternDetector.buildPatternFromImage (patternMat, pattern);
|
||||
patternDetector.train (pattern);
|
||||
|
||||
|
||||
webCamTextureToMatHelper.Init ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the web cam texture to mat helper inited event.
|
||||
/// </summary>
|
||||
public void OnWebCamTextureToMatHelperInited ()
|
||||
{
|
||||
Debug.Log ("OnWebCamTextureToMatHelperInited");
|
||||
|
||||
|
||||
Mat webCamTextureMat = webCamTextureToMatHelper.GetMat ();
|
||||
|
||||
texture = new Texture2D (webCamTextureMat.width(), webCamTextureMat.height(), TextureFormat.RGBA32, false);
|
||||
gameObject.GetComponent<Renderer> ().material.mainTexture = texture;
|
||||
|
||||
|
||||
grayMat = new Mat (webCamTextureMat.rows (), webCamTextureMat.cols (), CvType.CV_8UC1);
|
||||
|
||||
|
||||
gameObject.transform.localScale = new Vector3 (webCamTextureMat.width(), webCamTextureMat.height(), 1);
|
||||
|
||||
Debug.Log ("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
|
||||
|
||||
|
||||
|
||||
float width = webCamTextureMat.width ();
|
||||
float height = webCamTextureMat.height ();
|
||||
|
||||
float imageSizeScale = 1.0f;
|
||||
float widthScale = (float)Screen.width / width;
|
||||
float heightScale = (float)Screen.height / height;
|
||||
if (widthScale < heightScale) {
|
||||
Camera.main.orthographicSize = (width * (float)Screen.height / (float)Screen.width) / 2;
|
||||
imageSizeScale = (float)Screen.height / (float)Screen.width;
|
||||
} else {
|
||||
Camera.main.orthographicSize = height / 2;
|
||||
}
|
||||
|
||||
|
||||
//set cameraparam
|
||||
int max_d = (int)Mathf.Max (width, height);
|
||||
double fx = max_d;
|
||||
double fy = max_d;
|
||||
double cx = width / 2.0f;
|
||||
double cy = height / 2.0f;
|
||||
camMatrix = new Mat (3, 3, CvType.CV_64FC1);
|
||||
camMatrix.put (0, 0, fx);
|
||||
camMatrix.put (0, 1, 0);
|
||||
camMatrix.put (0, 2, cx);
|
||||
camMatrix.put (1, 0, 0);
|
||||
camMatrix.put (1, 1, fy);
|
||||
camMatrix.put (1, 2, cy);
|
||||
camMatrix.put (2, 0, 0);
|
||||
camMatrix.put (2, 1, 0);
|
||||
camMatrix.put (2, 2, 1.0f);
|
||||
Debug.Log ("camMatrix " + camMatrix.dump ());
|
||||
|
||||
|
||||
distCoeffs = new MatOfDouble (0, 0, 0, 0);
|
||||
Debug.Log ("distCoeffs " + distCoeffs.dump ());
|
||||
|
||||
|
||||
//calibration camera
|
||||
Size imageSize = new Size (width * imageSizeScale, height * imageSizeScale);
|
||||
double apertureWidth = 0;
|
||||
double apertureHeight = 0;
|
||||
double[] fovx = new double[1];
|
||||
double[] fovy = new double[1];
|
||||
double[] focalLength = new double[1];
|
||||
Point principalPoint = new Point (0, 0);
|
||||
double[] aspectratio = new double[1];
|
||||
|
||||
Calib3d.calibrationMatrixValues (camMatrix, imageSize, apertureWidth, apertureHeight, fovx, fovy, focalLength, principalPoint, aspectratio);
|
||||
|
||||
Debug.Log ("imageSize " + imageSize.ToString ());
|
||||
Debug.Log ("apertureWidth " + apertureWidth);
|
||||
Debug.Log ("apertureHeight " + apertureHeight);
|
||||
Debug.Log ("fovx " + fovx [0]);
|
||||
Debug.Log ("fovy " + fovy [0]);
|
||||
Debug.Log ("focalLength " + focalLength [0]);
|
||||
Debug.Log ("principalPoint " + principalPoint.ToString ());
|
||||
Debug.Log ("aspectratio " + aspectratio [0]);
|
||||
|
||||
|
||||
//To convert the difference of the FOV value of the OpenCV and Unity.
|
||||
double fovXScale = (2.0 * Mathf.Atan ((float)(imageSize.width / (2.0 * fx)))) / (Mathf.Atan2 ((float)cx, (float)fx) + Mathf.Atan2 ((float)(imageSize.width - cx), (float)fx));
|
||||
double fovYScale = (2.0 * Mathf.Atan ((float)(imageSize.height / (2.0 * fy)))) / (Mathf.Atan2 ((float)cy, (float)fy) + Mathf.Atan2 ((float)(imageSize.height - cy), (float)fy));
|
||||
|
||||
Debug.Log ("fovXScale " + fovXScale);
|
||||
Debug.Log ("fovYScale " + fovYScale);
|
||||
|
||||
|
||||
//Adjust Unity Camera FOV https://github.com/opencv/opencv/commit/8ed1945ccd52501f5ab22bdec6aa1f91f1e2cfd4
|
||||
if (widthScale < heightScale) {
|
||||
ARCamera.fieldOfView = (float)(fovx [0] * fovXScale);
|
||||
} else {
|
||||
ARCamera.fieldOfView = (float)(fovy [0] * fovYScale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
transformationM = new Matrix4x4 ();
|
||||
|
||||
invertYM = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, new Vector3 (1, -1, 1));
|
||||
Debug.Log ("invertYM " + invertYM.ToString ());
|
||||
|
||||
invertZM = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, new Vector3 (1, 1, -1));
|
||||
Debug.Log ("invertZM " + invertZM.ToString ());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//if WebCamera is frontFaceing,flip Mat.
|
||||
if (webCamTextureToMatHelper.GetWebCamDevice ().isFrontFacing) {
|
||||
webCamTextureToMatHelper.flipHorizontal = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the web cam texture to mat helper disposed event.
|
||||
/// </summary>
|
||||
public void OnWebCamTextureToMatHelperDisposed ()
|
||||
{
|
||||
Debug.Log ("OnWebCamTextureToMatHelperDisposed");
|
||||
|
||||
if (grayMat != null)
|
||||
grayMat.Dispose ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the web cam texture to mat helper error occurred event.
|
||||
/// </summary>
|
||||
/// <param name="errorCode">Error code.</param>
|
||||
public void OnWebCamTextureToMatHelperErrorOccurred(WebCamTextureToMatHelper.ErrorCode errorCode){
|
||||
Debug.Log ("OnWebCamTextureToMatHelperErrorOccurred " + errorCode);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
if (webCamTextureToMatHelper.IsPlaying () && webCamTextureToMatHelper.DidUpdateThisFrame ()) {
|
||||
|
||||
Mat rgbaMat = webCamTextureToMatHelper.GetMat ();
|
||||
|
||||
Imgproc.cvtColor (rgbaMat, grayMat, Imgproc.COLOR_RGBA2GRAY);
|
||||
|
||||
|
||||
bool patternFound = patternDetector.findPattern (grayMat, patternTrackingInfo);
|
||||
|
||||
// Debug.Log ("patternFound " + patternFound);
|
||||
if (patternFound) {
|
||||
patternTrackingInfo.computePose (pattern, camMatrix, distCoeffs);
|
||||
|
||||
//Marker to Camera Coordinate System Convert Matrix
|
||||
transformationM = patternTrackingInfo.pose3d;
|
||||
//Debug.Log ("transformationM " + transformationM.ToString ());
|
||||
|
||||
if (shouldMoveARCamera) {
|
||||
ARM = ARGameObject.transform.localToWorldMatrix * invertZM * transformationM.inverse * invertYM;
|
||||
//Debug.Log ("ARM " + ARM.ToString ());
|
||||
|
||||
ARUtils.SetTransformFromMatrix (ARCamera.transform, ref ARM);
|
||||
} else {
|
||||
|
||||
ARM = ARCamera.transform.localToWorldMatrix * invertYM * transformationM * invertZM;
|
||||
//Debug.Log ("ARM " + ARM.ToString ());
|
||||
|
||||
ARUtils.SetTransformFromMatrix (ARGameObject.transform, ref ARM);
|
||||
}
|
||||
|
||||
ARGameObject.GetComponent<DelayableSetActive> ().SetActive (true);
|
||||
} else {
|
||||
|
||||
ARGameObject.GetComponent<DelayableSetActive> ().SetActive (false, 0.5f);
|
||||
}
|
||||
|
||||
|
||||
Utils.matToTexture2D (rgbaMat, texture, webCamTextureToMatHelper.GetBufferColors ());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the disable event.
|
||||
/// </summary>
|
||||
void OnDisable ()
|
||||
{
|
||||
webCamTextureToMatHelper.Dispose ();
|
||||
|
||||
if (patternMat != null)
|
||||
patternMat.Dispose ();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Raises the back button event.
|
||||
/// </summary>
|
||||
public void OnBackButton ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("MarkerLessARSample");
|
||||
#else
|
||||
Application.LoadLevel ("MarkerLessARSample");
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the play button event.
|
||||
/// </summary>
|
||||
public void OnPlayButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Play ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the pause button event.
|
||||
/// </summary>
|
||||
public void OnPauseButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Pause ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the stop button event.
|
||||
/// </summary>
|
||||
public void OnStopButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Stop ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the change camera button event.
|
||||
/// </summary>
|
||||
public void OnChangeCameraButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Init (null, webCamTextureToMatHelper.requestWidth, webCamTextureToMatHelper.requestHeight, !webCamTextureToMatHelper.requestIsFrontFacing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the is showing axes toggle event.
|
||||
/// </summary>
|
||||
public void OnIsShowingAxesToggle ()
|
||||
{
|
||||
if (isShowingAxesToggle.isOn) {
|
||||
isShowingAxes = true;
|
||||
} else {
|
||||
isShowingAxes = false;
|
||||
}
|
||||
axes.SetActive (isShowingAxes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the is showing cube toggle event.
|
||||
/// </summary>
|
||||
public void OnIsShowingCubeToggle ()
|
||||
{
|
||||
if (isShowingCubeToggle.isOn) {
|
||||
isShowingCube = true;
|
||||
} else {
|
||||
isShowingCube = false;
|
||||
}
|
||||
cube.SetActive (isShowingCube);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the is showing video toggle event.
|
||||
/// </summary>
|
||||
public void OnIsShowingVideoToggle ()
|
||||
{
|
||||
if (isShowingVideoToggle.isOn) {
|
||||
isShowingVideo = true;
|
||||
} else {
|
||||
isShowingVideo = false;
|
||||
}
|
||||
video.SetActive (isShowingVideo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the pattern capture button event.
|
||||
/// </summary>
|
||||
public void OnPatternCaptureButton ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("CapturePattern");
|
||||
#else
|
||||
Application.LoadLevel ("CapturePattern");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
using UnityEngine.SceneManagement;
|
||||
#endif
|
||||
using OpenCVForUnity;
|
||||
|
||||
namespace MarkerLessARExample
|
||||
{
|
||||
/// <summary>
|
||||
/// Marker Less AR example from WebCamTexture.
|
||||
/// https://github.com/MasteringOpenCV/code/tree/master/Chapter3_MarkerlessAR by using "OpenCV for Unity"
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(WebCamTextureToMatHelper))]
|
||||
public class WebCamTextureMarkerLessARExample : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// The pattern mat.
|
||||
/// </summary>
|
||||
Mat patternMat;
|
||||
|
||||
/// <summary>
|
||||
/// The pattern raw image.
|
||||
/// </summary>
|
||||
public RawImage patternRawImage;
|
||||
|
||||
/// <summary>
|
||||
/// The texture.
|
||||
/// </summary>
|
||||
Texture2D texture;
|
||||
|
||||
/// <summary>
|
||||
/// The web cam texture to mat helper.
|
||||
/// </summary>
|
||||
WebCamTextureToMatHelper webCamTextureToMatHelper;
|
||||
|
||||
/// <summary>
|
||||
/// The gray mat.
|
||||
/// </summary>
|
||||
Mat grayMat;
|
||||
|
||||
/// <summary>
|
||||
/// The AR game object.
|
||||
/// </summary>
|
||||
public GameObject ARGameObject;
|
||||
|
||||
/// <summary>
|
||||
/// The AR camera.
|
||||
/// </summary>
|
||||
public Camera ARCamera;
|
||||
|
||||
/// <summary>
|
||||
/// The cam matrix.
|
||||
/// </summary>
|
||||
Mat camMatrix;
|
||||
|
||||
/// <summary>
|
||||
/// The dist coeffs.
|
||||
/// </summary>
|
||||
MatOfDouble distCoeffs;
|
||||
|
||||
/// <summary>
|
||||
/// The invert Y.
|
||||
/// </summary>
|
||||
Matrix4x4 invertYM;
|
||||
|
||||
/// <summary>
|
||||
/// The transformation m.
|
||||
/// </summary>
|
||||
Matrix4x4 transformationM;
|
||||
|
||||
/// <summary>
|
||||
/// The invert Z.
|
||||
/// </summary>
|
||||
Matrix4x4 invertZM;
|
||||
|
||||
/// <summary>
|
||||
/// The ar m.
|
||||
/// </summary>
|
||||
Matrix4x4 ARM;
|
||||
|
||||
/// <summary>
|
||||
/// The should move AR camera.
|
||||
/// </summary>
|
||||
public bool shouldMoveARCamera;
|
||||
|
||||
/// <summary>
|
||||
/// The pattern.
|
||||
/// </summary>
|
||||
Pattern pattern;
|
||||
|
||||
/// <summary>
|
||||
/// The pattern tracking info.
|
||||
/// </summary>
|
||||
PatternTrackingInfo patternTrackingInfo;
|
||||
|
||||
/// <summary>
|
||||
/// The pattern detector.
|
||||
/// </summary>
|
||||
PatternDetector patternDetector;
|
||||
|
||||
/// <summary>
|
||||
/// The is showing axes.
|
||||
/// </summary>
|
||||
public bool isShowingAxes = false;
|
||||
|
||||
/// <summary>
|
||||
/// The is showing axes toggle.
|
||||
/// </summary>
|
||||
public Toggle isShowingAxesToggle;
|
||||
|
||||
/// <summary>
|
||||
/// The axes.
|
||||
/// </summary>
|
||||
public GameObject axes;
|
||||
|
||||
/// <summary>
|
||||
/// The is showing cube.
|
||||
/// </summary>
|
||||
public bool isShowingCube = false;
|
||||
|
||||
/// <summary>
|
||||
/// The is showing cube toggle.
|
||||
/// </summary>
|
||||
public Toggle isShowingCubeToggle;
|
||||
|
||||
/// <summary>
|
||||
/// The cube.
|
||||
/// </summary>
|
||||
public GameObject cube;
|
||||
|
||||
/// <summary>
|
||||
/// The is showing video.
|
||||
/// </summary>
|
||||
public bool isShowingVideo = false;
|
||||
|
||||
/// <summary>
|
||||
/// The is showing video toggle.
|
||||
/// </summary>
|
||||
public Toggle isShowingVideoToggle;
|
||||
|
||||
/// <summary>
|
||||
/// The video.
|
||||
/// </summary>
|
||||
public GameObject video;
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
|
||||
isShowingAxesToggle.isOn = isShowingAxes;
|
||||
axes.SetActive (isShowingAxes);
|
||||
isShowingCubeToggle.isOn = isShowingCube;
|
||||
cube.SetActive (isShowingCube);
|
||||
isShowingVideoToggle.isOn = isShowingVideo;
|
||||
video.SetActive (isShowingVideo);
|
||||
|
||||
ARGameObject.gameObject.SetActive (false);
|
||||
|
||||
|
||||
|
||||
webCamTextureToMatHelper = gameObject.GetComponent<WebCamTextureToMatHelper> ();
|
||||
|
||||
patternMat = Imgcodecs.imread (Application.persistentDataPath + "/patternImg.jpg");
|
||||
|
||||
if (patternMat.empty ()) {
|
||||
|
||||
OnPatternCaptureButton ();
|
||||
} else {
|
||||
|
||||
Imgproc.cvtColor (patternMat, patternMat, Imgproc.COLOR_BGR2RGB);
|
||||
|
||||
Texture2D patternTexture = new Texture2D (patternMat.width (), patternMat.height (), TextureFormat.RGBA32, false);
|
||||
Utils.matToTexture2D (patternMat, patternTexture);
|
||||
Debug.Log ("patternMat dst ToString " + patternMat.ToString ());
|
||||
|
||||
patternRawImage.texture = patternTexture;
|
||||
patternRawImage.rectTransform.localScale = new Vector3 (1.0f, (float)patternMat.height () / (float)patternMat.width (), 1.0f);
|
||||
|
||||
pattern = new Pattern ();
|
||||
patternTrackingInfo = new PatternTrackingInfo ();
|
||||
|
||||
patternDetector = new PatternDetector (null, null, null, true);
|
||||
|
||||
patternDetector.buildPatternFromImage (patternMat, pattern);
|
||||
patternDetector.train (pattern);
|
||||
|
||||
|
||||
webCamTextureToMatHelper.Init ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the web cam texture to mat helper inited event.
|
||||
/// </summary>
|
||||
public void OnWebCamTextureToMatHelperInited ()
|
||||
{
|
||||
Debug.Log ("OnWebCamTextureToMatHelperInited");
|
||||
|
||||
|
||||
Mat webCamTextureMat = webCamTextureToMatHelper.GetMat ();
|
||||
|
||||
texture = new Texture2D (webCamTextureMat.width(), webCamTextureMat.height(), TextureFormat.RGBA32, false);
|
||||
gameObject.GetComponent<Renderer> ().material.mainTexture = texture;
|
||||
|
||||
|
||||
grayMat = new Mat (webCamTextureMat.rows (), webCamTextureMat.cols (), CvType.CV_8UC1);
|
||||
|
||||
|
||||
gameObject.transform.localScale = new Vector3 (webCamTextureMat.width(), webCamTextureMat.height(), 1);
|
||||
|
||||
Debug.Log ("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
|
||||
|
||||
|
||||
|
||||
float width = webCamTextureMat.width ();
|
||||
float height = webCamTextureMat.height ();
|
||||
|
||||
float imageSizeScale = 1.0f;
|
||||
float widthScale = (float)Screen.width / width;
|
||||
float heightScale = (float)Screen.height / height;
|
||||
if (widthScale < heightScale) {
|
||||
Camera.main.orthographicSize = (width * (float)Screen.height / (float)Screen.width) / 2;
|
||||
imageSizeScale = (float)Screen.height / (float)Screen.width;
|
||||
} else {
|
||||
Camera.main.orthographicSize = height / 2;
|
||||
}
|
||||
|
||||
|
||||
//set cameraparam
|
||||
int max_d = (int)Mathf.Max (width, height);
|
||||
double fx = max_d;
|
||||
double fy = max_d;
|
||||
double cx = width / 2.0f;
|
||||
double cy = height / 2.0f;
|
||||
camMatrix = new Mat (3, 3, CvType.CV_64FC1);
|
||||
camMatrix.put (0, 0, fx);
|
||||
camMatrix.put (0, 1, 0);
|
||||
camMatrix.put (0, 2, cx);
|
||||
camMatrix.put (1, 0, 0);
|
||||
camMatrix.put (1, 1, fy);
|
||||
camMatrix.put (1, 2, cy);
|
||||
camMatrix.put (2, 0, 0);
|
||||
camMatrix.put (2, 1, 0);
|
||||
camMatrix.put (2, 2, 1.0f);
|
||||
Debug.Log ("camMatrix " + camMatrix.dump ());
|
||||
|
||||
|
||||
distCoeffs = new MatOfDouble (0, 0, 0, 0);
|
||||
Debug.Log ("distCoeffs " + distCoeffs.dump ());
|
||||
|
||||
|
||||
//calibration camera
|
||||
Size imageSize = new Size (width * imageSizeScale, height * imageSizeScale);
|
||||
double apertureWidth = 0;
|
||||
double apertureHeight = 0;
|
||||
double[] fovx = new double[1];
|
||||
double[] fovy = new double[1];
|
||||
double[] focalLength = new double[1];
|
||||
Point principalPoint = new Point (0, 0);
|
||||
double[] aspectratio = new double[1];
|
||||
|
||||
Calib3d.calibrationMatrixValues (camMatrix, imageSize, apertureWidth, apertureHeight, fovx, fovy, focalLength, principalPoint, aspectratio);
|
||||
|
||||
Debug.Log ("imageSize " + imageSize.ToString ());
|
||||
Debug.Log ("apertureWidth " + apertureWidth);
|
||||
Debug.Log ("apertureHeight " + apertureHeight);
|
||||
Debug.Log ("fovx " + fovx [0]);
|
||||
Debug.Log ("fovy " + fovy [0]);
|
||||
Debug.Log ("focalLength " + focalLength [0]);
|
||||
Debug.Log ("principalPoint " + principalPoint.ToString ());
|
||||
Debug.Log ("aspectratio " + aspectratio [0]);
|
||||
|
||||
|
||||
//To convert the difference of the FOV value of the OpenCV and Unity.
|
||||
double fovXScale = (2.0 * Mathf.Atan ((float)(imageSize.width / (2.0 * fx)))) / (Mathf.Atan2 ((float)cx, (float)fx) + Mathf.Atan2 ((float)(imageSize.width - cx), (float)fx));
|
||||
double fovYScale = (2.0 * Mathf.Atan ((float)(imageSize.height / (2.0 * fy)))) / (Mathf.Atan2 ((float)cy, (float)fy) + Mathf.Atan2 ((float)(imageSize.height - cy), (float)fy));
|
||||
|
||||
Debug.Log ("fovXScale " + fovXScale);
|
||||
Debug.Log ("fovYScale " + fovYScale);
|
||||
|
||||
|
||||
//Adjust Unity Camera FOV https://github.com/opencv/opencv/commit/8ed1945ccd52501f5ab22bdec6aa1f91f1e2cfd4
|
||||
if (widthScale < heightScale) {
|
||||
ARCamera.fieldOfView = (float)(fovx [0] * fovXScale);
|
||||
} else {
|
||||
ARCamera.fieldOfView = (float)(fovy [0] * fovYScale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
transformationM = new Matrix4x4 ();
|
||||
|
||||
invertYM = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, new Vector3 (1, -1, 1));
|
||||
Debug.Log ("invertYM " + invertYM.ToString ());
|
||||
|
||||
invertZM = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, new Vector3 (1, 1, -1));
|
||||
Debug.Log ("invertZM " + invertZM.ToString ());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//if WebCamera is frontFaceing,flip Mat.
|
||||
if (webCamTextureToMatHelper.GetWebCamDevice ().isFrontFacing) {
|
||||
webCamTextureToMatHelper.flipHorizontal = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the web cam texture to mat helper disposed event.
|
||||
/// </summary>
|
||||
public void OnWebCamTextureToMatHelperDisposed ()
|
||||
{
|
||||
Debug.Log ("OnWebCamTextureToMatHelperDisposed");
|
||||
|
||||
if (grayMat != null)
|
||||
grayMat.Dispose ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the web cam texture to mat helper error occurred event.
|
||||
/// </summary>
|
||||
/// <param name="errorCode">Error code.</param>
|
||||
public void OnWebCamTextureToMatHelperErrorOccurred(WebCamTextureToMatHelper.ErrorCode errorCode){
|
||||
Debug.Log ("OnWebCamTextureToMatHelperErrorOccurred " + errorCode);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
if (webCamTextureToMatHelper.IsPlaying () && webCamTextureToMatHelper.DidUpdateThisFrame ()) {
|
||||
|
||||
Mat rgbaMat = webCamTextureToMatHelper.GetMat ();
|
||||
|
||||
Imgproc.cvtColor (rgbaMat, grayMat, Imgproc.COLOR_RGBA2GRAY);
|
||||
|
||||
|
||||
bool patternFound = patternDetector.findPattern (grayMat, patternTrackingInfo);
|
||||
|
||||
// Debug.Log ("patternFound " + patternFound);
|
||||
if (patternFound) {
|
||||
patternTrackingInfo.computePose (pattern, camMatrix, distCoeffs);
|
||||
|
||||
//Marker to Camera Coordinate System Convert Matrix
|
||||
transformationM = patternTrackingInfo.pose3d;
|
||||
//Debug.Log ("transformationM " + transformationM.ToString ());
|
||||
|
||||
if (shouldMoveARCamera) {
|
||||
ARM = ARGameObject.transform.localToWorldMatrix * invertZM * transformationM.inverse * invertYM;
|
||||
//Debug.Log ("ARM " + ARM.ToString ());
|
||||
|
||||
ARUtils.SetTransformFromMatrix (ARCamera.transform, ref ARM);
|
||||
} else {
|
||||
|
||||
ARM = ARCamera.transform.localToWorldMatrix * invertYM * transformationM * invertZM;
|
||||
//Debug.Log ("ARM " + ARM.ToString ());
|
||||
|
||||
ARUtils.SetTransformFromMatrix (ARGameObject.transform, ref ARM);
|
||||
}
|
||||
|
||||
ARGameObject.GetComponent<DelayableSetActive> ().SetActive (true);
|
||||
} else {
|
||||
|
||||
ARGameObject.GetComponent<DelayableSetActive> ().SetActive (false, 0.5f);
|
||||
}
|
||||
|
||||
|
||||
Utils.matToTexture2D (rgbaMat, texture, webCamTextureToMatHelper.GetBufferColors ());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the disable event.
|
||||
/// </summary>
|
||||
void OnDisable ()
|
||||
{
|
||||
webCamTextureToMatHelper.Dispose ();
|
||||
|
||||
if (patternMat != null)
|
||||
patternMat.Dispose ();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Raises the back button event.
|
||||
/// </summary>
|
||||
public void OnBackButton ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("MarkerLessARExample");
|
||||
#else
|
||||
Application.LoadLevel ("MarkerLessARExample");
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the play button event.
|
||||
/// </summary>
|
||||
public void OnPlayButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Play ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the pause button event.
|
||||
/// </summary>
|
||||
public void OnPauseButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Pause ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the stop button event.
|
||||
/// </summary>
|
||||
public void OnStopButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Stop ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the change camera button event.
|
||||
/// </summary>
|
||||
public void OnChangeCameraButton ()
|
||||
{
|
||||
webCamTextureToMatHelper.Init (null, webCamTextureToMatHelper.requestWidth, webCamTextureToMatHelper.requestHeight, !webCamTextureToMatHelper.requestIsFrontFacing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the is showing axes toggle event.
|
||||
/// </summary>
|
||||
public void OnIsShowingAxesToggle ()
|
||||
{
|
||||
if (isShowingAxesToggle.isOn) {
|
||||
isShowingAxes = true;
|
||||
} else {
|
||||
isShowingAxes = false;
|
||||
}
|
||||
axes.SetActive (isShowingAxes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the is showing cube toggle event.
|
||||
/// </summary>
|
||||
public void OnIsShowingCubeToggle ()
|
||||
{
|
||||
if (isShowingCubeToggle.isOn) {
|
||||
isShowingCube = true;
|
||||
} else {
|
||||
isShowingCube = false;
|
||||
}
|
||||
cube.SetActive (isShowingCube);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the is showing video toggle event.
|
||||
/// </summary>
|
||||
public void OnIsShowingVideoToggle ()
|
||||
{
|
||||
if (isShowingVideoToggle.isOn) {
|
||||
isShowingVideo = true;
|
||||
} else {
|
||||
isShowingVideo = false;
|
||||
}
|
||||
video.SetActive (isShowingVideo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the pattern capture button event.
|
||||
/// </summary>
|
||||
public void OnPatternCaptureButton ()
|
||||
{
|
||||
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene ("CapturePattern");
|
||||
#else
|
||||
Application.LoadLevel ("CapturePattern");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Двоичные данные
MarkerLessARSample/ReadMe.pdf
|
@ -1,4 +1,4 @@
|
|||
MarkerLess AR Sample
|
||||
MarkerLess AR Example
|
||||
====================
|
||||
|
||||
Overview
|
||||
|
@ -12,13 +12,13 @@ Setup Tutorial & Demo Video
|
|||
Demo
|
||||
-----
|
||||
- WebGL
|
||||
<https://enoxsoftware.github.io/MarkerLessARSample/webgl_sample/index.html>
|
||||
<https://enoxsoftware.github.io/MarkerLessARExample/webgl_example/index.html>
|
||||
- Android
|
||||
<https://play.google.com/store/apps/details?id=com.enoxsoftware.markerlessarsample>
|
||||
<https://play.google.com/store/apps/details?id=com.enoxsoftware.markerlessarexample>
|
||||
|
||||
Manual
|
||||
-----
|
||||
[ReadMe.pdf](/MarkerLessARSample/ReadMe.pdf)
|
||||
[ReadMe.pdf](/Assets/MarkerLessARExample/ReadMe.pdf)
|
||||
|
||||
|
||||
|
||||
|
|