├── .github
└── ISSUE_TEMPLATE
│ ├── -----.md
│ └── --.md
├── .gitignore
├── ColorMapping
└── Scripts
│ ├── core
│ ├── ARFoundationColorMapping.cs
│ ├── AirarManager.cs
│ ├── EasyARColorMapping.cs
│ ├── MaxstARColorMapping.cs
│ └── VuforiaColorMapping.cs
│ └── helper
│ ├── AirarSingleton.cs
│ ├── FilePathUtil.cs
│ └── ScreenShot.cs
├── LICENSE
├── Plugins
├── Android
│ ├── libAirarColorMap.so
│ └── libopencv_java3.so
└── iOS
│ └── libAirarColorMap.a
├── README.md
└── Sample
├── ColorMappingWithARFoundationSample.unitypackage
├── ColorMappingWithEasyARSample.unitypackage
├── ColorMappingWithMaxstARSample.unitypackage
└── ColorMappingWithVuforiaSample.unitypackage
/.github/ISSUE_TEMPLATE/-----.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 버그리포트
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/--.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 버그
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | ColorMapping.meta
3 | ColorMapping/Scenes.meta
4 | ColorMapping/Scenes/ColorMapping.unity.meta
5 | ColorMapping/Scripts.meta
6 | ColorMapping/Scripts/CallNativeCode.cs.meta
7 | Plugins.meta
8 | Plugins/Android.meta
9 | Plugins/Android/libopencv_java3.so.meta
10 | Plugins/Android/libOpenCVBridge.so.meta
11 | README.md.meta
12 | *.meta
13 |
--------------------------------------------------------------------------------
/ColorMapping/Scripts/core/ARFoundationColorMapping.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 | #if USE_ARFOUNDATION
6 | using UnityEngine.XR.ARFoundation;
7 | using UnityEngine.XR.ARSubsystems;
8 | #endif
9 |
10 | public class ARFoundationColorMapping : MonoBehaviour
11 | {
12 | #if USE_ARFOUNDATION
13 | public ARTrackedImageManager imageManager;
14 | #endif
15 |
16 | public GameObject arPrefabs;
17 |
18 | public int realWidth;
19 | public int realHeight;
20 |
21 | private GameObject arContents;
22 | private GameObject drawObj;
23 |
24 | private GameObject cube;
25 |
26 | #if USE_ARFOUNDATION
27 | void Start()
28 | {
29 | imageManager.trackedImagesChanged += OnTrackedImagesChanged;
30 | }
31 |
32 | private void OnTrackedImagesChanged(ARTrackedImagesChangedEventArgs eventArgs)
33 | {
34 | ARTrackedImage trackedImage = null;
35 |
36 | for (int i = 0; i < eventArgs.added.Count; i++)
37 | {
38 | trackedImage = eventArgs.added[i];
39 | string imgName = trackedImage.referenceImage.name;
40 |
41 | if(imgName == "sw-12")
42 | {
43 | arContents = Instantiate(arPrefabs, trackedImage.transform);
44 | cube = CreateCubeForARFoundationTarget(this.gameObject, trackedImage.size.x, trackedImage.size.y, trackedImage.transform);
45 | }
46 | }
47 |
48 | for (int i = 0; i < eventArgs.updated.Count; i++)
49 | {
50 | trackedImage = eventArgs.updated[i];
51 |
52 | if (trackedImage.trackingState == TrackingState.Tracking)
53 | {
54 | arContents.SetActive(true);
55 | }
56 | else
57 | {
58 | arContents.SetActive(false);
59 | }
60 | }
61 |
62 | for (int i = 0; i < eventArgs.removed.Count; i++)
63 | {
64 | arContents.SetActive(false);
65 | }
66 | }
67 | #endif
68 |
69 | public void Play()
70 | {
71 | float[] srcValue = AirarManager.Instance.CalculateMarkerImageVertex(cube);
72 |
73 | Texture2D screenShotTex = ScreenShot.GetScreenShot(arContents);
74 |
75 | AirarManager.Instance.ProcessColoredMapTexture(screenShotTex, srcValue, realHeight, realWidth, (resultTex) =>
76 | {
77 | drawObj = GameObject.FindGameObjectWithTag("coloring");
78 | drawObj.GetComponent().material.mainTexture = resultTex;
79 | });
80 | }
81 |
82 | ///
83 | /// Create a full size cube on the ARFoundation marker image
84 | ///
85 | /// marker image width
86 | /// marker image height
87 | public GameObject CreateCubeForARFoundationTarget(GameObject parentObj, float targetWidth, float targetHeight, Transform trans)
88 | {
89 | GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
90 | cube.GetComponent().material = AirarManager.Instance.transparentMat;
91 | cube.transform.SetParent(trans);
92 | cube.transform.localPosition = trans.localPosition;
93 | cube.transform.localScale = new Vector3(targetWidth, 0.001f, targetHeight);
94 |
95 | return cube;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/ColorMapping/Scripts/core/AirarManager.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 | using System.Runtime.InteropServices;
5 | using System.IO;
6 | using UnityEngine.Networking;
7 | using System;
8 |
9 | public class AirarManager : AirarSingleton
10 | {
11 | public Material transparentMat;
12 |
13 | #if UNITY_ANDROID
14 | [DllImport("AirarColorMap")]
15 | #elif UNITY_IOS
16 | [DllImport("__Internal")]
17 | #endif
18 |
19 | private static extern void ImageProc(string imgPath, float[] src, int height, int width);
20 |
21 | ///
22 | ///
23 | ///
24 | /// screenshot
25 | /// float[8]
26 | /// target 3d model map height size
27 | /// target 3d model map width size
28 | public void ProcessColoredMapTexture(Texture2D srcTexture ,float[] src,int height, int width,Action callback)
29 | {
30 |
31 | Texture2D dstTexture = new Texture2D(width, height);
32 |
33 | //string imgPath = FilePathUtil.GetImageSavePath("airar.jpg");
34 | string imgPath = Path.Combine(Application.persistentDataPath, "airar.jpg");
35 | File.WriteAllBytes(imgPath, srcTexture.EncodeToJPG());
36 | unsafe
37 | {
38 | ImageProc(imgPath, src, height, width);
39 | }
40 |
41 | if (File.Exists(imgPath))
42 | {
43 | StartCoroutine(LoadTexture(imgPath,(www)=>
44 | {
45 | callback(DownloadHandlerTexture.GetContent(www));
46 | }));
47 | }
48 | }
49 |
50 | IEnumerator LoadTexture(string path, Action callback)
51 | {
52 |
53 | UnityWebRequest www = UnityWebRequestTexture.GetTexture("file://" + path);
54 | yield return www.SendWebRequest();
55 |
56 | if (!www.isNetworkError)
57 | {
58 | callback(www);
59 | }
60 | }
61 |
62 | ///
63 | /// Marker image vertex coordinate calculation
64 | ///
65 | /// cube object on marker image
66 | public float[] CalculateMarkerImageVertex(GameObject cube)
67 | {
68 | List vertexList = new List();
69 |
70 | Vector3[] vertices = cube.GetComponent().mesh.vertices;
71 | Vector2[] result = new Vector2[vertices.Length];
72 | for (int i = 0; i < vertices.Length; ++i)
73 | {
74 | result[i] = Camera.main.WorldToScreenPoint(cube.transform.TransformPoint(vertices[i]));
75 | vertexList.Add(result[i]);
76 | }
77 |
78 | // Actual Device Size
79 | int screenHeight = Screen.height;
80 |
81 | // Use mesh bottom vertices
82 | // 14(LU), 13(RU), 12(RD), 15(LD)
83 | Vector2 LU = new Vector2();
84 | Vector2 RU = new Vector2();
85 | Vector2 RD = new Vector2();
86 | Vector2 LD = new Vector2();
87 | for (int i = 0; i < vertexList.Count; i++)
88 | {
89 | if (i >= 12 && i <= 15)
90 | {
91 | LU = vertexList[14];
92 | RU = vertexList[13];
93 | RD = vertexList[12];
94 | LD = vertexList[15];
95 | }
96 | }
97 |
98 | float[] srcPosition = new float[8];
99 | srcPosition[0] = LU.x;
100 | srcPosition[1] = screenHeight - LU.y;
101 |
102 | srcPosition[2] = RU.x;
103 | srcPosition[3] = screenHeight - RU.y;
104 |
105 | srcPosition[4] = RD.x;
106 | srcPosition[5] = screenHeight - RD.y;
107 |
108 | srcPosition[6] = LD.x;
109 | srcPosition[7] = screenHeight - LD.y;
110 |
111 | return srcPosition;
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/ColorMapping/Scripts/core/EasyARColorMapping.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 | #if USE_EASYAR
6 | using easyar;
7 | #endif
8 |
9 | public class EasyARColorMapping : MonoBehaviour
10 | {
11 | #if USE_EASYAR
12 | public ImageTargetController imageTargetController;
13 | #endif
14 |
15 | public GameObject arContents;
16 |
17 | public int realWidth;
18 | public int realHeight;
19 |
20 | private GameObject drawObj;
21 | private GameObject cube;
22 |
23 | void Start()
24 | {
25 | #if USE_EASYAR
26 | imageTargetController.TargetLoad += (loadedTarget, result) =>
27 | {
28 | easyar.Image targetImage = ((loadedTarget as ImageTarget).images())[0];
29 | float targetWidth = (float)targetImage.width();
30 | float targetHeight = (float)targetImage.height();
31 | float targetScale = (targetHeight / targetWidth);
32 |
33 | cube = CreateCubeForEasyARTarget(this.gameObject, targetScale);
34 | };
35 | #endif
36 | }
37 |
38 | public void Play()
39 | {
40 | float[] srcValue = AirarManager.Instance.CalculateMarkerImageVertex(cube);
41 |
42 | Texture2D screenShotTex = ScreenShot.GetScreenShot(arContents);
43 |
44 | AirarManager.Instance.ProcessColoredMapTexture(screenShotTex, srcValue, realHeight, realWidth, (resultTex) =>
45 | {
46 | drawObj = GameObject.FindGameObjectWithTag("coloring");
47 | drawObj.GetComponent().material.mainTexture = resultTex;
48 | });
49 | }
50 |
51 | ///
52 | /// Create a full size cube on the EasyAR marker image
53 | ///
54 | /// EasyAR marker image scale
55 | public GameObject CreateCubeForEasyARTarget(GameObject parentObj, float targetScale)
56 | {
57 | GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
58 | cube.GetComponent().material = AirarManager.Instance.transparentMat;
59 | cube.transform.SetParent(parentObj.transform);
60 | cube.transform.localPosition = new Vector3(0f, 0f, -0.005f);
61 | cube.transform.localRotation = Quaternion.Euler(new Vector3(-90f, 0f, 0f));
62 | cube.transform.localScale = new Vector3(1f, 0.01f, targetScale);
63 |
64 | return cube;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/ColorMapping/Scripts/core/MaxstARColorMapping.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 | #if USE_MAXSTAR
6 | using maxstAR;
7 | #endif
8 |
9 | public class MaxstARColorMapping : MonoBehaviour
10 | {
11 | #if USE_MAXSTAR
12 | public ImageTrackableBehaviour trackableBehaviour;
13 | #endif
14 |
15 | public GameObject arContents;
16 |
17 | public int realWidth;
18 | public int realHeight;
19 |
20 | private GameObject drawObj;
21 | private GameObject cube;
22 |
23 | void Start()
24 | {
25 | #if USE_MAXSTAR
26 | float targetWidth = trackableBehaviour.TargetWidth;
27 | float targetHeight = trackableBehaviour.TargetHeight;
28 |
29 | cube = CreateCubeForMaxstARTarget(this.gameObject, targetWidth, targetHeight);
30 | #endif
31 | }
32 |
33 | public void Play()
34 | {
35 | float[] srcValue = AirarManager.Instance.CalculateMarkerImageVertex(cube);
36 |
37 | Texture2D screenShotTex = ScreenShot.GetScreenShot(arContents);
38 |
39 | AirarManager.Instance.ProcessColoredMapTexture(screenShotTex, srcValue, realHeight, realWidth, (resultTex) =>
40 | {
41 | drawObj = GameObject.FindGameObjectWithTag("coloring");
42 | drawObj.GetComponent().material.mainTexture = resultTex;
43 | });
44 | }
45 |
46 | ///
47 | /// Create a full size cube on the MaxstAR marker image
48 | ///
49 | /// marker image width
50 | /// marker image height
51 | public GameObject CreateCubeForMaxstARTarget(GameObject parentObj, float targetWidth, float targetHeight)
52 | {
53 | GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
54 | cube.GetComponent().material = AirarManager.Instance.transparentMat;
55 | cube.transform.SetParent(parentObj.transform);
56 | cube.transform.localPosition = Vector3.zero;
57 | cube.transform.localScale = new Vector3(targetWidth, 0.001f, targetHeight);
58 |
59 | return cube;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/ColorMapping/Scripts/core/VuforiaColorMapping.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 | #if USE_VUFORIA
6 | using Vuforia;
7 | #endif
8 |
9 | public class VuforiaColorMapping : MonoBehaviour
10 | {
11 | #if USE_VUFORIA
12 | public ImageTargetBehaviour imageTaget;
13 | #endif
14 |
15 | public GameObject arContents;
16 |
17 | public int realWidth;
18 | public int realHeight;
19 |
20 | private GameObject drawObj;
21 | private GameObject cube;
22 |
23 | void Start()
24 | {
25 | #if USE_VUFORIA
26 | Vector2 imageTargetSize = imageTaget.GetSize();
27 | float targetWidth = imageTargetSize.x;
28 | float targetHeight = imageTargetSize.y;
29 |
30 | cube = CreateCubeForVuforiaTarget(this.gameObject, targetWidth, targetHeight);
31 | #endif
32 | }
33 |
34 | public void Play()
35 | {
36 | float[] srcValue = AirarManager.Instance.CalculateMarkerImageVertex(cube);
37 |
38 | Texture2D screenShotTex = ScreenShot.GetScreenShot(arContents);
39 |
40 | AirarManager.Instance.ProcessColoredMapTexture(screenShotTex, srcValue, realHeight, realWidth, (resultTex) =>
41 | {
42 | drawObj = GameObject.FindGameObjectWithTag("coloring");
43 | drawObj.GetComponent().material.mainTexture = resultTex;
44 | });
45 | }
46 |
47 | ///
48 | /// Create a full size cube on the Vuforia marker image
49 | ///
50 | /// marker image width
51 | /// marker image height
52 | public GameObject CreateCubeForVuforiaTarget(GameObject parentObj, float targetWidth, float targetHeight)
53 | {
54 | GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
55 | cube.GetComponent().material = AirarManager.Instance.transparentMat;
56 | cube.transform.SetParent(parentObj.transform);
57 | cube.transform.localPosition = Vector3.zero;
58 | cube.transform.localScale = new Vector3(targetWidth, 0.001f, targetHeight);
59 |
60 | return cube;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/ColorMapping/Scripts/helper/AirarSingleton.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using UnityEngine;
3 |
4 | public abstract class AirarSingleton : MonoBehaviour where T : MonoBehaviour
5 | {
6 | private static T instance;
7 |
8 | public static T Instance
9 | {
10 | get
11 | {
12 | if(instance == null)
13 | {
14 | instance = FindObjectOfType();
15 | }
16 |
17 | return instance;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ColorMapping/Scripts/helper/FilePathUtil.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using UnityEngine;
3 |
4 | //Helps create file paths
5 | public static class FilePathUtil
6 | {
7 | private static string FOLDER_NAME = "AIR_AR";
8 | private static string FILE_NAME = "temp.jpg";
9 |
10 | // Get Android Internal Path
11 | public static string GetAndroidInternalFilesDir()
12 | {
13 | string[] potentialDirectories = new string[]
14 | {
15 | "/mnt/sdcard",
16 | "/sdcard",
17 | "/storage/sdcard0",
18 | "/storage/sdcard1"
19 | };
20 |
21 | if (Application.platform == RuntimePlatform.Android)
22 | {
23 | for (int i = 0; i < potentialDirectories.Length; i++)
24 | {
25 | if (Directory.Exists(potentialDirectories[i]))
26 | {
27 | return potentialDirectories[i];
28 | }
29 | }
30 | }
31 | return "";
32 | }
33 |
34 | // Create File Save Path
35 | public static string GetImageSavePath(string fileName)
36 | {
37 | string strPath;
38 |
39 | #if UNITY_ANDROID && !UNITY_EDITOR
40 | string dirPath = Path.Combine(GetAndroidInternalFilesDir(), FOLDER_NAME);
41 | if (!System.IO.Directory.Exists(dirPath))
42 | {
43 | System.IO.Directory.CreateDirectory(dirPath);
44 | }
45 |
46 | strPath = Path.Combine(dirPath, fileName);
47 |
48 | #elif UNITY_IOS && !UNITY_EDITOR
49 | strPath = Path.Combine(Application.persistentDataPath, fileName);
50 | #else
51 | strPath = Path.Combine(Application.persistentDataPath, fileName);
52 | #endif
53 | return strPath;
54 | }
55 | }
--------------------------------------------------------------------------------
/ColorMapping/Scripts/helper/ScreenShot.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using UnityEditor;
5 | using UnityEngine;
6 |
7 | //Help to ScreenShot
8 | public static class ScreenShot
9 | {
10 | private static string TEMP_FILE_NAME = "colorMappingTempImg.jpg";
11 |
12 | private static Rect rect;
13 | private static RenderTexture renderTexture;
14 | private static Texture2D screenShot;
15 |
16 | public static Texture2D GetScreenShot(GameObject arContents)
17 | {
18 | arContents.SetActive(false);
19 |
20 | if (renderTexture == null)
21 | {
22 | int sceenWidth = Screen.width;
23 | int sceenHeight = Screen.height;
24 |
25 | rect = new Rect(0, 0, sceenWidth, sceenHeight);
26 | renderTexture = new RenderTexture(sceenWidth, sceenHeight, 24);
27 | screenShot = new Texture2D(sceenWidth, sceenHeight, TextureFormat.RGB24, false);
28 | }
29 |
30 | Camera camera = Camera.main;
31 | camera.targetTexture = renderTexture;
32 | camera.Render();
33 |
34 | RenderTexture.active = renderTexture;
35 | screenShot.ReadPixels(rect, 0, 0);
36 | screenShot.Apply();
37 |
38 | camera.targetTexture = null;
39 | RenderTexture.active = null;
40 |
41 | Texture2D tex = screenShot;
42 |
43 | byte[] texture_bytes = tex.EncodeToJPG();
44 |
45 | string filePath = Path.Combine(Application.persistentDataPath, TEMP_FILE_NAME);
46 | File.WriteAllBytes(filePath, texture_bytes);
47 |
48 | renderTexture = null;
49 | screenShot = null;
50 |
51 | arContents.SetActive(true);
52 |
53 | return tex;
54 | }
55 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2020, AIRAR Company
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | 1. Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | 2. Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | 3. Neither the name of the copyright holder nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/Plugins/Android/libAirarColorMap.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/airar-dev/Unity-AR-ColorMapping/ec129a80478917f312b8d4ebdf654321daae0409/Plugins/Android/libAirarColorMap.so
--------------------------------------------------------------------------------
/Plugins/Android/libopencv_java3.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/airar-dev/Unity-AR-ColorMapping/ec129a80478917f312b8d4ebdf654321daae0409/Plugins/Android/libopencv_java3.so
--------------------------------------------------------------------------------
/Plugins/iOS/libAirarColorMap.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/airar-dev/Unity-AR-ColorMapping/ec129a80478917f312b8d4ebdf654321daae0409/Plugins/iOS/libAirarColorMap.a
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
AR ColorMapping
9 |
10 |
11 |
12 | [](https://github.com/airar-dev/Unity-AR-ColorMapping/releases/)
13 | [](https://github.com/airar-dev/Unity-AR-ColorMapping/search?l=c%23)
14 | [](https://opensource.org/licenses/BSD-3-Clause)
15 | [](https://github.com/airar-dev/Unity-AR-ColorMapping/watchers)
16 | [](https://github.com/airar-dev/Unity-AR-ColorMapping/stargazers)
17 | [](https://github.com/airar-dev/Unity-AR-ColorMapping/network/members)
18 | [](https://unity.com/)
19 | [](https://visualstudio.microsoft.com/)
20 | [](https://opencv.org/releases/)
21 | [](https://opencv.org/releases/)
22 |
23 |
24 |
25 |
26 | This project is an easy-to-apply AR Coloring Library for Unity.
27 | This project can be applied to AR Engines of MaxstAR, EasyAR, Vuforia, ARFoundation(ARkit, ARcore).
28 | To use it for business projects, you need to purchase a separate license for the AR Engine.
29 | View Demo
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | ## Table of Contents
44 |
45 | * [Requirements](#requirements)
46 | * [Installation](#installation)
47 | * [Quick Start](#quick-start)
48 | * [with MaxstAR](#with-maxstar)
49 | * [with EasyAR](#with-easyar)
50 | * [with Vuforia](#with-vuforia)
51 | * [with ARFoundation(ARkit, ARcore)](#with-arfoundationarkit-arcore)
52 | * [Release](#release)
53 | * [Future Release](#Future-release)
54 | * [Trouble Shooting](#Trouble-shooting)
55 | * [Known Issues](#known-issues)
56 | * [Contributing](#contributing)
57 | * [License](#license)
58 | * [Contact](#contact)
59 |
60 |
61 |
62 |
63 | ## Requirements
64 |
65 | * Unity3D 2019.3.14f1
66 | * MaxstAR 5.0.2v
67 | * EasyAR 3.1.0v
68 | * Vuforia Engine AR Unity Package 9.5.4v
69 | * ARFoundation 2.1.8v
70 | * Visual Studio 2019
71 | * opencv-3.4.10-android-sdk
72 | * opencv.framework(*3.4.11 version)
73 | The opencv library can be downloaded from the official website.
Download the opencv from this link (https://opencv.org/releases/).
74 |
75 | **\* As of August 3, 2021, the latest version of Unity3D and the latest version of each AR engine have been tested.**
76 | * Unity3D 2021.1.6f1
77 | * MaxstAR 5.0.5v
78 | * EasyAR 4.3.0v
79 | * Vuforia Engine AR Unity Package 10.0v
80 | * ARFoundation 4.1.7v
81 |
82 | **\* As of July 21, 2023, the latest version of Unity3D and the latest version of each AR engine have been tested.**
83 | * Unity3D 2022.3.4f1
84 | * MaxstAR 6.0.1v
85 | * EasyAR 4.6.2v
86 | * Vuforia Engine AR Unity Package 10.16.3v
87 | * ARFoundation 5.0.6v
88 |
89 | **\* As of July 29, 2024, the latest version of Unity3D and the latest version of ARFoundation have been tested.**
90 | * Unity3D 2023.2.0f1
91 | * ARFoundation 5.1.5v
92 |
93 | **\* As of July 30, 2024, the latest version of Unity3D and the latest version of Vuforia have been tested.**
94 | * Unity3D 2023.2.0f1
95 | * Vuforia 10.25.4v
96 |
97 | **\* As of Aug 9, 2024, multi-tracking supported ARFoundation samples have been updated.**
98 | * Unity3D 2023.2.0f1
99 | * ARFoundation 5.1.5v
100 |
101 |
102 |
103 |
104 | ## Installation
105 | 1. Clone a repository or download it as zip.
106 | ```
107 | git clone https://github.com/airar-dev/ColorMapping.git
108 | ```
109 | 2. Importing the AR Engine SDK to be used together.
110 | (You can use MaxstAR, EasyAR, Vuforia, ARFoundation(ARkit, ARcore))
111 |
112 |
113 |
114 | ## 3D Guide
115 | https://youtu.be/2-h8aBLddjY
116 |
117 |
118 | ## Quick Start
119 |
120 | ### with MaxstAR
121 |
122 | **Create Android App Project Demo(https://youtu.be/JhixOsRKQ5k)**
123 | **Create iOS App Project Demo(https://youtu.be/h3YQMaf7R-E)**
124 |
125 | **1. Create Project**
126 | - Create an empty Unity3D project.
127 |
128 | **2. Import [MaxstAR](https://developer.maxst.com/MD/downloadsdk)**
129 | - Import MaxstAR SDK(5.0.2v +).
130 |
131 | **3. Import Sample Package**
132 | - After extracting the downloaded file,
133 | import ColorMappingWithMaxstARSample.unitypackage from
134 | ColorMapping-master -> Sample folder.
135 |
136 | **4. Import Native Library**
137 | - Import ‘libAirarColorMap.so, libopencv_java3.so’ file for Android.
138 | (Set the CPU to ARM64 in the platform settings of the libAirarColorMap.so, libopencv_java3.so files.)
139 | - Import ‘libAirarColorMap.a, opencv2.framework’ file for iOS.
140 |
141 | **5. Player Settings for Android**
142 |
143 | Allow 'unsafe' code | Check the Allow 'unsafe' code |
144 | Scripting Backend | Select IL2CPP |
145 | Target Architectures | Check Arm64 architecture(uncheck ARM7) |
146 | Scripting Define Symbols | Add ‘USE_MAXSTAR’ into Scripting Define Symbols |
147 |
148 |
149 |
150 | **6. Player Settings for iOS**
151 |
152 | Allow 'unsafe' code | Check the Allow 'unsafe' code |
153 | Scripting Backend | Select IL2CPP |
154 | Target Architectures | Check Arm64 architecture(uncheck ARM7) |
155 | Scripting Define Symbols | Add ‘USE_MAXSTAR’ into Scripting Define Symbols |
156 |
157 |
158 |
159 | **7. Setting for 3D Contents**
160 |
161 | ‘coloring’ tag | Set ‘coloring’ tag for Object containing the material to which the colored texture is applied |
162 |
163 |
164 |
165 | **8. MaxstARColorMapping.cs**
166 | ![masxtar-1]
167 |
168 | trackableBehaviour | MaxstAR ImageTrackableBehaviour |
169 | ARContents | 3D object to augment |
170 | RealWidth | Actual horizontal size of the marker image |
171 | RealHeight | Actual vertical size of the marker image |
172 |
173 |
174 |
175 | **9. Build**
176 | - Build by selecting the MaxstARSample scene under ColorMapping -> Scenes.
177 |
178 |
179 | ### with EasyAR
180 |
181 | **Create Android App Project Demo(https://youtu.be/elk7-E3LDYc)**
182 | **Create iOS App Project Demo(https://youtu.be/bcKe0nKg5fg)**
183 |
184 | **1. Create Project**
185 | - Create an empty Unity3D project.
186 |
187 | **2. Initialize [EasyAR](https://www.easyar.com/view/download.html)**
188 | - EasyAR 3.1.0 Version + required.
189 | - For EasyAR to work, a license key is required.
190 |
191 | **3. Import Sample Package**
192 | - After extracting the downloaded file,
193 | import ColorMappingWithEasyARSample.unitypackage from
194 | ColorMapping-master -> Sample folder.
195 |
196 | **4. Import Native Library**
197 | - Import ‘libAirarColorMap.so, libopencv_java3.so’ file for Android.
198 | (Set the CPU to ARM64 in the platform settings of the libAirarColorMap.so, libopencv_java3.so files.)
199 | - Import ‘libAirarColorMap.a, opencv2.framework’ file for iOS.
200 |
201 | **5. Player Settings for Android**
202 |
203 | Allow 'unsafe' code | Check the Allow 'unsafe' code |
204 | Graphics APIs | Remove Vulkan from the Graphic API list |
205 | Scripting Backend | Select IL2CPP |
206 | Target Architectures | Check Arm64 architecture(uncheck ARM7) |
207 | Scripting Define Symbols | Add 'USE_EASYAR' into Scripting Define Symbols |
208 |
209 |
210 |
211 | **6. Player Settings for iOS**
212 |
213 | Allow 'unsafe' code | Check the Allow 'unsafe' code |
214 | Graphics APIs | Remove Metal from the Graphic API list |
215 | Scripting Backend | Select IL2CPP |
216 | Architecture | Check Arm64 architecture(uncheck ARM7) |
217 | Scripting Define Symbols | Add 'USE_EASYAR' into Scripting Define Symbols |
218 |
219 |
220 |
221 | **7. Setting for 3D Contents**
222 |
223 | ‘coloring’ tag | Set ‘coloring’ tag for Object containing the material to which the colored texture is applied |
224 |
225 |
226 |
227 | **8. EasyARColorMapping.cs**
228 | ![easyar-1]
229 |
230 | ImageTargetController | EasyAR ImageTargetController |
231 | ARContents | 3D object to augment |
232 | RealWidth | Actual horizontal size of the marker image |
233 | RealHeight | Actual vertical size of the marker image |
234 |
235 |
236 |
237 | **9. Build**
238 | - Build by selecting the EasyARSample scene under ColorMapping -> Scenes.
239 |
240 |
241 | ### with Vuforia
242 |
243 | **Create Android App Project Demo(https://youtu.be/b5zSwDiwE4Q)**
244 | **Create iOS App Project Demo(https://youtu.be/s1TcKE2PzXk)**
245 |
246 | **1. Create Project**
247 | - Create an empty Unity3D project.
248 |
249 | **2. Import Vuforia Unity Package**
250 | - Importing the Vuforia Engine AR Unity Package(9.5.4v +) and Vuforia Sample Package.
251 |
252 | **3. Import Sample Package**
253 | - After extracting the downloaded file,
254 | import ColorMappingWithVuforiaSample.unitypackage from
255 | ColorMapping-master -> Sample folder.
256 |
257 | **4. Import Native Library**
258 | - Import ‘libAirarColorMap.so, libopencv_java3.so’ file for Android.
259 | (Set the CPU to ARM64 in the platform settings of the libAirarColorMap.so, libopencv_java3.so files.)
260 | - Import ‘libAirarColorMap.a, opencv2.framework’ file for iOS.
261 |
262 | **5. Player Settings for Android**
263 |
264 | Allow 'unsafe' code | Check the Allow 'unsafe' code |
265 | Scripting Backend | Select IL2CPP |
266 | Target Architectures | Check Arm64 architecture(uncheck ARM7) |
267 | Scripting Define Symbols | Add 'USE_VUFORIA' into Scripting Define Symbols |
268 |
269 |
270 |
271 | **6. Player Settings for iOS**
272 |
273 | Allow 'unsafe' code | Check the Allow 'unsafe' code |
274 | Scripting Backend | Select IL2CPP |
275 | Target Architectures | Check Arm64 architecture(uncheck ARM7) |
276 | Scripting Define Symbols | Add 'USE_VUFORIA' into Scripting Define Symbols |
277 |
278 |
279 |
280 | **7. Setting for 3D Contents**
281 |
282 | ‘coloring’ tag | Set ‘coloring’ tag for Object containing the material to which the colored texture is applied |
283 |
284 |
285 |
286 | **8. VuforiaColorMapping.cs**
287 | ![vuforia-1]
288 |
289 | ImageTaget | Vuforia ImageTargetBehaviour |
290 | ARContents | 3D object to augment |
291 | RealWidth | Actual horizontal size of the marker image |
292 | RealHeight | Actual vertical size of the marker image |
293 |
294 |
295 |
296 | **9. Build**
297 | - Build by selecting the VuforiaSample scene under ColorMapping -> Scenes.
298 |
299 |
300 | ### with ARFoundation(ARkit, ARcore)
301 |
302 | **Create Android App Project Demo(https://youtu.be/nR0D5B6s6dA)**
303 | **Create iOS App Project Demo(https://youtu.be/lzDVS_dOwV4)**
304 |
305 | **1. Create Project**
306 | - Create an empty Unity3D project.
307 |
308 | **2. Import ARFoundation Unity Package**
309 | - Importing the ARFoundation(2.1.8v +),
310 | ARCore(for Android)(2.1.11v +), ARKit(for iOS)(2.1.9v +) Unity Package.
311 |
312 | **3. Import Sample Package**
313 | - After extracting the downloaded file,
314 | import ColorMappingWithARFoundationSample.unitypackage from
315 | ColorMapping-master -> Sample folder.
316 |
317 | **4. Import Native Library**
318 | - Import ‘libAirarColorMap.so, libopencv_java3.so’ file for Android.
319 | (Set the CPU to ARM64 in the platform settings of the libAirarColorMap.so, libopencv_java3.so files.)
320 | - Import ‘libAirarColorMap.a, opencv2.framework’ file for iOS.
321 |
322 | **5. Player Settings for Android**
323 |
324 | Allow 'unsafe' code | Check the Allow 'unsafe' code |
325 | Scripting Backend | Select IL2CPP |
326 | Target Architectures | Check Arm64 architecture(uncheck ARM7) |
327 | Scripting Define Symbols | Add 'USE_ARFOUNDATION' into Scripting Define Symbols |
328 | Minimum API Level | Android 7.0(API Level 24)+ |
329 |
330 |
331 |
332 | **6. Player Settings for iOS**
333 |
334 | Allow 'unsafe' code | Check the Allow 'unsafe' code |
335 | Scripting Backend | Select IL2CPP |
336 | Architecture | Check Arm64 architecture(uncheck ARM7) |
337 | Scripting Define Symbols | Add 'USE_ARFOUNDATION' into Scripting Define Symbols |
338 | Target minimum iOS Version | 11.0+ |
339 |
340 |
341 |
342 | **7. Setting for 3D Contents**
343 |
344 | ‘coloring’ tag | Set ‘coloring’ tag for Object containing the material to which the colored texture is applied |
345 |
346 |
347 |
348 | **8. ARFoundationColorMapping.cs**
349 | ![arfoundation-1]
350 |
351 | ImageManager | ARTrackedImageManager |
352 | ARContents | 3D object to augment |
353 | RealWidth | Actual horizontal size of the marker image |
354 | RealHeight | Actual vertical size of the marker image |
355 |
356 |
357 |
358 | **7. Build**
359 | - Build by selecting the ARFoundationSample scene under ColorMapping -> Scenes.
360 |
361 |
362 | ## Release
363 | | Version | New Features | Date |
364 | |:---:|---|:---:|
365 | | v1.3.7 | [multi-tracking supported ARFoundation samples have been updated.](https://github.com/airar-dev/Unity-AR-ColorMapping/releases/tag/1.3.7) | 2024.08.09 |
366 | | v1.3.6 | [the latest version of Unity3D and the latest version of Vuforia have been tested.](https://github.com/airar-dev/Unity-AR-ColorMapping/releases/tag/1.3.6) | 2024.07.30 |
367 | | v1.3.5 | [the latest version of Unity3D and the latest version of ARFoundation have been tested.](https://github.com/airar-dev/Unity-AR-ColorMapping/releases/tag/1.3.5) | 2024.07.29 |
368 | | v1.3.4 | [the latest version of Unity3D and the latest version of each AR engine have been tested.](https://github.com/airar-dev/Unity-AR-ColorMapping/releases/tag/1.3.4) | 2023.07.21 |
369 | | v1.3.3 | [Upload samples compatible with the latest version of Vuforia](https://github.com/airar-dev/Unity-AR-ColorMapping/releases/tag/1.3.3) | 2023.05.31 |
370 | | v1.3.2 | [Upload samples compatible with the latest version of Vuforia](https://github.com/airar-dev/Unity-AR-ColorMapping/releases/tag/1.3.2) | 2022.11.30 |
371 | | v1.3.1 | [the latest version of Unity3D and the latest version of each AR engine have been tested.](https://github.com/airar-dev/Unity-AR-ColorMapping/releases/tag/1.3.1) | 2021.08.03 |
372 | | v1.3.0 | [update all sample for Android/iOS](https://github.com/airar-dev/Unity-AR-ColorMapping/releases/tag/1.3.0) | 2020.10.27 |
373 | | v1.2.1 | [modify sample unitypackages for android](https://github.com/airar-dev/Unity-AR-ColorMapping/releases/tag/1.2.1) | 2020.10.23 |
374 | | v1.2.0 | [update android sample](https://github.com/airar-dev/Unity-AR-ColorMapping/releases/tag/v1.2.0) | 2020.10.23 |
375 | | v1.1.0 | [add iOS Library](https://github.com/airar-dev/Unity-AR-ColorMapping/releases/tag/3) | 2020.10.21 |
376 | | v1.0.1 | [add EasyAR sample](https://github.com/airar-dev/Unity-AR-ColorMapping/releases/tag/2) | 2020.10.07 |
377 | | v1.0.0 | [Apply MaxstAR, EasyAR](https://github.com/airar-dev/Unity-AR-ColorMapping/releases/tag/v1.0.0) | 2020.09.09 |
378 |
379 |
380 |
381 |
382 | ## Future Release
383 | * We will add a method for creating coloring 3D content in the near future.
384 |
385 |
386 |
387 |
388 | ## Trouble Shooting
389 | * If an error such as "Undefined symbols for architecture arm64" occurs.
390 |
391 | example:
392 |
393 |
394 | ```
395 | Undefined symbols for architecture arm64:
396 | "cv::getPerspectiveTransform(cv::Point_ const*, cv::Point_ const*)", referenced from:
397 | _ImageProc in libAirarColorMap.a(AirarColorMap.o)
398 | (maybe you meant: cv::getPerspectiveTransform(cv::Point_ const*, cv::Point_ const*, int))
399 | ld: symbol(s) not found for architecture arm64
400 | clang: error: linker command failed with exit code 1 (use -v to see invocation)
401 | ```
402 |
403 | solutions:
404 |
405 |
406 | Be sure to use **version 3.4.11 of the opencv framework.**
407 |
408 |
409 | ## Known issues
410 |
411 | * The coloring is not very accurate when used with the MaxstAR engine.
412 |
413 |
414 |
415 |
416 | ## Contributing
417 |
418 | * Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
419 | 1. Fork the Project.
420 | 2. Create your Feature Branch.
421 | 3. Commit your Changes.
422 | 4. Push to the Branch.
423 | 5. Open a Pull Request.
424 |
425 |
426 |
427 |
428 | ## License
429 | * The 3-Clause BSD License. (see the LICENSE file inside this repo)
430 |
431 |
432 |
433 | ## Contact
434 | * oh@airar.co (sung hoon oh)
435 |
436 |
437 |
438 |
439 |
440 | [masxtar-1]: http://airar.co.kr/ColorMapping/Img/MaxstARSampleImg_01.jpg
441 | [easyar-1]: http://airar.co.kr/ColorMapping/Img/EasyARSampleImg_01.jpg
442 | [vuforia-1]: http://airar.co.kr/ColorMapping/Img/VuforiaSampleImg_01_221130.jpg
443 | [arfoundation-1]: http://airar.co.kr/ColorMapping/Img/ARFoundationSampleImg_01.jpg
444 |
--------------------------------------------------------------------------------
/Sample/ColorMappingWithARFoundationSample.unitypackage:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/airar-dev/Unity-AR-ColorMapping/ec129a80478917f312b8d4ebdf654321daae0409/Sample/ColorMappingWithARFoundationSample.unitypackage
--------------------------------------------------------------------------------
/Sample/ColorMappingWithEasyARSample.unitypackage:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/airar-dev/Unity-AR-ColorMapping/ec129a80478917f312b8d4ebdf654321daae0409/Sample/ColorMappingWithEasyARSample.unitypackage
--------------------------------------------------------------------------------
/Sample/ColorMappingWithMaxstARSample.unitypackage:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/airar-dev/Unity-AR-ColorMapping/ec129a80478917f312b8d4ebdf654321daae0409/Sample/ColorMappingWithMaxstARSample.unitypackage
--------------------------------------------------------------------------------
/Sample/ColorMappingWithVuforiaSample.unitypackage:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/airar-dev/Unity-AR-ColorMapping/ec129a80478917f312b8d4ebdf654321daae0409/Sample/ColorMappingWithVuforiaSample.unitypackage
--------------------------------------------------------------------------------