├── Assets ├── VuforiaWithOpenCVForUnityExample.meta └── VuforiaWithOpenCVForUnityExample │ ├── CameraImageToMatExample.cs │ ├── CameraImageToMatExample.cs.meta │ ├── CameraImageToMatExample.unity │ ├── CameraImageToMatExample.unity.meta │ ├── ExampleMaterial.mat │ ├── ExampleMaterial.mat.meta │ ├── LoadingIcon.png │ ├── LoadingIcon.png.meta │ ├── PostRenderToMatExample.cs │ ├── PostRenderToMatExample.cs.meta │ ├── PostRenderToMatExample.unity │ └── PostRenderToMatExample.unity.meta ├── CameraImageToMatExample.PNG ├── Light_Frame.png ├── PackageManager.PNG ├── PostRenderToMatExample.PNG ├── README.md └── VuforiaWithOpenCVForUnityExample.unitypackage /Assets/VuforiaWithOpenCVForUnityExample.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26f0434134c4bb44ebb7b6fe002e4b2a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/VuforiaWithOpenCVForUnityExample/CameraImageToMatExample.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | using Vuforia; 5 | using OpenCVForUnity.CoreModule; 6 | using OpenCVForUnity.ImgprocModule; 7 | using OpenCVForUnity.UnityUtils; 8 | 9 | /// 10 | /// Camera image to mat sample. 11 | /// https://library.vuforia.com/content/vuforia-library/en/articles/Solution/Working-with-the-Camera.html#How-To-Access-the-Camera-Image-in-Unity 12 | /// 13 | public class CameraImageToMatExample : MonoBehaviour 14 | { 15 | 16 | private PIXEL_FORMAT mPixelFormat = PIXEL_FORMAT.UNKNOWN_FORMAT; 17 | 18 | private bool mAccessCameraImage = true; 19 | private bool mFormatRegistered = false; 20 | 21 | public GameObject quad; 22 | public Camera mainCamera; 23 | Mat inputMat; 24 | Texture2D outputTexture; 25 | 26 | 27 | void Start () 28 | { 29 | 30 | #if UNITY_EDITOR 31 | mPixelFormat = PIXEL_FORMAT.GRAYSCALE; // Need Grayscale for Editor 32 | #else 33 | mPixelFormat = Image.PIXEL_FORMAT.RGB888; // Use RGB888 for mobile 34 | #endif 35 | 36 | // Register Vuforia life-cycle callbacks: 37 | VuforiaARController.Instance.RegisterVuforiaStartedCallback (OnVuforiaStarted); 38 | VuforiaARController.Instance.RegisterTrackablesUpdatedCallback (OnTrackablesUpdated); 39 | VuforiaARController.Instance.RegisterOnPauseCallback (OnPause); 40 | 41 | } 42 | 43 | void OnVuforiaStarted () 44 | { 45 | 46 | // Try register camera image format 47 | if (CameraDevice.Instance.SetFrameFormat (mPixelFormat, true)) { 48 | Debug.Log ("Successfully registered pixel format " + mPixelFormat.ToString ()); 49 | 50 | mFormatRegistered = true; 51 | } else { 52 | Debug.LogError ( 53 | "\nFailed to register pixel format: " + mPixelFormat.ToString () + 54 | "\nThe format may be unsupported by your device." + 55 | "\nConsider using a different pixel format.\n"); 56 | 57 | mFormatRegistered = false; 58 | } 59 | 60 | } 61 | 62 | /// 63 | /// Called each time the Vuforia state is updated 64 | /// 65 | void OnTrackablesUpdated () 66 | { 67 | if (mFormatRegistered) { 68 | if (mAccessCameraImage) { 69 | Vuforia.Image image = CameraDevice.Instance.GetCameraImage (mPixelFormat); 70 | 71 | if (image != null) { 72 | // Debug.Log ( 73 | // "\nImage Format: " + image.PixelFormat + 74 | // "\nImage Size: " + image.Width + "x" + image.Height + 75 | // "\nBuffer Size: " + image.BufferWidth + "x" + image.BufferHeight + 76 | // "\nImage Stride: " + image.Stride + "\n" 77 | // ); 78 | 79 | // byte[] pixels = image.Pixels; 80 | // 81 | // if (pixels != null && pixels.Length > 0) 82 | // { 83 | // Debug.Log( 84 | // "\nImage pixels: " + 85 | // pixels[0] + ", " + 86 | // pixels[1] + ", " + 87 | // pixels[2] + ", ...\n" 88 | // ); 89 | // } 90 | 91 | if (inputMat == null) { 92 | if (mPixelFormat == PIXEL_FORMAT.GRAYSCALE) { 93 | inputMat = new Mat (image.Height, image.Width, CvType.CV_8UC1); 94 | } else if (mPixelFormat == PIXEL_FORMAT.RGB888) { 95 | inputMat = new Mat (image.Height, image.Width, CvType.CV_8UC3); 96 | } 97 | //Debug.Log ("inputMat dst ToString " + inputMat.ToString ()); 98 | } 99 | 100 | 101 | inputMat.put (0, 0, image.Pixels); 102 | 103 | Imgproc.putText (inputMat, "CameraImageToMatSample " + inputMat.cols () + "x" + inputMat.rows (), new Point (5, inputMat.rows () - 5), Imgproc.FONT_HERSHEY_PLAIN, 1.0, new Scalar (255, 0, 0, 255)); 104 | 105 | 106 | if (outputTexture == null) { 107 | outputTexture = new Texture2D (inputMat.cols (), inputMat.rows (), TextureFormat.RGBA32, false); 108 | } 109 | 110 | Utils.matToTexture2D (inputMat, outputTexture); 111 | 112 | 113 | quad.transform.localScale = new Vector3 ((float)image.Width, (float)image.Height, 1.0f); 114 | quad.GetComponent ().material.mainTexture = outputTexture; 115 | 116 | mainCamera.orthographicSize = image.Height / 2; 117 | } 118 | } 119 | } 120 | } 121 | 122 | /// 123 | /// Called when app is paused / resumed 124 | /// 125 | void OnPause (bool paused) 126 | { 127 | if (paused) { 128 | Debug.Log ("App was paused"); 129 | UnregisterFormat (); 130 | } else { 131 | Debug.Log ("App was resumed"); 132 | RegisterFormat (); 133 | } 134 | } 135 | 136 | /// 137 | /// Register the camera pixel format 138 | /// 139 | void RegisterFormat () 140 | { 141 | if (CameraDevice.Instance.SetFrameFormat (mPixelFormat, true)) { 142 | Debug.Log ("Successfully registered camera pixel format " + mPixelFormat.ToString ()); 143 | mFormatRegistered = true; 144 | } else { 145 | Debug.LogError ("Failed to register camera pixel format " + mPixelFormat.ToString ()); 146 | mFormatRegistered = false; 147 | } 148 | } 149 | 150 | /// 151 | /// Unregister the camera pixel format (e.g. call this when app is paused) 152 | /// 153 | void UnregisterFormat () 154 | { 155 | Debug.Log ("Unregistering camera pixel format " + mPixelFormat.ToString ()); 156 | CameraDevice.Instance.SetFrameFormat (mPixelFormat, false); 157 | mFormatRegistered = false; 158 | } 159 | 160 | } 161 | -------------------------------------------------------------------------------- /Assets/VuforiaWithOpenCVForUnityExample/CameraImageToMatExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44ddccb4042e2bb4bba53ba02328f71d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/VuforiaWithOpenCVForUnityExample/CameraImageToMatExample.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 8 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0.44657826, g: 0.49641263, b: 0.57481676, a: 1} 42 | --- !u!157 &3 43 | LightmapSettings: 44 | m_ObjectHideFlags: 0 45 | serializedVersion: 11 46 | m_GIWorkflowMode: 0 47 | m_GISettings: 48 | serializedVersion: 2 49 | m_BounceScale: 1 50 | m_IndirectOutputScale: 1 51 | m_AlbedoBoost: 1 52 | m_TemporalCoherenceThreshold: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 1 56 | m_LightmapEditorSettings: 57 | serializedVersion: 9 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_TextureWidth: 1024 61 | m_TextureHeight: 1024 62 | m_AO: 0 63 | m_AOMaxDistance: 1 64 | m_CompAOExponent: 1 65 | m_CompAOExponentDirect: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 0 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVRFilterTypeDirect: 0 81 | m_PVRFilterTypeIndirect: 0 82 | m_PVRFilterTypeAO: 0 83 | m_PVRFilteringMode: 1 84 | m_PVRCulling: 1 85 | m_PVRFilteringGaussRadiusDirect: 1 86 | m_PVRFilteringGaussRadiusIndirect: 5 87 | m_PVRFilteringGaussRadiusAO: 2 88 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 89 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 90 | m_PVRFilteringAtrousPositionSigmaAO: 1 91 | m_ShowResolutionOverlay: 1 92 | m_LightingDataAsset: {fileID: 0} 93 | m_UseShadowmask: 1 94 | --- !u!196 &4 95 | NavMeshSettings: 96 | serializedVersion: 2 97 | m_ObjectHideFlags: 0 98 | m_BuildSettings: 99 | serializedVersion: 2 100 | agentTypeID: 0 101 | agentRadius: 0.5 102 | agentHeight: 2 103 | agentSlope: 45 104 | agentClimb: 0.4 105 | ledgeDropHeight: 0 106 | maxJumpAcrossDistance: 0 107 | minRegionArea: 2 108 | manualCellSize: 0 109 | cellSize: 0.16666667 110 | manualTileSize: 0 111 | tileSize: 256 112 | accuratePlacement: 0 113 | debug: 114 | m_Flags: 0 115 | m_NavMeshData: {fileID: 0} 116 | --- !u!1 &176186253 117 | GameObject: 118 | m_ObjectHideFlags: 0 119 | m_PrefabParentObject: {fileID: 0} 120 | m_PrefabInternal: {fileID: 0} 121 | serializedVersion: 5 122 | m_Component: 123 | - component: {fileID: 176186257} 124 | - component: {fileID: 176186256} 125 | - component: {fileID: 176186255} 126 | m_Layer: 0 127 | m_Name: Main Camera 128 | m_TagString: MainCamera 129 | m_Icon: {fileID: 0} 130 | m_NavMeshLayer: 0 131 | m_StaticEditorFlags: 0 132 | m_IsActive: 1 133 | --- !u!124 &176186255 134 | Behaviour: 135 | m_ObjectHideFlags: 0 136 | m_PrefabParentObject: {fileID: 0} 137 | m_PrefabInternal: {fileID: 0} 138 | m_GameObject: {fileID: 176186253} 139 | m_Enabled: 1 140 | --- !u!20 &176186256 141 | Camera: 142 | m_ObjectHideFlags: 0 143 | m_PrefabParentObject: {fileID: 0} 144 | m_PrefabInternal: {fileID: 0} 145 | m_GameObject: {fileID: 176186253} 146 | m_Enabled: 1 147 | serializedVersion: 2 148 | m_ClearFlags: 1 149 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 150 | m_NormalizedViewPortRect: 151 | serializedVersion: 2 152 | x: 0 153 | y: 0 154 | width: 1 155 | height: 1 156 | near clip plane: 0.3 157 | far clip plane: 1000 158 | field of view: 60 159 | orthographic: 1 160 | orthographic size: 5 161 | m_Depth: 2 162 | m_CullingMask: 163 | serializedVersion: 2 164 | m_Bits: 4294967295 165 | m_RenderingPath: -1 166 | m_TargetTexture: {fileID: 0} 167 | m_TargetDisplay: 0 168 | m_TargetEye: 3 169 | m_HDR: 1 170 | m_AllowMSAA: 1 171 | m_AllowDynamicResolution: 0 172 | m_ForceIntoRT: 0 173 | m_OcclusionCulling: 1 174 | m_StereoConvergence: 10 175 | m_StereoSeparation: 0.022 176 | --- !u!4 &176186257 177 | Transform: 178 | m_ObjectHideFlags: 0 179 | m_PrefabParentObject: {fileID: 0} 180 | m_PrefabInternal: {fileID: 0} 181 | m_GameObject: {fileID: 176186253} 182 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 183 | m_LocalPosition: {x: 0, y: 0, z: -10} 184 | m_LocalScale: {x: 1, y: 1, z: 1} 185 | m_Children: [] 186 | m_Father: {fileID: 0} 187 | m_RootOrder: 0 188 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 189 | --- !u!43 &438224595 190 | Mesh: 191 | m_ObjectHideFlags: 0 192 | m_PrefabParentObject: {fileID: 0} 193 | m_PrefabInternal: {fileID: 0} 194 | m_Name: 195 | serializedVersion: 8 196 | m_SubMeshes: 197 | - serializedVersion: 2 198 | firstByte: 0 199 | indexCount: 6 200 | topology: 0 201 | baseVertex: 0 202 | firstVertex: 0 203 | vertexCount: 4 204 | localAABB: 205 | m_Center: {x: 0, y: 0, z: 0} 206 | m_Extent: {x: 0.28947368, y: 0, z: 0.5} 207 | m_Shapes: 208 | vertices: [] 209 | shapes: [] 210 | channels: [] 211 | fullWeights: [] 212 | m_BindPose: [] 213 | m_BoneNameHashes: 214 | m_RootBoneNameHash: 0 215 | m_MeshCompression: 0 216 | m_IsReadable: 1 217 | m_KeepVertices: 1 218 | m_KeepIndices: 1 219 | m_IndexFormat: 0 220 | m_IndexBuffer: 000001000200020001000300 221 | m_Skin: [] 222 | m_VertexData: 223 | m_CurrentChannels: 11 224 | m_VertexCount: 4 225 | m_Channels: 226 | - stream: 0 227 | offset: 0 228 | format: 0 229 | dimension: 3 230 | - stream: 0 231 | offset: 12 232 | format: 0 233 | dimension: 3 234 | - stream: 0 235 | offset: 0 236 | format: 0 237 | dimension: 0 238 | - stream: 0 239 | offset: 24 240 | format: 0 241 | dimension: 2 242 | - stream: 0 243 | offset: 0 244 | format: 0 245 | dimension: 0 246 | - stream: 0 247 | offset: 0 248 | format: 0 249 | dimension: 0 250 | - stream: 0 251 | offset: 0 252 | format: 0 253 | dimension: 0 254 | - stream: 0 255 | offset: 0 256 | format: 0 257 | dimension: 0 258 | m_DataSize: 128 259 | _typelessdata: e53594be00000000000000bf000000000000803f000000000000000000000000e53594be000000000000003f000000000000803f00000000000000000000803fe535943e00000000000000bf000000000000803f000000000000803f00000000e535943e000000000000003f000000000000803f000000000000803f0000803f 260 | m_CompressedMesh: 261 | m_Vertices: 262 | m_NumItems: 0 263 | m_Range: 0 264 | m_Start: 0 265 | m_Data: 266 | m_BitSize: 0 267 | m_UV: 268 | m_NumItems: 0 269 | m_Range: 0 270 | m_Start: 0 271 | m_Data: 272 | m_BitSize: 0 273 | m_Normals: 274 | m_NumItems: 0 275 | m_Range: 0 276 | m_Start: 0 277 | m_Data: 278 | m_BitSize: 0 279 | m_Tangents: 280 | m_NumItems: 0 281 | m_Range: 0 282 | m_Start: 0 283 | m_Data: 284 | m_BitSize: 0 285 | m_Weights: 286 | m_NumItems: 0 287 | m_Data: 288 | m_BitSize: 0 289 | m_NormalSigns: 290 | m_NumItems: 0 291 | m_Data: 292 | m_BitSize: 0 293 | m_TangentSigns: 294 | m_NumItems: 0 295 | m_Data: 296 | m_BitSize: 0 297 | m_FloatColors: 298 | m_NumItems: 0 299 | m_Range: 0 300 | m_Start: 0 301 | m_Data: 302 | m_BitSize: 0 303 | m_BoneIndices: 304 | m_NumItems: 0 305 | m_Data: 306 | m_BitSize: 0 307 | m_Triangles: 308 | m_NumItems: 0 309 | m_Data: 310 | m_BitSize: 0 311 | m_UVInfo: 0 312 | m_LocalAABB: 313 | m_Center: {x: 0, y: 0, z: 0} 314 | m_Extent: {x: 0.28947368, y: 0, z: 0.5} 315 | m_MeshUsageFlags: 0 316 | m_BakedConvexCollisionMesh: 317 | m_BakedTriangleCollisionMesh: 318 | m_MeshOptimized: 0 319 | --- !u!1 &814934680 320 | GameObject: 321 | m_ObjectHideFlags: 0 322 | m_PrefabParentObject: {fileID: 0} 323 | m_PrefabInternal: {fileID: 0} 324 | serializedVersion: 5 325 | m_Component: 326 | - component: {fileID: 814934682} 327 | - component: {fileID: 814934681} 328 | m_Layer: 0 329 | m_Name: Directional Light 330 | m_TagString: Untagged 331 | m_Icon: {fileID: 0} 332 | m_NavMeshLayer: 0 333 | m_StaticEditorFlags: 0 334 | m_IsActive: 1 335 | --- !u!108 &814934681 336 | Light: 337 | m_ObjectHideFlags: 0 338 | m_PrefabParentObject: {fileID: 0} 339 | m_PrefabInternal: {fileID: 0} 340 | m_GameObject: {fileID: 814934680} 341 | m_Enabled: 1 342 | serializedVersion: 8 343 | m_Type: 1 344 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 345 | m_Intensity: 1 346 | m_Range: 10 347 | m_SpotAngle: 30 348 | m_CookieSize: 10 349 | m_Shadows: 350 | m_Type: 2 351 | m_Resolution: -1 352 | m_CustomResolution: -1 353 | m_Strength: 1 354 | m_Bias: 0.05 355 | m_NormalBias: 0.4 356 | m_NearPlane: 0.2 357 | m_Cookie: {fileID: 0} 358 | m_DrawHalo: 0 359 | m_Flare: {fileID: 0} 360 | m_RenderMode: 0 361 | m_CullingMask: 362 | serializedVersion: 2 363 | m_Bits: 4294967295 364 | m_Lightmapping: 4 365 | m_AreaSize: {x: 1, y: 1} 366 | m_BounceIntensity: 1 367 | m_ColorTemperature: 6570 368 | m_UseColorTemperature: 0 369 | m_ShadowRadius: 0 370 | m_ShadowAngle: 0 371 | --- !u!4 &814934682 372 | Transform: 373 | m_ObjectHideFlags: 0 374 | m_PrefabParentObject: {fileID: 0} 375 | m_PrefabInternal: {fileID: 0} 376 | m_GameObject: {fileID: 814934680} 377 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 378 | m_LocalPosition: {x: 0, y: 3, z: 0} 379 | m_LocalScale: {x: 1, y: 1, z: 1} 380 | m_Children: [] 381 | m_Father: {fileID: 0} 382 | m_RootOrder: 1 383 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 384 | --- !u!21 &865150752 385 | Material: 386 | serializedVersion: 6 387 | m_ObjectHideFlags: 0 388 | m_PrefabParentObject: {fileID: 0} 389 | m_PrefabInternal: {fileID: 0} 390 | m_Name: AstronautMaterial 391 | m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0} 392 | m_ShaderKeywords: 393 | m_LightmapFlags: 5 394 | m_EnableInstancingVariants: 0 395 | m_DoubleSidedGI: 0 396 | m_CustomRenderQueue: -1 397 | stringTagMap: {} 398 | disabledShaderPasses: [] 399 | m_SavedProperties: 400 | serializedVersion: 3 401 | m_TexEnvs: 402 | - _MainTex: 403 | m_Texture: {fileID: 2800000, guid: 77fb44a366db5cb41b8c06649271f8e6, type: 3} 404 | m_Scale: {x: 1, y: 1} 405 | m_Offset: {x: 0, y: 0} 406 | m_Floats: [] 407 | m_Colors: 408 | - _Color: {r: 0.82089555, g: 0.82089555, b: 0.82089555, a: 1} 409 | --- !u!1 &908191110 410 | GameObject: 411 | m_ObjectHideFlags: 0 412 | m_PrefabParentObject: {fileID: 0} 413 | m_PrefabInternal: {fileID: 0} 414 | serializedVersion: 5 415 | m_Component: 416 | - component: {fileID: 908191116} 417 | - component: {fileID: 908191115} 418 | - component: {fileID: 908191114} 419 | - component: {fileID: 908191113} 420 | - component: {fileID: 908191112} 421 | - component: {fileID: 908191111} 422 | m_Layer: 0 423 | m_Name: ImageTarget 424 | m_TagString: Untagged 425 | m_Icon: {fileID: 0} 426 | m_NavMeshLayer: 0 427 | m_StaticEditorFlags: 0 428 | m_IsActive: 1 429 | --- !u!33 &908191111 430 | MeshFilter: 431 | m_ObjectHideFlags: 0 432 | m_PrefabParentObject: {fileID: 0} 433 | m_PrefabInternal: {fileID: 0} 434 | m_GameObject: {fileID: 908191110} 435 | m_Mesh: {fileID: 438224595} 436 | --- !u!23 &908191112 437 | MeshRenderer: 438 | m_ObjectHideFlags: 0 439 | m_PrefabParentObject: {fileID: 0} 440 | m_PrefabInternal: {fileID: 0} 441 | m_GameObject: {fileID: 908191110} 442 | m_Enabled: 1 443 | m_CastShadows: 1 444 | m_ReceiveShadows: 1 445 | m_DynamicOccludee: 1 446 | m_MotionVectors: 1 447 | m_LightProbeUsage: 0 448 | m_ReflectionProbeUsage: 1 449 | m_Materials: 450 | - {fileID: 865150752} 451 | m_StaticBatchInfo: 452 | firstSubMesh: 0 453 | subMeshCount: 0 454 | m_StaticBatchRoot: {fileID: 0} 455 | m_ProbeAnchor: {fileID: 0} 456 | m_LightProbeVolumeOverride: {fileID: 0} 457 | m_ScaleInLightmap: 1 458 | m_PreserveUVs: 0 459 | m_IgnoreNormalsForChartDetection: 0 460 | m_ImportantGI: 0 461 | m_StitchLightmapSeams: 0 462 | m_SelectedEditorRenderState: 3 463 | m_MinimumChartSize: 4 464 | m_AutoUVMaxDistance: 0.5 465 | m_AutoUVMaxAngle: 89 466 | m_LightmapParameters: {fileID: 0} 467 | m_SortingLayerID: 0 468 | m_SortingLayer: 0 469 | m_SortingOrder: 0 470 | --- !u!114 &908191113 471 | MonoBehaviour: 472 | m_ObjectHideFlags: 0 473 | m_PrefabParentObject: {fileID: 0} 474 | m_PrefabInternal: {fileID: 0} 475 | m_GameObject: {fileID: 908191110} 476 | m_Enabled: 1 477 | m_EditorHideFlags: 0 478 | m_Script: {fileID: -1770992566, guid: 1e108ae5f2133934f948edded555f03e, type: 3} 479 | m_Name: 480 | m_EditorClassIdentifier: 481 | --- !u!114 &908191114 482 | MonoBehaviour: 483 | m_ObjectHideFlags: 0 484 | m_PrefabParentObject: {fileID: 0} 485 | m_PrefabInternal: {fileID: 0} 486 | m_GameObject: {fileID: 908191110} 487 | m_Enabled: 1 488 | m_EditorHideFlags: 0 489 | m_Script: {fileID: 11500000, guid: 5a917f0af64a6423093132dab321c15f, type: 3} 490 | m_Name: 491 | m_EditorClassIdentifier: 492 | --- !u!114 &908191115 493 | MonoBehaviour: 494 | m_ObjectHideFlags: 0 495 | m_PrefabParentObject: {fileID: 0} 496 | m_PrefabInternal: {fileID: 0} 497 | m_GameObject: {fileID: 908191110} 498 | m_Enabled: 1 499 | m_EditorHideFlags: 0 500 | m_Script: {fileID: -1631628248, guid: 1e108ae5f2133934f948edded555f03e, type: 3} 501 | m_Name: 502 | m_EditorClassIdentifier: 503 | mTrackableName: Astronaut 504 | mPreserveChildSize: 0 505 | mInitializedInEditor: 1 506 | mDataSetPath: Vuforia/VuforiaMars_Images.xml 507 | mExtendedTracking: 0 508 | mAspectRatio: 1.7272727 509 | mImageTargetType: 0 510 | mWidth: 0.06985 511 | mHeight: 0.12065 512 | --- !u!4 &908191116 513 | Transform: 514 | m_ObjectHideFlags: 0 515 | m_PrefabParentObject: {fileID: 0} 516 | m_PrefabInternal: {fileID: 0} 517 | m_GameObject: {fileID: 908191110} 518 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 519 | m_LocalPosition: {x: 0, y: 0, z: 0} 520 | m_LocalScale: {x: 0.12065, y: 0.12065, z: 0.12065} 521 | m_Children: 522 | - {fileID: 1709327201} 523 | m_Father: {fileID: 0} 524 | m_RootOrder: 3 525 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 526 | --- !u!1 &1418794998 527 | GameObject: 528 | m_ObjectHideFlags: 0 529 | m_PrefabParentObject: {fileID: 0} 530 | m_PrefabInternal: {fileID: 0} 531 | serializedVersion: 5 532 | m_Component: 533 | - component: {fileID: 1418795003} 534 | - component: {fileID: 1418795002} 535 | - component: {fileID: 1418795001} 536 | - component: {fileID: 1418795000} 537 | - component: {fileID: 1418794999} 538 | m_Layer: 0 539 | m_Name: Quad 540 | m_TagString: Untagged 541 | m_Icon: {fileID: 0} 542 | m_NavMeshLayer: 0 543 | m_StaticEditorFlags: 0 544 | m_IsActive: 1 545 | --- !u!114 &1418794999 546 | MonoBehaviour: 547 | m_ObjectHideFlags: 0 548 | m_PrefabParentObject: {fileID: 0} 549 | m_PrefabInternal: {fileID: 0} 550 | m_GameObject: {fileID: 1418794998} 551 | m_Enabled: 1 552 | m_EditorHideFlags: 0 553 | m_Script: {fileID: 11500000, guid: 44ddccb4042e2bb4bba53ba02328f71d, type: 3} 554 | m_Name: 555 | m_EditorClassIdentifier: 556 | quad: {fileID: 1418794998} 557 | mainCamera: {fileID: 176186256} 558 | --- !u!23 &1418795000 559 | MeshRenderer: 560 | m_ObjectHideFlags: 0 561 | m_PrefabParentObject: {fileID: 0} 562 | m_PrefabInternal: {fileID: 0} 563 | m_GameObject: {fileID: 1418794998} 564 | m_Enabled: 1 565 | m_CastShadows: 1 566 | m_ReceiveShadows: 1 567 | m_DynamicOccludee: 1 568 | m_MotionVectors: 1 569 | m_LightProbeUsage: 1 570 | m_ReflectionProbeUsage: 1 571 | m_Materials: 572 | - {fileID: 2100000, guid: 12317db4e4abc304690f2189eec2beb3, type: 2} 573 | m_StaticBatchInfo: 574 | firstSubMesh: 0 575 | subMeshCount: 0 576 | m_StaticBatchRoot: {fileID: 0} 577 | m_ProbeAnchor: {fileID: 0} 578 | m_LightProbeVolumeOverride: {fileID: 0} 579 | m_ScaleInLightmap: 1 580 | m_PreserveUVs: 1 581 | m_IgnoreNormalsForChartDetection: 0 582 | m_ImportantGI: 0 583 | m_StitchLightmapSeams: 0 584 | m_SelectedEditorRenderState: 3 585 | m_MinimumChartSize: 4 586 | m_AutoUVMaxDistance: 0.5 587 | m_AutoUVMaxAngle: 89 588 | m_LightmapParameters: {fileID: 0} 589 | m_SortingLayerID: 0 590 | m_SortingLayer: 0 591 | m_SortingOrder: 0 592 | --- !u!64 &1418795001 593 | MeshCollider: 594 | m_ObjectHideFlags: 0 595 | m_PrefabParentObject: {fileID: 0} 596 | m_PrefabInternal: {fileID: 0} 597 | m_GameObject: {fileID: 1418794998} 598 | m_Material: {fileID: 0} 599 | m_IsTrigger: 0 600 | m_Enabled: 1 601 | serializedVersion: 3 602 | m_Convex: 0 603 | m_CookingOptions: 14 604 | m_SkinWidth: 0.01 605 | m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} 606 | --- !u!33 &1418795002 607 | MeshFilter: 608 | m_ObjectHideFlags: 0 609 | m_PrefabParentObject: {fileID: 0} 610 | m_PrefabInternal: {fileID: 0} 611 | m_GameObject: {fileID: 1418794998} 612 | m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} 613 | --- !u!4 &1418795003 614 | Transform: 615 | m_ObjectHideFlags: 0 616 | m_PrefabParentObject: {fileID: 0} 617 | m_PrefabInternal: {fileID: 0} 618 | m_GameObject: {fileID: 1418794998} 619 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 620 | m_LocalPosition: {x: 0, y: 0, z: 0} 621 | m_LocalScale: {x: 10, y: 10, z: 1} 622 | m_Children: [] 623 | m_Father: {fileID: 0} 624 | m_RootOrder: 4 625 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 626 | --- !u!1 &1557567375 627 | GameObject: 628 | m_ObjectHideFlags: 0 629 | m_PrefabParentObject: {fileID: 0} 630 | m_PrefabInternal: {fileID: 0} 631 | serializedVersion: 5 632 | m_Component: 633 | - component: {fileID: 1557567380} 634 | - component: {fileID: 1557567379} 635 | - component: {fileID: 1557567378} 636 | - component: {fileID: 1557567377} 637 | - component: {fileID: 1557567376} 638 | m_Layer: 0 639 | m_Name: ARCamera 640 | m_TagString: Untagged 641 | m_Icon: {fileID: 0} 642 | m_NavMeshLayer: 0 643 | m_StaticEditorFlags: 0 644 | m_IsActive: 1 645 | --- !u!114 &1557567376 646 | MonoBehaviour: 647 | m_ObjectHideFlags: 0 648 | m_PrefabParentObject: {fileID: 0} 649 | m_PrefabInternal: {fileID: 0} 650 | m_GameObject: {fileID: 1557567375} 651 | m_Enabled: 1 652 | m_EditorHideFlags: 0 653 | m_Script: {fileID: 11500000, guid: c47f92041efbb4b429a4eafca855ebe3, type: 3} 654 | m_Name: 655 | m_EditorClassIdentifier: 656 | --- !u!114 &1557567377 657 | MonoBehaviour: 658 | m_ObjectHideFlags: 0 659 | m_PrefabParentObject: {fileID: 0} 660 | m_PrefabInternal: {fileID: 0} 661 | m_GameObject: {fileID: 1557567375} 662 | m_Enabled: 1 663 | m_EditorHideFlags: 0 664 | m_Script: {fileID: -1826476478, guid: 1e108ae5f2133934f948edded555f03e, type: 3} 665 | m_Name: 666 | m_EditorClassIdentifier: 667 | mWorldCenterMode: 1 668 | mWorldCenter: {fileID: 0} 669 | --- !u!81 &1557567378 670 | AudioListener: 671 | m_ObjectHideFlags: 0 672 | m_PrefabParentObject: {fileID: 0} 673 | m_PrefabInternal: {fileID: 0} 674 | m_GameObject: {fileID: 1557567375} 675 | m_Enabled: 1 676 | --- !u!20 &1557567379 677 | Camera: 678 | m_ObjectHideFlags: 0 679 | m_PrefabParentObject: {fileID: 0} 680 | m_PrefabInternal: {fileID: 0} 681 | m_GameObject: {fileID: 1557567375} 682 | m_Enabled: 1 683 | serializedVersion: 2 684 | m_ClearFlags: 2 685 | m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1} 686 | m_NormalizedViewPortRect: 687 | serializedVersion: 2 688 | x: 0 689 | y: 0 690 | width: 1 691 | height: 1 692 | near clip plane: 0.05 693 | far clip plane: 2000 694 | field of view: 60 695 | orthographic: 0 696 | orthographic size: 5 697 | m_Depth: 1 698 | m_CullingMask: 699 | serializedVersion: 2 700 | m_Bits: 4294967295 701 | m_RenderingPath: -1 702 | m_TargetTexture: {fileID: 0} 703 | m_TargetDisplay: 0 704 | m_TargetEye: 3 705 | m_HDR: 0 706 | m_AllowMSAA: 1 707 | m_AllowDynamicResolution: 0 708 | m_ForceIntoRT: 0 709 | m_OcclusionCulling: 1 710 | m_StereoConvergence: 10 711 | m_StereoSeparation: 0.022 712 | --- !u!4 &1557567380 713 | Transform: 714 | m_ObjectHideFlags: 0 715 | m_PrefabParentObject: {fileID: 0} 716 | m_PrefabInternal: {fileID: 0} 717 | m_GameObject: {fileID: 1557567375} 718 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 719 | m_LocalPosition: {x: 0, y: 0, z: 0} 720 | m_LocalScale: {x: 1, y: 1, z: 1} 721 | m_Children: [] 722 | m_Father: {fileID: 0} 723 | m_RootOrder: 2 724 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 725 | --- !u!1 &1709327200 726 | GameObject: 727 | m_ObjectHideFlags: 0 728 | m_PrefabParentObject: {fileID: 0} 729 | m_PrefabInternal: {fileID: 0} 730 | serializedVersion: 5 731 | m_Component: 732 | - component: {fileID: 1709327201} 733 | - component: {fileID: 1709327204} 734 | - component: {fileID: 1709327203} 735 | - component: {fileID: 1709327202} 736 | m_Layer: 0 737 | m_Name: Cube 738 | m_TagString: Untagged 739 | m_Icon: {fileID: 0} 740 | m_NavMeshLayer: 0 741 | m_StaticEditorFlags: 0 742 | m_IsActive: 1 743 | --- !u!4 &1709327201 744 | Transform: 745 | m_ObjectHideFlags: 0 746 | m_PrefabParentObject: {fileID: 0} 747 | m_PrefabInternal: {fileID: 0} 748 | m_GameObject: {fileID: 1709327200} 749 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 750 | m_LocalPosition: {x: 0, y: 0.2, z: 0} 751 | m_LocalScale: {x: 0.4, y: 0.4, z: 0.4} 752 | m_Children: [] 753 | m_Father: {fileID: 908191116} 754 | m_RootOrder: 0 755 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 756 | --- !u!23 &1709327202 757 | MeshRenderer: 758 | m_ObjectHideFlags: 0 759 | m_PrefabParentObject: {fileID: 0} 760 | m_PrefabInternal: {fileID: 0} 761 | m_GameObject: {fileID: 1709327200} 762 | m_Enabled: 1 763 | m_CastShadows: 1 764 | m_ReceiveShadows: 1 765 | m_DynamicOccludee: 1 766 | m_MotionVectors: 1 767 | m_LightProbeUsage: 1 768 | m_ReflectionProbeUsage: 1 769 | m_Materials: 770 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} 771 | m_StaticBatchInfo: 772 | firstSubMesh: 0 773 | subMeshCount: 0 774 | m_StaticBatchRoot: {fileID: 0} 775 | m_ProbeAnchor: {fileID: 0} 776 | m_LightProbeVolumeOverride: {fileID: 0} 777 | m_ScaleInLightmap: 1 778 | m_PreserveUVs: 1 779 | m_IgnoreNormalsForChartDetection: 0 780 | m_ImportantGI: 0 781 | m_StitchLightmapSeams: 0 782 | m_SelectedEditorRenderState: 3 783 | m_MinimumChartSize: 4 784 | m_AutoUVMaxDistance: 0.5 785 | m_AutoUVMaxAngle: 89 786 | m_LightmapParameters: {fileID: 0} 787 | m_SortingLayerID: 0 788 | m_SortingLayer: 0 789 | m_SortingOrder: 0 790 | --- !u!65 &1709327203 791 | BoxCollider: 792 | m_ObjectHideFlags: 0 793 | m_PrefabParentObject: {fileID: 0} 794 | m_PrefabInternal: {fileID: 0} 795 | m_GameObject: {fileID: 1709327200} 796 | m_Material: {fileID: 0} 797 | m_IsTrigger: 0 798 | m_Enabled: 1 799 | serializedVersion: 2 800 | m_Size: {x: 1, y: 1, z: 1} 801 | m_Center: {x: 0, y: 0, z: 0} 802 | --- !u!33 &1709327204 803 | MeshFilter: 804 | m_ObjectHideFlags: 0 805 | m_PrefabParentObject: {fileID: 0} 806 | m_PrefabInternal: {fileID: 0} 807 | m_GameObject: {fileID: 1709327200} 808 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 809 | -------------------------------------------------------------------------------- /Assets/VuforiaWithOpenCVForUnityExample/CameraImageToMatExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f4dccf3c9735fbc4187e43538b2bc661 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/VuforiaWithOpenCVForUnityExample/ExampleMaterial.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: ExampleMaterial 10 | m_Shader: {fileID: 10750, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 5 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _MainTex: 22 | m_Texture: {fileID: 2800000, guid: f100581fa3f1fd74ab512969aeb37608, type: 3} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | m_Floats: [] 26 | m_Colors: 27 | - _Color: {r: 1, g: 1, b: 1, a: 1} 28 | -------------------------------------------------------------------------------- /Assets/VuforiaWithOpenCVForUnityExample/ExampleMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12317db4e4abc304690f2189eec2beb3 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | assetBundleVariant: 7 | -------------------------------------------------------------------------------- /Assets/VuforiaWithOpenCVForUnityExample/LoadingIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EnoxSoftware/VuforiaWithOpenCVForUnityExample/c68aad92f778763b361f6ebf8a6d838ebc0f57ce/Assets/VuforiaWithOpenCVForUnityExample/LoadingIcon.png -------------------------------------------------------------------------------- /Assets/VuforiaWithOpenCVForUnityExample/LoadingIcon.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f100581fa3f1fd74ab512969aeb37608 3 | timeCreated: 1479448965 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: .25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 8 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -1 30 | maxTextureSize: 512 31 | textureSettings: 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: -1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | spriteMode: 0 41 | spriteExtrude: 1 42 | spriteMeshType: 1 43 | alignment: 0 44 | spritePivot: {x: .5, y: .5} 45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 46 | spritePixelsToUnits: 100 47 | alphaIsTransparency: 0 48 | textureType: -1 49 | buildTargetSettings: [] 50 | spriteSheet: 51 | sprites: [] 52 | spritePackingTag: 53 | userData: 54 | assetBundleName: 55 | assetBundleVariant: 56 | -------------------------------------------------------------------------------- /Assets/VuforiaWithOpenCVForUnityExample/PostRenderToMatExample.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | using OpenCVForUnity.CoreModule; 5 | using OpenCVForUnity.ImgprocModule; 6 | using OpenCVForUnity.UnityUtils; 7 | 8 | /// 9 | /// Post render to mat example. 10 | /// 11 | public class PostRenderToMatExample : MonoBehaviour 12 | { 13 | 14 | public GameObject quad; 15 | public Camera mainCamera; 16 | Mat cameraMat; 17 | Texture2D cameraTexture; 18 | Texture2D outputTexture; 19 | Color32[] colors; 20 | Mat mSepiaKernel; 21 | private Size mSize0; 22 | private Mat mIntermediateMat; 23 | 24 | public enum modeType 25 | { 26 | original, 27 | sepia, 28 | pixelize, 29 | } 30 | 31 | public modeType mode; 32 | 33 | // Use this for initialization 34 | void Start () 35 | { 36 | 37 | cameraMat = new Mat (Screen.height, Screen.width, CvType.CV_8UC4); 38 | 39 | Debug.Log ("imgMat dst ToString " + cameraMat.ToString ()); 40 | 41 | 42 | cameraTexture = new Texture2D (cameraMat.cols (), cameraMat.rows (), TextureFormat.ARGB32, false); 43 | outputTexture = new Texture2D (cameraMat.cols (), cameraMat.rows (), TextureFormat.ARGB32, false); 44 | 45 | 46 | colors = new Color32[outputTexture.width * outputTexture.height]; 47 | 48 | 49 | mainCamera.orthographicSize = cameraTexture.height / 2; 50 | 51 | quad.transform.localScale = new Vector3 (cameraTexture.width, cameraTexture.height, quad.transform.localScale.z); 52 | quad.GetComponent ().material.mainTexture = outputTexture; 53 | 54 | 55 | 56 | // sepia 57 | mSepiaKernel = new Mat (4, 4, CvType.CV_32F); 58 | mSepiaKernel.put (0, 0, /* R */0.189f, 0.769f, 0.393f, 0f); 59 | mSepiaKernel.put (1, 0, /* G */0.168f, 0.686f, 0.349f, 0f); 60 | mSepiaKernel.put (2, 0, /* B */0.131f, 0.534f, 0.272f, 0f); 61 | mSepiaKernel.put (3, 0, /* A */0.000f, 0.000f, 0.000f, 1f); 62 | 63 | 64 | // pixelize 65 | mIntermediateMat = new Mat (); 66 | mSize0 = new Size (); 67 | } 68 | 69 | // Update is called once per frame 70 | void Update () 71 | { 72 | 73 | } 74 | 75 | void OnPostRender () 76 | { 77 | 78 | UnityEngine.Rect rect = new UnityEngine.Rect (0, 0, cameraTexture.width, cameraTexture.height); 79 | cameraTexture.ReadPixels (rect, 0, 0, true); 80 | 81 | 82 | 83 | Utils.texture2DToMat (cameraTexture, cameraMat); 84 | 85 | 86 | if (mode == modeType.original) { 87 | 88 | Imgproc.putText (cameraMat, "ORIGINAL MODE " + cameraTexture.width + "x" + cameraTexture.height, new Point (5, cameraTexture.height - 5), Imgproc.FONT_HERSHEY_PLAIN, 1.0, new Scalar (255, 0, 0, 255)); 89 | 90 | } else if (mode == modeType.sepia) { 91 | 92 | Core.transform (cameraMat, cameraMat, mSepiaKernel); 93 | 94 | Imgproc.putText (cameraMat, "SEPIA MODE " + cameraTexture.width + "x" + cameraTexture.height, new Point (5, cameraTexture.height - 5), Imgproc.FONT_HERSHEY_PLAIN, 1.0, new Scalar (255, 0, 0, 255)); 95 | 96 | } else if (mode == modeType.pixelize) { 97 | Imgproc.resize (cameraMat, mIntermediateMat, mSize0, 0.2, 0.2, Imgproc.INTER_NEAREST); 98 | Imgproc.resize (mIntermediateMat, cameraMat, cameraMat.size (), 0.0, 0.0, Imgproc.INTER_NEAREST); 99 | 100 | Imgproc.putText (cameraMat, "PIXELIZE MODE" + cameraTexture.width + "x" + cameraTexture.height, new Point (5, cameraTexture.height - 5), Imgproc.FONT_HERSHEY_PLAIN, 1.0, new Scalar (255, 0, 0, 255)); 101 | 102 | } 103 | 104 | 105 | Utils.matToTexture2D (cameraMat, outputTexture, colors); 106 | } 107 | 108 | void OnGUI () 109 | { 110 | float screenScale = Screen.width / 240.0f; 111 | Matrix4x4 scaledMatrix = Matrix4x4.Scale (new Vector3 (screenScale, screenScale, screenScale)); 112 | GUI.matrix = scaledMatrix; 113 | 114 | 115 | GUILayout.BeginVertical (); 116 | 117 | if (GUILayout.Button ("Original")) { 118 | mode = modeType.original; 119 | } 120 | 121 | if (GUILayout.Button ("sepia")) { 122 | mode = modeType.sepia; 123 | } 124 | 125 | if (GUILayout.Button ("pixelize")) { 126 | mode = modeType.pixelize; 127 | } 128 | 129 | 130 | GUILayout.EndVertical (); 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /Assets/VuforiaWithOpenCVForUnityExample/PostRenderToMatExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 342471e66edfb1840afa3b8d588cc1f3 3 | timeCreated: 1472226423 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/VuforiaWithOpenCVForUnityExample/PostRenderToMatExample.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0.44657826, g: 0.49641263, b: 0.57481676, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 11 47 | m_GIWorkflowMode: 0 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 1 56 | m_LightmapEditorSettings: 57 | serializedVersion: 12 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 1 64 | m_CompAOExponentDirect: 0 65 | m_ExtractAmbientOcclusion: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 1 75 | m_BakeBackend: 0 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVREnvironmentSampleCount: 500 81 | m_PVREnvironmentReferencePointCount: 2048 82 | m_PVRFilteringMode: 0 83 | m_PVRDenoiserTypeDirect: 0 84 | m_PVRDenoiserTypeIndirect: 0 85 | m_PVRDenoiserTypeAO: 0 86 | m_PVRFilterTypeDirect: 0 87 | m_PVRFilterTypeIndirect: 0 88 | m_PVRFilterTypeAO: 0 89 | m_PVREnvironmentMIS: 0 90 | m_PVRCulling: 1 91 | m_PVRFilteringGaussRadiusDirect: 1 92 | m_PVRFilteringGaussRadiusIndirect: 5 93 | m_PVRFilteringGaussRadiusAO: 2 94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 96 | m_PVRFilteringAtrousPositionSigmaAO: 1 97 | m_ExportTrainingData: 0 98 | m_TrainingDataDestination: TrainingData 99 | m_LightProbeSampleCountMultiplier: 4 100 | m_LightingDataAsset: {fileID: 0} 101 | m_UseShadowmask: 0 102 | --- !u!196 &4 103 | NavMeshSettings: 104 | serializedVersion: 2 105 | m_ObjectHideFlags: 0 106 | m_BuildSettings: 107 | serializedVersion: 2 108 | agentTypeID: 0 109 | agentRadius: 0.5 110 | agentHeight: 2 111 | agentSlope: 45 112 | agentClimb: 0.4 113 | ledgeDropHeight: 0 114 | maxJumpAcrossDistance: 0 115 | minRegionArea: 2 116 | manualCellSize: 0 117 | cellSize: 0.16666667 118 | manualTileSize: 0 119 | tileSize: 256 120 | accuratePlacement: 0 121 | debug: 122 | m_Flags: 0 123 | m_NavMeshData: {fileID: 0} 124 | --- !u!1 &322681424 125 | GameObject: 126 | m_ObjectHideFlags: 0 127 | m_CorrespondingSourceObject: {fileID: 0} 128 | m_PrefabInstance: {fileID: 0} 129 | m_PrefabAsset: {fileID: 0} 130 | serializedVersion: 6 131 | m_Component: 132 | - component: {fileID: 322681430} 133 | - component: {fileID: 322681429} 134 | - component: {fileID: 322681428} 135 | - component: {fileID: 322681427} 136 | - component: {fileID: 322681426} 137 | - component: {fileID: 322681425} 138 | m_Layer: 0 139 | m_Name: ImageTarget 140 | m_TagString: Untagged 141 | m_Icon: {fileID: 0} 142 | m_NavMeshLayer: 0 143 | m_StaticEditorFlags: 0 144 | m_IsActive: 1 145 | --- !u!33 &322681425 146 | MeshFilter: 147 | m_ObjectHideFlags: 0 148 | m_CorrespondingSourceObject: {fileID: 0} 149 | m_PrefabInstance: {fileID: 0} 150 | m_PrefabAsset: {fileID: 0} 151 | m_GameObject: {fileID: 322681424} 152 | m_Mesh: {fileID: 698685007} 153 | --- !u!23 &322681426 154 | MeshRenderer: 155 | m_ObjectHideFlags: 0 156 | m_CorrespondingSourceObject: {fileID: 0} 157 | m_PrefabInstance: {fileID: 0} 158 | m_PrefabAsset: {fileID: 0} 159 | m_GameObject: {fileID: 322681424} 160 | m_Enabled: 1 161 | m_CastShadows: 1 162 | m_ReceiveShadows: 1 163 | m_DynamicOccludee: 1 164 | m_MotionVectors: 1 165 | m_LightProbeUsage: 0 166 | m_ReflectionProbeUsage: 1 167 | m_RayTracingMode: 2 168 | m_RenderingLayerMask: 1 169 | m_RendererPriority: 0 170 | m_Materials: 171 | - {fileID: 969542069} 172 | m_StaticBatchInfo: 173 | firstSubMesh: 0 174 | subMeshCount: 0 175 | m_StaticBatchRoot: {fileID: 0} 176 | m_ProbeAnchor: {fileID: 0} 177 | m_LightProbeVolumeOverride: {fileID: 0} 178 | m_ScaleInLightmap: 1 179 | m_ReceiveGI: 1 180 | m_PreserveUVs: 0 181 | m_IgnoreNormalsForChartDetection: 0 182 | m_ImportantGI: 0 183 | m_StitchLightmapSeams: 0 184 | m_SelectedEditorRenderState: 3 185 | m_MinimumChartSize: 4 186 | m_AutoUVMaxDistance: 0.5 187 | m_AutoUVMaxAngle: 89 188 | m_LightmapParameters: {fileID: 0} 189 | m_SortingLayerID: 0 190 | m_SortingLayer: 0 191 | m_SortingOrder: 0 192 | --- !u!114 &322681427 193 | MonoBehaviour: 194 | m_ObjectHideFlags: 0 195 | m_CorrespondingSourceObject: {fileID: 0} 196 | m_PrefabInstance: {fileID: 0} 197 | m_PrefabAsset: {fileID: 0} 198 | m_GameObject: {fileID: 322681424} 199 | m_Enabled: 1 200 | m_EditorHideFlags: 0 201 | m_Script: {fileID: -1770992566, guid: bab6fa851cf5a1a4bba3cec5f191cb8e, type: 3} 202 | m_Name: 203 | m_EditorClassIdentifier: 204 | --- !u!114 &322681428 205 | MonoBehaviour: 206 | m_ObjectHideFlags: 0 207 | m_CorrespondingSourceObject: {fileID: 0} 208 | m_PrefabInstance: {fileID: 0} 209 | m_PrefabAsset: {fileID: 0} 210 | m_GameObject: {fileID: 322681424} 211 | m_Enabled: 1 212 | m_EditorHideFlags: 0 213 | m_Script: {fileID: 11500000, guid: 5a917f0af64a6423093132dab321c15f, type: 3} 214 | m_Name: 215 | m_EditorClassIdentifier: 216 | --- !u!114 &322681429 217 | MonoBehaviour: 218 | m_ObjectHideFlags: 0 219 | m_CorrespondingSourceObject: {fileID: 0} 220 | m_PrefabInstance: {fileID: 0} 221 | m_PrefabAsset: {fileID: 0} 222 | m_GameObject: {fileID: 322681424} 223 | m_Enabled: 1 224 | m_EditorHideFlags: 0 225 | m_Script: {fileID: -1631628248, guid: bab6fa851cf5a1a4bba3cec5f191cb8e, type: 3} 226 | m_Name: 227 | m_EditorClassIdentifier: 228 | mTrackableName: Astronaut 229 | mPreserveChildSize: 0 230 | mInitializedInEditor: 1 231 | mDataSetPath: Vuforia/VuforiaMars_Images.xml 232 | mAspectRatio: 1.7272727 233 | mImageTargetType: 0 234 | mWidth: 0.06985 235 | mHeight: 0.12065 236 | --- !u!4 &322681430 237 | Transform: 238 | m_ObjectHideFlags: 0 239 | m_CorrespondingSourceObject: {fileID: 0} 240 | m_PrefabInstance: {fileID: 0} 241 | m_PrefabAsset: {fileID: 0} 242 | m_GameObject: {fileID: 322681424} 243 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 244 | m_LocalPosition: {x: 0, y: 0, z: 0} 245 | m_LocalScale: {x: 0.12065, y: 0.12065, z: 0.12065} 246 | m_Children: 247 | - {fileID: 1523839655} 248 | m_Father: {fileID: 0} 249 | m_RootOrder: 4 250 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 251 | --- !u!1 &698104848 252 | GameObject: 253 | m_ObjectHideFlags: 0 254 | m_CorrespondingSourceObject: {fileID: 0} 255 | m_PrefabInstance: {fileID: 0} 256 | m_PrefabAsset: {fileID: 0} 257 | serializedVersion: 6 258 | m_Component: 259 | - component: {fileID: 698104854} 260 | - component: {fileID: 698104853} 261 | - component: {fileID: 698104852} 262 | - component: {fileID: 698104851} 263 | - component: {fileID: 698104850} 264 | - component: {fileID: 698104849} 265 | m_Layer: 0 266 | m_Name: ARCamera 267 | m_TagString: Untagged 268 | m_Icon: {fileID: 0} 269 | m_NavMeshLayer: 0 270 | m_StaticEditorFlags: 0 271 | m_IsActive: 1 272 | --- !u!114 &698104849 273 | MonoBehaviour: 274 | m_ObjectHideFlags: 0 275 | m_CorrespondingSourceObject: {fileID: 0} 276 | m_PrefabInstance: {fileID: 0} 277 | m_PrefabAsset: {fileID: 0} 278 | m_GameObject: {fileID: 698104848} 279 | m_Enabled: 1 280 | m_EditorHideFlags: 0 281 | m_Script: {fileID: 11500000, guid: 342471e66edfb1840afa3b8d588cc1f3, type: 3} 282 | m_Name: 283 | m_EditorClassIdentifier: 284 | quad: {fileID: 2130338423} 285 | mainCamera: {fileID: 1707624672} 286 | mode: 0 287 | --- !u!114 &698104850 288 | MonoBehaviour: 289 | m_ObjectHideFlags: 0 290 | m_CorrespondingSourceObject: {fileID: 0} 291 | m_PrefabInstance: {fileID: 0} 292 | m_PrefabAsset: {fileID: 0} 293 | m_GameObject: {fileID: 698104848} 294 | m_Enabled: 1 295 | m_EditorHideFlags: 0 296 | m_Script: {fileID: 11500000, guid: c47f92041efbb4b429a4eafca855ebe3, type: 3} 297 | m_Name: 298 | m_EditorClassIdentifier: 299 | --- !u!114 &698104851 300 | MonoBehaviour: 301 | m_ObjectHideFlags: 0 302 | m_CorrespondingSourceObject: {fileID: 0} 303 | m_PrefabInstance: {fileID: 0} 304 | m_PrefabAsset: {fileID: 0} 305 | m_GameObject: {fileID: 698104848} 306 | m_Enabled: 1 307 | m_EditorHideFlags: 0 308 | m_Script: {fileID: -1826476478, guid: bab6fa851cf5a1a4bba3cec5f191cb8e, type: 3} 309 | m_Name: 310 | m_EditorClassIdentifier: 311 | mWorldCenterMode: 1 312 | mWorldCenter: {fileID: 0} 313 | --- !u!81 &698104852 314 | AudioListener: 315 | m_ObjectHideFlags: 0 316 | m_CorrespondingSourceObject: {fileID: 0} 317 | m_PrefabInstance: {fileID: 0} 318 | m_PrefabAsset: {fileID: 0} 319 | m_GameObject: {fileID: 698104848} 320 | m_Enabled: 1 321 | --- !u!20 &698104853 322 | Camera: 323 | m_ObjectHideFlags: 0 324 | m_CorrespondingSourceObject: {fileID: 0} 325 | m_PrefabInstance: {fileID: 0} 326 | m_PrefabAsset: {fileID: 0} 327 | m_GameObject: {fileID: 698104848} 328 | m_Enabled: 1 329 | serializedVersion: 2 330 | m_ClearFlags: 2 331 | m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1} 332 | m_projectionMatrixMode: 1 333 | m_GateFitMode: 2 334 | m_FOVAxisMode: 0 335 | m_SensorSize: {x: 36, y: 24} 336 | m_LensShift: {x: 0, y: 0} 337 | m_FocalLength: 50 338 | m_NormalizedViewPortRect: 339 | serializedVersion: 2 340 | x: 0 341 | y: 0 342 | width: 1 343 | height: 1 344 | near clip plane: 0.05 345 | far clip plane: 2000 346 | field of view: 60 347 | orthographic: 0 348 | orthographic size: 5 349 | m_Depth: 1 350 | m_CullingMask: 351 | serializedVersion: 2 352 | m_Bits: 1 353 | m_RenderingPath: -1 354 | m_TargetTexture: {fileID: 0} 355 | m_TargetDisplay: 0 356 | m_TargetEye: 3 357 | m_HDR: 0 358 | m_AllowMSAA: 1 359 | m_AllowDynamicResolution: 0 360 | m_ForceIntoRT: 0 361 | m_OcclusionCulling: 1 362 | m_StereoConvergence: 10 363 | m_StereoSeparation: 0.022 364 | --- !u!4 &698104854 365 | Transform: 366 | m_ObjectHideFlags: 0 367 | m_CorrespondingSourceObject: {fileID: 0} 368 | m_PrefabInstance: {fileID: 0} 369 | m_PrefabAsset: {fileID: 0} 370 | m_GameObject: {fileID: 698104848} 371 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 372 | m_LocalPosition: {x: 0, y: 0, z: 0} 373 | m_LocalScale: {x: 1, y: 1, z: 1} 374 | m_Children: [] 375 | m_Father: {fileID: 0} 376 | m_RootOrder: 3 377 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 378 | --- !u!43 &698685007 379 | Mesh: 380 | m_ObjectHideFlags: 0 381 | m_CorrespondingSourceObject: {fileID: 0} 382 | m_PrefabInstance: {fileID: 0} 383 | m_PrefabAsset: {fileID: 0} 384 | m_Name: 385 | serializedVersion: 10 386 | m_SubMeshes: 387 | - serializedVersion: 2 388 | firstByte: 0 389 | indexCount: 6 390 | topology: 0 391 | baseVertex: 0 392 | firstVertex: 0 393 | vertexCount: 4 394 | localAABB: 395 | m_Center: {x: 0, y: 0, z: 0} 396 | m_Extent: {x: 0.28947368, y: 0, z: 0.5} 397 | m_Shapes: 398 | vertices: [] 399 | shapes: [] 400 | channels: [] 401 | fullWeights: [] 402 | m_BindPose: [] 403 | m_BoneNameHashes: 404 | m_RootBoneNameHash: 0 405 | m_BonesAABB: [] 406 | m_VariableBoneCountWeights: 407 | m_Data: 408 | m_MeshCompression: 0 409 | m_IsReadable: 1 410 | m_KeepVertices: 1 411 | m_KeepIndices: 1 412 | m_IndexFormat: 0 413 | m_IndexBuffer: 000001000200020001000300 414 | m_VertexData: 415 | serializedVersion: 3 416 | m_VertexCount: 4 417 | m_Channels: 418 | - stream: 0 419 | offset: 0 420 | format: 0 421 | dimension: 3 422 | - stream: 0 423 | offset: 12 424 | format: 0 425 | dimension: 3 426 | - stream: 0 427 | offset: 0 428 | format: 0 429 | dimension: 0 430 | - stream: 0 431 | offset: 0 432 | format: 0 433 | dimension: 0 434 | - stream: 0 435 | offset: 24 436 | format: 0 437 | dimension: 2 438 | - stream: 0 439 | offset: 0 440 | format: 0 441 | dimension: 0 442 | - stream: 0 443 | offset: 0 444 | format: 0 445 | dimension: 0 446 | - stream: 0 447 | offset: 0 448 | format: 0 449 | dimension: 0 450 | - stream: 0 451 | offset: 0 452 | format: 0 453 | dimension: 0 454 | - stream: 0 455 | offset: 0 456 | format: 0 457 | dimension: 0 458 | - stream: 0 459 | offset: 0 460 | format: 0 461 | dimension: 0 462 | - stream: 0 463 | offset: 0 464 | format: 0 465 | dimension: 0 466 | - stream: 0 467 | offset: 0 468 | format: 0 469 | dimension: 0 470 | - stream: 0 471 | offset: 0 472 | format: 0 473 | dimension: 0 474 | m_DataSize: 128 475 | _typelessdata: e53594be00000000000000bf000000000000803f000000000000000000000000e53594be000000000000003f000000000000803f00000000000000000000803fe535943e00000000000000bf000000000000803f000000000000803f00000000e535943e000000000000003f000000000000803f000000000000803f0000803f 476 | m_CompressedMesh: 477 | m_Vertices: 478 | m_NumItems: 0 479 | m_Range: 0 480 | m_Start: 0 481 | m_Data: 482 | m_BitSize: 0 483 | m_UV: 484 | m_NumItems: 0 485 | m_Range: 0 486 | m_Start: 0 487 | m_Data: 488 | m_BitSize: 0 489 | m_Normals: 490 | m_NumItems: 0 491 | m_Range: 0 492 | m_Start: 0 493 | m_Data: 494 | m_BitSize: 0 495 | m_Tangents: 496 | m_NumItems: 0 497 | m_Range: 0 498 | m_Start: 0 499 | m_Data: 500 | m_BitSize: 0 501 | m_Weights: 502 | m_NumItems: 0 503 | m_Data: 504 | m_BitSize: 0 505 | m_NormalSigns: 506 | m_NumItems: 0 507 | m_Data: 508 | m_BitSize: 0 509 | m_TangentSigns: 510 | m_NumItems: 0 511 | m_Data: 512 | m_BitSize: 0 513 | m_FloatColors: 514 | m_NumItems: 0 515 | m_Range: 0 516 | m_Start: 0 517 | m_Data: 518 | m_BitSize: 0 519 | m_BoneIndices: 520 | m_NumItems: 0 521 | m_Data: 522 | m_BitSize: 0 523 | m_Triangles: 524 | m_NumItems: 0 525 | m_Data: 526 | m_BitSize: 0 527 | m_UVInfo: 0 528 | m_LocalAABB: 529 | m_Center: {x: 0, y: 0, z: 0} 530 | m_Extent: {x: 0.5, y: 0, z: 0.5} 531 | m_MeshUsageFlags: 0 532 | m_BakedConvexCollisionMesh: 533 | m_BakedTriangleCollisionMesh: 534 | m_MeshMetrics[0]: 1 535 | m_MeshMetrics[1]: 1 536 | m_MeshOptimizationFlags: -1 537 | m_StreamData: 538 | offset: 0 539 | size: 0 540 | path: 541 | --- !u!21 &969542069 542 | Material: 543 | serializedVersion: 6 544 | m_ObjectHideFlags: 0 545 | m_CorrespondingSourceObject: {fileID: 0} 546 | m_PrefabInstance: {fileID: 0} 547 | m_PrefabAsset: {fileID: 0} 548 | m_Name: AstronautMaterial 549 | m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0} 550 | m_ShaderKeywords: 551 | m_LightmapFlags: 5 552 | m_EnableInstancingVariants: 0 553 | m_DoubleSidedGI: 0 554 | m_CustomRenderQueue: -1 555 | stringTagMap: {} 556 | disabledShaderPasses: [] 557 | m_SavedProperties: 558 | serializedVersion: 3 559 | m_TexEnvs: 560 | - _MainTex: 561 | m_Texture: {fileID: 2800000, guid: 77fb44a366db5cb41b8c06649271f8e6, type: 3} 562 | m_Scale: {x: 1, y: 1} 563 | m_Offset: {x: 0, y: 0} 564 | m_Floats: [] 565 | m_Colors: 566 | - _Color: {r: 0.82089555, g: 0.82089555, b: 0.82089555, a: 1} 567 | --- !u!1 &987344590 568 | GameObject: 569 | m_ObjectHideFlags: 0 570 | m_CorrespondingSourceObject: {fileID: 0} 571 | m_PrefabInstance: {fileID: 0} 572 | m_PrefabAsset: {fileID: 0} 573 | serializedVersion: 6 574 | m_Component: 575 | - component: {fileID: 987344592} 576 | - component: {fileID: 987344591} 577 | m_Layer: 0 578 | m_Name: Directional Light 579 | m_TagString: Untagged 580 | m_Icon: {fileID: 0} 581 | m_NavMeshLayer: 0 582 | m_StaticEditorFlags: 0 583 | m_IsActive: 1 584 | --- !u!108 &987344591 585 | Light: 586 | m_ObjectHideFlags: 0 587 | m_CorrespondingSourceObject: {fileID: 0} 588 | m_PrefabInstance: {fileID: 0} 589 | m_PrefabAsset: {fileID: 0} 590 | m_GameObject: {fileID: 987344590} 591 | m_Enabled: 1 592 | serializedVersion: 10 593 | m_Type: 1 594 | m_Shape: 0 595 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 596 | m_Intensity: 1 597 | m_Range: 10 598 | m_SpotAngle: 30 599 | m_InnerSpotAngle: 21.80208 600 | m_CookieSize: 10 601 | m_Shadows: 602 | m_Type: 2 603 | m_Resolution: -1 604 | m_CustomResolution: -1 605 | m_Strength: 1 606 | m_Bias: 0.05 607 | m_NormalBias: 0.4 608 | m_NearPlane: 0.2 609 | m_CullingMatrixOverride: 610 | e00: 1 611 | e01: 0 612 | e02: 0 613 | e03: 0 614 | e10: 0 615 | e11: 1 616 | e12: 0 617 | e13: 0 618 | e20: 0 619 | e21: 0 620 | e22: 1 621 | e23: 0 622 | e30: 0 623 | e31: 0 624 | e32: 0 625 | e33: 1 626 | m_UseCullingMatrixOverride: 0 627 | m_Cookie: {fileID: 0} 628 | m_DrawHalo: 0 629 | m_Flare: {fileID: 0} 630 | m_RenderMode: 0 631 | m_CullingMask: 632 | serializedVersion: 2 633 | m_Bits: 4294967295 634 | m_RenderingLayerMask: 1 635 | m_Lightmapping: 4 636 | m_LightShadowCasterMode: 0 637 | m_AreaSize: {x: 1, y: 1} 638 | m_BounceIntensity: 1 639 | m_ColorTemperature: 6570 640 | m_UseColorTemperature: 0 641 | m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} 642 | m_UseBoundingSphereOverride: 0 643 | m_ShadowRadius: 0 644 | m_ShadowAngle: 0 645 | --- !u!4 &987344592 646 | Transform: 647 | m_ObjectHideFlags: 0 648 | m_CorrespondingSourceObject: {fileID: 0} 649 | m_PrefabInstance: {fileID: 0} 650 | m_PrefabAsset: {fileID: 0} 651 | m_GameObject: {fileID: 987344590} 652 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 653 | m_LocalPosition: {x: 0, y: 3, z: 0} 654 | m_LocalScale: {x: 1, y: 1, z: 1} 655 | m_Children: [] 656 | m_Father: {fileID: 0} 657 | m_RootOrder: 0 658 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 659 | --- !u!1 &1523839654 660 | GameObject: 661 | m_ObjectHideFlags: 0 662 | m_CorrespondingSourceObject: {fileID: 0} 663 | m_PrefabInstance: {fileID: 0} 664 | m_PrefabAsset: {fileID: 0} 665 | serializedVersion: 6 666 | m_Component: 667 | - component: {fileID: 1523839655} 668 | - component: {fileID: 1523839658} 669 | - component: {fileID: 1523839657} 670 | - component: {fileID: 1523839656} 671 | m_Layer: 0 672 | m_Name: Cube 673 | m_TagString: Untagged 674 | m_Icon: {fileID: 0} 675 | m_NavMeshLayer: 0 676 | m_StaticEditorFlags: 0 677 | m_IsActive: 1 678 | --- !u!4 &1523839655 679 | Transform: 680 | m_ObjectHideFlags: 0 681 | m_CorrespondingSourceObject: {fileID: 0} 682 | m_PrefabInstance: {fileID: 0} 683 | m_PrefabAsset: {fileID: 0} 684 | m_GameObject: {fileID: 1523839654} 685 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 686 | m_LocalPosition: {x: 0, y: 0.2, z: 0} 687 | m_LocalScale: {x: 0.4, y: 0.4, z: 0.4} 688 | m_Children: [] 689 | m_Father: {fileID: 322681430} 690 | m_RootOrder: 0 691 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 692 | --- !u!23 &1523839656 693 | MeshRenderer: 694 | m_ObjectHideFlags: 0 695 | m_CorrespondingSourceObject: {fileID: 0} 696 | m_PrefabInstance: {fileID: 0} 697 | m_PrefabAsset: {fileID: 0} 698 | m_GameObject: {fileID: 1523839654} 699 | m_Enabled: 1 700 | m_CastShadows: 1 701 | m_ReceiveShadows: 1 702 | m_DynamicOccludee: 1 703 | m_MotionVectors: 1 704 | m_LightProbeUsage: 1 705 | m_ReflectionProbeUsage: 1 706 | m_RayTracingMode: 2 707 | m_RenderingLayerMask: 1 708 | m_RendererPriority: 0 709 | m_Materials: 710 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} 711 | m_StaticBatchInfo: 712 | firstSubMesh: 0 713 | subMeshCount: 0 714 | m_StaticBatchRoot: {fileID: 0} 715 | m_ProbeAnchor: {fileID: 0} 716 | m_LightProbeVolumeOverride: {fileID: 0} 717 | m_ScaleInLightmap: 1 718 | m_ReceiveGI: 1 719 | m_PreserveUVs: 1 720 | m_IgnoreNormalsForChartDetection: 0 721 | m_ImportantGI: 0 722 | m_StitchLightmapSeams: 0 723 | m_SelectedEditorRenderState: 3 724 | m_MinimumChartSize: 4 725 | m_AutoUVMaxDistance: 0.5 726 | m_AutoUVMaxAngle: 89 727 | m_LightmapParameters: {fileID: 0} 728 | m_SortingLayerID: 0 729 | m_SortingLayer: 0 730 | m_SortingOrder: 0 731 | --- !u!65 &1523839657 732 | BoxCollider: 733 | m_ObjectHideFlags: 0 734 | m_CorrespondingSourceObject: {fileID: 0} 735 | m_PrefabInstance: {fileID: 0} 736 | m_PrefabAsset: {fileID: 0} 737 | m_GameObject: {fileID: 1523839654} 738 | m_Material: {fileID: 0} 739 | m_IsTrigger: 0 740 | m_Enabled: 1 741 | serializedVersion: 2 742 | m_Size: {x: 1, y: 1, z: 1} 743 | m_Center: {x: 0, y: 0, z: 0} 744 | --- !u!33 &1523839658 745 | MeshFilter: 746 | m_ObjectHideFlags: 0 747 | m_CorrespondingSourceObject: {fileID: 0} 748 | m_PrefabInstance: {fileID: 0} 749 | m_PrefabAsset: {fileID: 0} 750 | m_GameObject: {fileID: 1523839654} 751 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 752 | --- !u!1 &1707624668 753 | GameObject: 754 | m_ObjectHideFlags: 0 755 | m_CorrespondingSourceObject: {fileID: 0} 756 | m_PrefabInstance: {fileID: 0} 757 | m_PrefabAsset: {fileID: 0} 758 | serializedVersion: 6 759 | m_Component: 760 | - component: {fileID: 1707624673} 761 | - component: {fileID: 1707624672} 762 | - component: {fileID: 1707624671} 763 | m_Layer: 5 764 | m_Name: Main Camera 765 | m_TagString: Untagged 766 | m_Icon: {fileID: 0} 767 | m_NavMeshLayer: 0 768 | m_StaticEditorFlags: 0 769 | m_IsActive: 1 770 | --- !u!124 &1707624671 771 | Behaviour: 772 | m_ObjectHideFlags: 0 773 | m_CorrespondingSourceObject: {fileID: 0} 774 | m_PrefabInstance: {fileID: 0} 775 | m_PrefabAsset: {fileID: 0} 776 | m_GameObject: {fileID: 1707624668} 777 | m_Enabled: 0 778 | --- !u!20 &1707624672 779 | Camera: 780 | m_ObjectHideFlags: 0 781 | m_CorrespondingSourceObject: {fileID: 0} 782 | m_PrefabInstance: {fileID: 0} 783 | m_PrefabAsset: {fileID: 0} 784 | m_GameObject: {fileID: 1707624668} 785 | m_Enabled: 1 786 | serializedVersion: 2 787 | m_ClearFlags: 3 788 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 789 | m_projectionMatrixMode: 1 790 | m_GateFitMode: 2 791 | m_FOVAxisMode: 0 792 | m_SensorSize: {x: 36, y: 24} 793 | m_LensShift: {x: 0, y: 0} 794 | m_FocalLength: 50 795 | m_NormalizedViewPortRect: 796 | serializedVersion: 2 797 | x: 0 798 | y: 0 799 | width: 1 800 | height: 1 801 | near clip plane: 0.3 802 | far clip plane: 1000 803 | field of view: 60 804 | orthographic: 1 805 | orthographic size: 50 806 | m_Depth: 2 807 | m_CullingMask: 808 | serializedVersion: 2 809 | m_Bits: 32 810 | m_RenderingPath: -1 811 | m_TargetTexture: {fileID: 0} 812 | m_TargetDisplay: 0 813 | m_TargetEye: 3 814 | m_HDR: 0 815 | m_AllowMSAA: 1 816 | m_AllowDynamicResolution: 0 817 | m_ForceIntoRT: 0 818 | m_OcclusionCulling: 1 819 | m_StereoConvergence: 10 820 | m_StereoSeparation: 0.022 821 | --- !u!4 &1707624673 822 | Transform: 823 | m_ObjectHideFlags: 0 824 | m_CorrespondingSourceObject: {fileID: 0} 825 | m_PrefabInstance: {fileID: 0} 826 | m_PrefabAsset: {fileID: 0} 827 | m_GameObject: {fileID: 1707624668} 828 | m_LocalRotation: {x: 1, y: 0, z: 0, w: 0} 829 | m_LocalPosition: {x: 0, y: 0, z: 0} 830 | m_LocalScale: {x: 1, y: 1, z: 1} 831 | m_Children: [] 832 | m_Father: {fileID: 0} 833 | m_RootOrder: 2 834 | m_LocalEulerAnglesHint: {x: 180, y: 0, z: 0} 835 | --- !u!1 &2130338423 836 | GameObject: 837 | m_ObjectHideFlags: 0 838 | m_CorrespondingSourceObject: {fileID: 0} 839 | m_PrefabInstance: {fileID: 0} 840 | m_PrefabAsset: {fileID: 0} 841 | serializedVersion: 6 842 | m_Component: 843 | - component: {fileID: 2130338428} 844 | - component: {fileID: 2130338427} 845 | - component: {fileID: 2130338426} 846 | - component: {fileID: 2130338425} 847 | m_Layer: 5 848 | m_Name: Quad 849 | m_TagString: Untagged 850 | m_Icon: {fileID: 0} 851 | m_NavMeshLayer: 0 852 | m_StaticEditorFlags: 0 853 | m_IsActive: 1 854 | --- !u!23 &2130338425 855 | MeshRenderer: 856 | m_ObjectHideFlags: 0 857 | m_CorrespondingSourceObject: {fileID: 0} 858 | m_PrefabInstance: {fileID: 0} 859 | m_PrefabAsset: {fileID: 0} 860 | m_GameObject: {fileID: 2130338423} 861 | m_Enabled: 1 862 | m_CastShadows: 1 863 | m_ReceiveShadows: 1 864 | m_DynamicOccludee: 1 865 | m_MotionVectors: 1 866 | m_LightProbeUsage: 1 867 | m_ReflectionProbeUsage: 1 868 | m_RayTracingMode: 2 869 | m_RenderingLayerMask: 1 870 | m_RendererPriority: 0 871 | m_Materials: 872 | - {fileID: 2100000, guid: 12317db4e4abc304690f2189eec2beb3, type: 2} 873 | m_StaticBatchInfo: 874 | firstSubMesh: 0 875 | subMeshCount: 0 876 | m_StaticBatchRoot: {fileID: 0} 877 | m_ProbeAnchor: {fileID: 0} 878 | m_LightProbeVolumeOverride: {fileID: 0} 879 | m_ScaleInLightmap: 1 880 | m_ReceiveGI: 1 881 | m_PreserveUVs: 1 882 | m_IgnoreNormalsForChartDetection: 0 883 | m_ImportantGI: 0 884 | m_StitchLightmapSeams: 0 885 | m_SelectedEditorRenderState: 3 886 | m_MinimumChartSize: 4 887 | m_AutoUVMaxDistance: 0.5 888 | m_AutoUVMaxAngle: 89 889 | m_LightmapParameters: {fileID: 0} 890 | m_SortingLayerID: 0 891 | m_SortingLayer: 0 892 | m_SortingOrder: 0 893 | --- !u!64 &2130338426 894 | MeshCollider: 895 | m_ObjectHideFlags: 0 896 | m_CorrespondingSourceObject: {fileID: 0} 897 | m_PrefabInstance: {fileID: 0} 898 | m_PrefabAsset: {fileID: 0} 899 | m_GameObject: {fileID: 2130338423} 900 | m_Material: {fileID: 0} 901 | m_IsTrigger: 0 902 | m_Enabled: 1 903 | serializedVersion: 4 904 | m_Convex: 0 905 | m_CookingOptions: 30 906 | m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} 907 | --- !u!33 &2130338427 908 | MeshFilter: 909 | m_ObjectHideFlags: 0 910 | m_CorrespondingSourceObject: {fileID: 0} 911 | m_PrefabInstance: {fileID: 0} 912 | m_PrefabAsset: {fileID: 0} 913 | m_GameObject: {fileID: 2130338423} 914 | m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} 915 | --- !u!4 &2130338428 916 | Transform: 917 | m_ObjectHideFlags: 0 918 | m_CorrespondingSourceObject: {fileID: 0} 919 | m_PrefabInstance: {fileID: 0} 920 | m_PrefabAsset: {fileID: 0} 921 | m_GameObject: {fileID: 2130338423} 922 | m_LocalRotation: {x: 1, y: 0, z: 0, w: 0} 923 | m_LocalPosition: {x: 0, y: 0, z: -10} 924 | m_LocalScale: {x: 100, y: 100, z: 0} 925 | m_Children: [] 926 | m_Father: {fileID: 0} 927 | m_RootOrder: 1 928 | m_LocalEulerAnglesHint: {x: 180, y: 0, z: 0} 929 | -------------------------------------------------------------------------------- /Assets/VuforiaWithOpenCVForUnityExample/PostRenderToMatExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f964998aaad66724a938bf7d19306e8e 3 | timeCreated: 1472226271 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CameraImageToMatExample.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EnoxSoftware/VuforiaWithOpenCVForUnityExample/c68aad92f778763b361f6ebf8a6d838ebc0f57ce/CameraImageToMatExample.PNG -------------------------------------------------------------------------------- /Light_Frame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EnoxSoftware/VuforiaWithOpenCVForUnityExample/c68aad92f778763b361f6ebf8a6d838ebc0f57ce/Light_Frame.png -------------------------------------------------------------------------------- /PackageManager.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EnoxSoftware/VuforiaWithOpenCVForUnityExample/c68aad92f778763b361f6ebf8a6d838ebc0f57ce/PackageManager.PNG -------------------------------------------------------------------------------- /PostRenderToMatExample.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EnoxSoftware/VuforiaWithOpenCVForUnityExample/c68aad92f778763b361f6ebf8a6d838ebc0f57ce/PostRenderToMatExample.PNG -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Vuforia with OpenCV for Unity Example 2 | ==================== 3 | 4 | Demo Video 5 | ----- 6 | [![](http://img.youtube.com/vi/TnF90ladrOo/sddefault.jpg)](https://www.youtube.com/watch?v=TnF90ladrOo) 7 | 8 | Environment 9 | ----- 10 | Windows 10 11 | Unity 2019.3.10f1 12 | Vuforia Engine AR 8.5.9 13 | [OpenCV for Unity](https://assetstore.unity.com/packages/tools/integration/opencv-for-unity-21088?aid=1011l4ehR) 2.4.3 14 | 15 | Setup 16 | ----- 17 | * Setup Vuforia ([Getting Started with Vuforia Engine in Unity](https://library.vuforia.com/articles/Training/getting-started-with-vuforia-in-unity.html)) 18 | ![PackageManager.PNG](PackageManager.PNG) 19 | * Import OpenCVForUnity2.4.3 from AssetStore 20 | * Import VuforiaWithOpenCVForUnityExample.unitypackage 21 | 22 | Examples 23 | ----- 24 | **[CameraImageToMatExample.cs](/Assets/VuforiaWithOpenCVForUnityExample/CameraImageToMatExample.cs)** 25 | Conversion from CameraImage(without augmentation) of "Vuforia" to Mat of "OpenCV for Unity". 26 | ![CameraImageToMatExample.PNG](CameraImageToMatExample.PNG) 27 | 28 | **[PostRenderToMatExample.cs](/Assets/VuforiaWithOpenCVForUnityExample/PostRenderToMatExample.cs)** 29 | Conversion from PostRenderTexture(ARCamera) of "Vuforia" to Mat of "OpenCV for Unity". 30 | ![PostRenderToMatExample.PNG](PostRenderToMatExample.PNG) 31 | 32 | 33 | ![Light_Frame.png](Light_Frame.png) 34 | 35 | 36 | -------------------------------------------------------------------------------- /VuforiaWithOpenCVForUnityExample.unitypackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EnoxSoftware/VuforiaWithOpenCVForUnityExample/c68aad92f778763b361f6ebf8a6d838ebc0f57ce/VuforiaWithOpenCVForUnityExample.unitypackage --------------------------------------------------------------------------------