This commit is contained in:
Alexander Munch-Hansen 2019-02-20 17:48:59 +01:00
parent bcb2ad1630
commit 6da0efe753
38 changed files with 4771 additions and 273 deletions

BIN
AR-2/Assets/.DS_Store vendored

Binary file not shown.

1156
AR-2/Assets/2a1.unity Normal file

File diff suppressed because it is too large Load Diff

1156
AR-2/Assets/2a2.unity Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
Shader "AR/BeerShader"
{
SubShader
{
Tags { "Queue"="Geometry-100" }
Pass
{
ZWrite On
ColorMask 0
}
}
}

View File

@ -0,0 +1,60 @@
Shader "AR/BeerShader_2"
{
Properties {
_MainTex ("Beer Texture", 2D) = "white" {}
}
SubShader
{
Tags { "Queue"="Geometry-100" }
ZWrite On
ColorMask 0
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
fixed4 _Color;
struct Input {
float4 position : POSITION;
float4 color : COLOR;
float2 coord : TEXCOORD0;
};
struct VertexToFragment {
float4 position : SV_POSITION;
float4 color : COLOR;
half2 coord : TEXCOORD0;
};
VertexToFragment vert(Input IN) {
VertexToFragment OUT;
OUT.position = UnityObjectToClipPos( IN.position);
OUT.color = IN.color;
OUT.coord = IN.coord;
return OUT;
}
sampler2D _MainTex;
fixed4 frag(VertexToFragment IN) : SV_Target {
fixed4 c = tex2D(_MainTex, IN.coord) * IN.color;
if (c.r == 0) {
discard;
}
return IN.color;
}
ENDCG
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

473
AR-2/Assets/MatDisplay.cs Executable file
View File

@ -0,0 +1,473 @@
using OpenCVForUnity.CoreModule;
using OpenCVForUnity.ImgcodecsModule;
using OpenCVForUnity.ImgprocModule;
using System;
using UnityEngine;
public struct MatDisplaySettings {
public static float DEFAULT_SIZE = 0.75f;
public static MatDisplaySettings FULL_BACKGROUND = new MatDisplaySettings(0,0,2,true);
public static MatDisplaySettings BOTTOM_LEFT = new MatDisplaySettings(-1, -1, DEFAULT_SIZE, false);
public static MatDisplaySettings BOTTOM_RIGHT = new MatDisplaySettings(1, -1, DEFAULT_SIZE, false);
public static MatDisplaySettings TOP_LEFT = new MatDisplaySettings(-1, 1, DEFAULT_SIZE, false);
public static MatDisplaySettings TOP_RIGHT = new MatDisplaySettings(1, 1, DEFAULT_SIZE, false);
public float x, y, size;
public bool background;
public MatDisplaySettings(float x,float y,float size,bool background)
{
this.x = x;
this.y = y;
this.size = size;
this.background = background;
}
public MatDisplaySettings(float x,float y,float size) : this(x,y,size,false)
{
}
}
internal class MatDrawer
{
public bool active = false;
public MatDisplaySettings properties;
public int channels;
public Texture2D texture = null;
public bool flipY = false;
public void Activate(MatDisplaySettings properties)
{
active = true;
this.properties = properties;
}
public void Draw(Material material)
{
if (active)
{
material.mainTexture = texture;
material.SetPass(0);
float height = properties.size;
float width = height;
if (texture != null)
width *= (float)texture.width / texture.height;
width *= ((float)Screen.height / Screen.width);
float x = properties.x - width * 0.5f;
float y = properties.y - height * 0.5f;
if (x < -1)
x = -1;
if (x > 1 - width)
x = 1 - width;
if (y < -1)
y = -1;
if (y > 1 - height)
y = 1 - height;
float y1 = flipY ? y : y + height;
float y2 = flipY ? y + height : y;
GL.Begin(GL.TRIANGLE_STRIP);
GL.Color(Color.white);
GL.TexCoord(new Vector3(0, 0, 0));
GL.Vertex(new Vector3(x, y1, 0));
GL.Color(Color.white);
GL.TexCoord(new Vector3(1, 0, 0));
GL.Vertex(new Vector3(x + width, y1, 0));
GL.Color(Color.white);
GL.TexCoord(new Vector3(0, 1, 0));
GL.Vertex(new Vector3(x, y2, 0));
GL.Color(Color.white);
GL.TexCoord(new Vector3(1, 1, 0));
GL.Vertex(new Vector3(x + width, y2, 0));
GL.End();
}
}
}
public class MatDisplay : MonoBehaviour {
private static MatDisplay instance;
public static bool SAFE_MODE = false;
public static bool X86 = false;
private static bool started = false;
private static bool error = false;
private static byte[] convData = new byte[2048 * 2048 * 4];
private static Mat convertMat;
private static Mat flipMat = new Mat();
private static MatDrawer[] matDisplays = new MatDrawer[64];
private static MatDrawer[] texDisplays = new MatDrawer[64];
private static int texDisplayCount = 0;
private static bool awaitRender = false;
public Material material;
private Material foregroundMaterial;
private Material backgroundMaterial;
private Camera cam;
void Start () {
cam = GetComponent<Camera>();
if(cam==null)
{
cam = GameObject.FindObjectOfType<Camera>();
}
if(cam==null)
{
Debug.LogError("No camera found");
}
if(material==null)
{
material = new Material(Shader.Find("AR/MatDisplay"));
}
foregroundMaterial = new Material(material);
foregroundMaterial.renderQueue = 4005;
backgroundMaterial = new Material(material);
backgroundMaterial.renderQueue = 500;
for (int i = 0;i<matDisplays.Length;i++)
{
matDisplays[i] = new MatDrawer();
texDisplays[i] = new MatDrawer();
}
convertMat = new Mat();
Clear();
started = true;
}
public static void DisplayTexture(Texture2D texture,MatDisplaySettings properties)
{
MatDrawer uDispl = texDisplays[texDisplayCount++];
uDispl.texture = texture;
uDispl.flipY = true;
uDispl.Activate(properties);
}
public static bool isValid
{
get {
if (error)
return false;
if (instance == null)
{
instance = GameObject.FindObjectOfType<MatDisplay>();
if (instance == null)
{
Camera cam = Camera.main;
if (cam == null)
{
Debug.LogError("No camera found");
error = true;
return false;
}else
{
instance = cam.gameObject.AddComponent<MatDisplay>();
}
}
}
if (!started)
return false;
return true;
}
}
public static void SetCameraFoV(float fov = 41.5f)
{
GameObject.FindObjectOfType<Camera>().fieldOfView = fov;
}
void Update()
{
cam.clearFlags = CameraClearFlags.Depth;
if (awaitRender)
{
Clear();
}
awaitRender = true;
GameObject backgroungPlane = GameObject.Find("BackgroundPlane");
if (backgroungPlane != null)
{
backgroungPlane.SetActive(false);
}
}
internal static TextureFormat ChannelsToFormat(int channels)
{
switch (channels)
{
case 1:
return TextureFormat.RGB24;
case 3:
return TextureFormat.RGB24;
case 4:
return TextureFormat.RGBA32;
default:
throw new Exception("Invalid channel number: "+channels);
}
}
public static unsafe void DisplayImageData(IntPtr ptr, int width,int height,int channels,MatDisplaySettings properties)
{
if(width * height <= 0)
throw new Exception("[MatDisplay] invalid extends: width="+width+", height="+height);
if (!isValid)
return;
int len = width * height * channels;
TextureFormat format = ChannelsToFormat(channels);
MatDrawer uDispl = null;
//Reuse displ
foreach(MatDrawer displ in matDisplays)
{
if(!displ.active)
{
if (displ.texture != null && format == displ.texture.format && height == displ.texture.height && width == displ.texture.width)
{
uDispl = displ;
}
}
}
if (uDispl == null)
{
//Find new display
foreach (MatDrawer displ in matDisplays)
{
if (displ.texture==null)
{
uDispl = displ;
displ.texture = new Texture2D(width,height, format, false);
displ.channels = channels;
break;
}
}
}
if (uDispl == null)
{
Debug.LogError("Too many mat displays");
return;
}
//Update texture data
uDispl.flipY = false;
uDispl.texture.LoadRawTextureData(ptr, len);
uDispl.texture.Apply();
//Activate display for rendering
uDispl.Activate(properties);
}
public unsafe static void DisplayImageData(byte[] data, int width, int height, int channels, MatDisplaySettings properties)
{
int len = width * height * channels;
if (channels == 1)
{
int cI = 0;
for (int i = 0; i < len; i++)
{
byte val = data[i];
convData[cI++] = val;
convData[cI++] = val;
convData[cI++] = val;
}
data = convData;
channels = 3;
}
fixed (byte* ptr = data)
{
DisplayImageData(new IntPtr(ptr), width, height, channels, properties);
}
}
public static void DisplayMat(Mat mat, MatDisplaySettings properties)
{
if (!isValid)
return;
Mat uMat = PrepareMatData(mat);
DisplayImageData(new IntPtr(uMat.dataAddr()), uMat.width(), uMat.height(), uMat.channels(), properties);
}
public unsafe static void MatToTexture(Mat srcMat, ref Texture2D targetTexture)
{
Mat uMat = PrepareMatData(srcMat);
Core.flip(uMat,flipMat,0);
//uMat = flipMat;
TextureFormat format = ChannelsToFormat(uMat.channels());
if (targetTexture !=null && (targetTexture.width != uMat.width() || targetTexture.height != uMat.height() || targetTexture.format != format || targetTexture.mipmapCount>1))
{
Debug.LogWarning("Invalid texture given. Pass uninitialized or valid texture. Deleting and recreating texture.");
targetTexture = null;
}
if (targetTexture==null)
targetTexture = new Texture2D(srcMat.width(), srcMat.height(), format, false);
targetTexture.LoadRawTextureData(new IntPtr(flipMat.dataAddr()), uMat.width()*uMat.height()*uMat.channels());
targetTexture.Apply();
}
/*
public unsafe static void MatToTexture(Mat srcMat, Texture targetTexture)
{
if (!(targetTexture is Texture2D))
throw new Exception("Invalid texture");
Texture2D tex = (Texture2D)targetTexture;
MatToTexture(srcMat,ref tex);
}*/
private unsafe static Mat PrepareMatData(Mat mat)
{
Mat uMat = mat;
if (mat.channels() == 1)
{
Imgproc.cvtColor(mat, convertMat, Imgproc.COLOR_GRAY2RGB);
uMat = convertMat;
}
return uMat;
}
void Clear()
{
if (matDisplays != null)
{
foreach (MatDrawer matDispl in matDisplays)
{
if (matDispl != null)
matDispl.active = false;
}
}
if(texDisplays!=null)
{
foreach (MatDrawer texDisplay in texDisplays)
{
if (texDisplay != null)
{
texDisplay.texture = null;
texDisplay.active = false;
}
}
}
texDisplayCount = 0;
}
void OnPreRender()
{
if (cam == null)
return;
GL.LoadProjectionMatrix(Matrix4x4.identity);
Matrix4x4 prevModelView = GL.modelview;
GL.Viewport(new UnityEngine.Rect(0,0,Screen.width,Screen.height));
GL.modelview = Matrix4x4.identity;
foreach (MatDrawer displ in matDisplays)
{
if (displ.properties.background)
displ.Draw(backgroundMaterial);
}
for (int i = 0; i < texDisplayCount; i++)
{
if (texDisplays[i].properties.background)
texDisplays[i].Draw(backgroundMaterial);
}
GL.modelview = prevModelView;
GL.LoadProjectionMatrix(cam.projectionMatrix);
}
void OnPostRender ()
{
if (cam == null)
return;
GL.LoadProjectionMatrix(Matrix4x4.identity);
Matrix4x4 prevModelView = GL.modelview;
GL.Viewport(new UnityEngine.Rect(0, 0, Screen.width, Screen.height));
GL.modelview = Matrix4x4.identity;
foreach(MatDrawer displ in matDisplays)
{
if(!displ.properties.background)
displ.Draw(foregroundMaterial);
}
for(int i=0;i<texDisplayCount;i++)
{
if (!texDisplays[i].properties.background)
texDisplays[i].Draw(foregroundMaterial);
}
GL.modelview = prevModelView;
GL.LoadProjectionMatrix(cam.projectionMatrix);
Clear();
awaitRender = false;
}
private static float[] tmpPnt = new float[2];
public static Vector2 GetPoint2f(MatOfPoint2f matOfPoint2f, int index)
{
matOfPoint2f.get(index, 0, tmpPnt);
return new Vector2(tmpPnt[0],tmpPnt[1]);
}
public static void PutPoint2f(MatOfPoint2f target,int index, float x,float y)
{
if(index>=target.size().height)
throw new Exception("Your mat of point is not big enough. Use alloc(capacity) before setting elements.");
target.put(index, 0, x, y);
}
public static void PutPoint2f(MatOfPoint2f target, int index, Vector2 point)
{
PutPoint2f(target,index,point.x,point.y);
}
public static Mat LoadRGBATexture(string textureFilename)
{
string fn = "Assets/" + textureFilename;
Mat loadMat = Imgcodecs.imread(fn);
Mat result = new Mat();
if (loadMat.width() > 0)
{
Imgproc.cvtColor(loadMat, result, Imgproc.COLOR_BGRA2RGBA);
}
else
return null;
return result;
}
private static double[] tempDouble = new double[1];
private static float[] tempFloat = new float[1];
public static Vector3 MatColumnToVector3(Mat mat, int column)
{
Vector3 result = new Vector3();
if(mat.type() == CvType.CV_64F)
{
mat.get(0, column, tempDouble);
result.x = (float)tempDouble[0];
mat.get(1, column, tempDouble);
result.y = (float)tempDouble[0];
mat.get(2, column, tempDouble);
result.z = (float)tempDouble[0];
}
else
{
mat.get(0, column, tempFloat);
result.x = tempFloat[0];
mat.get(1, column, tempFloat);
result.y = tempFloat[0];
mat.get(2, column, tempFloat);
result.z = tempFloat[0];
}
return result;
}
}

View File

@ -0,0 +1,53 @@
Shader "AR/MatDisplay"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Transparent" }
Cull Off
ZWrite Off
ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
return col;
}
ENDCG
}
}
}

View File

@ -0,0 +1,77 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: beer_mask
m_Shader: {fileID: 4800000, guid: 2099a48cdfdf04ba0851e51953a666c1, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 9b2d50797bca94e76b70b9d726bccba5, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

View File

@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OpenCVScript : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,363 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657838, g: 0.49641234, b: 0.57481676, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 10
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringMode: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ShowResolutionOverlay: 1
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &1001315648
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1001315650}
- component: {fileID: 1001315649}
m_Layer: 0
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1001315649
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1001315648}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 31af50fb72e3b400d8ccc0fef00cbf28, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1001315650
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1001315648}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.10250124, y: 0.010528497, z: 0.07359406}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1034971291
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1034971293}
- component: {fileID: 1034971292}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &1034971292
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1034971291}
m_Enabled: 1
serializedVersion: 8
m_Type: 1
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1034971293
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1034971291}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &1846189156
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1846189161}
- component: {fileID: 1846189160}
- component: {fileID: 1846189159}
- component: {fileID: 1846189158}
- component: {fileID: 1846189157}
- component: {fileID: 1846189163}
- component: {fileID: 1846189162}
m_Layer: 0
m_Name: ARCamera
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1846189157
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1846189156}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c47f92041efbb4b429a4eafca855ebe3, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1846189158
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1846189156}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -1826476478, guid: bab6fa851cf5a1a4bba3cec5f191cb8e, type: 3}
m_Name:
m_EditorClassIdentifier:
mWorldCenterMode: 2
mWorldCenter: {fileID: 0}
--- !u!81 &1846189159
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1846189156}
m_Enabled: 1
--- !u!20 &1846189160
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1846189156}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1}
m_projectionMatrixMode: 1
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_GateFitMode: 2
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.05
far clip plane: 2000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: 1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 0
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &1846189161
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1846189156}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.0976, y: 0, z: -0.0093}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1846189162
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1846189156}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8c0d1f48f6a3d4e30a957a5d96927c46, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1846189163
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1846189156}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c7af34bc5e2f8423ab708d81040d71f5, type: 3}
m_Name:
m_EditorClassIdentifier:
material: {fileID: 0}

View File

@ -51,7 +51,7 @@ MonoBehaviour:
videoBackgroundShader: {fileID: 4800000, guid: f40623b353e2f1943b1b3ba42975db7a, videoBackgroundShader: {fileID: 4800000, guid: f40623b353e2f1943b1b3ba42975db7a,
type: 3} type: 3}
matteShader: {fileID: 4800000, guid: 66d0d78a3000021448b598bb54a3bfdf, type: 3} matteShader: {fileID: 4800000, guid: 66d0d78a3000021448b598bb54a3bfdf, type: 3}
videoBackgroundEnabled: 1 videoBackgroundEnabled: 0
deviceTracker: deviceTracker:
autoInitTracker: 0 autoInitTracker: 0
autoStartTracker: 0 autoStartTracker: 0

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<QCARConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="qcar_config.xsd"> <QCARConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="qcar_config.xsd">
<Tracking> <Tracking>
<ImageTarget name="beer" size="0.080000 0.100627" />
<ImageTarget name="terrain_controller" size="0.100000 0.099413" /> <ImageTarget name="terrain_controller" size="0.100000 0.099413" />
<ImageTarget name="terrain_base" size="0.100000 0.099738" /> <ImageTarget name="terrain_base" size="0.100000 0.099738" />
</Tracking> </Tracking>

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,5 @@
[.ShellClassInfo]
InfoTip=This folder is shared online.
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
IconIndex=16

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -0,0 +1,5 @@
[.ShellClassInfo]
InfoTip=This folder is shared online.
IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
IconIndex=16

BIN
AR-2/Assets/Textures/noise.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 KiB

868
AR-2/Assets/Tree.prefab Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using OpenCVForUnity.CoreModule;
using OpenCVForUnity.ImgprocModule;
using Vuforia;
public class VideoBGScript : MonoBehaviour
{
Mat cameraImageMat;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
MatDisplay.SetCameraFoV(41.5f);
Image cameraImage = CameraDevice.Instance.GetCameraImage(Image.PIXEL_FORMAT.RGBA8888);
if (cameraImage != null) {
if (cameraImageMat == null) {
cameraImageMat = new Mat(cameraImage.Height, cameraImage.Width, CvType.CV_8UC4);
}
cameraImageMat.put(0,0, cameraImage.Pixels);
MatDisplay.DisplayMat(cameraImageMat, MatDisplaySettings.FULL_BACKGROUND);
}
}
}

BIN
AR-2/Assets/beer_mask.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@ -8,7 +8,7 @@ Material:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: plain m_Name: plain
m_Shader: {fileID: 4800000, guid: a9e6ccf80455a4d9fb7561b1326d0ec9, type: 3} m_Shader: {fileID: 4800000, guid: 2099a48cdfdf04ba0851e51953a666c1, type: 3}
m_ShaderKeywords: m_ShaderKeywords:
m_LightmapFlags: 4 m_LightmapFlags: 4
m_EnableInstancingVariants: 0 m_EnableInstancingVariants: 0

View File

@ -106,6 +106,11 @@ PlayerSettings:
xboxOneDisableEsram: 0 xboxOneDisableEsram: 0
xboxOnePresentImmediateThreshold: 0 xboxOnePresentImmediateThreshold: 0
switchQueueCommandMemory: 0 switchQueueCommandMemory: 0
switchQueueControlMemory: 16384
switchQueueComputeMemory: 262144
switchNVNShaderPoolsGranularity: 33554432
switchNVNDefaultPoolsGranularity: 16777216
switchNVNOtherPoolsGranularity: 16777216
vulkanEnableSetSRGBWrite: 0 vulkanEnableSetSRGBWrite: 0
m_SupportedAspectRatios: m_SupportedAspectRatios:
4:3: 1 4:3: 1
@ -422,6 +427,7 @@ PlayerSettings:
switchAllowsRuntimeAddOnContentInstall: 0 switchAllowsRuntimeAddOnContentInstall: 0
switchDataLossConfirmation: 0 switchDataLossConfirmation: 0
switchUserAccountLockEnabled: 0 switchUserAccountLockEnabled: 0
switchSystemResourceMemory: 16777216
switchSupportedNpadStyles: 3 switchSupportedNpadStyles: 3
switchNativeFsCacheSize: 32 switchNativeFsCacheSize: 32
switchIsHoldTypeHorizontal: 0 switchIsHoldTypeHorizontal: 0
@ -528,7 +534,7 @@ PlayerSettings:
il2cppCompilerConfiguration: {} il2cppCompilerConfiguration: {}
managedStrippingLevel: {} managedStrippingLevel: {}
incrementalIl2cppBuild: {} incrementalIl2cppBuild: {}
allowUnsafeCode: 0 allowUnsafeCode: 1
additionalIl2CppArgs: additionalIl2CppArgs:
scriptingRuntimeVersion: 1 scriptingRuntimeVersion: 1
apiCompatibilityLevelPerPlatform: {} apiCompatibilityLevelPerPlatform: {}