├── Assets
├── DlibFaceLandmarkDetector.meta
├── DlibFaceLandmarkDetector
│ ├── DlibLicense.txt
│ ├── DlibLicense.txt.meta
│ ├── EnoxSoftware.DlibFaceLandmarkDetector.asmdef
│ ├── EnoxSoftware.DlibFaceLandmarkDetector.asmdef.meta
│ ├── Examples.meta
│ ├── Examples
│ │ ├── BenchmarkExample.meta
│ │ ├── BenchmarkExample
│ │ │ ├── BenchmarkExample.cs
│ │ │ ├── BenchmarkExample.cs.meta
│ │ │ ├── BenchmarkExample.unity
│ │ │ └── BenchmarkExample.unity.meta
│ │ ├── CatDetectionExample.meta
│ │ ├── CatDetectionExample
│ │ │ ├── CatDetectionExample.cs
│ │ │ ├── CatDetectionExample.cs.meta
│ │ │ ├── CatDetectionExample.unity
│ │ │ └── CatDetectionExample.unity.meta
│ │ ├── DlibFaceLandmarkDetectorExample.cs
│ │ ├── DlibFaceLandmarkDetectorExample.cs.meta
│ │ ├── DlibFaceLandmarkDetectorExample.unity
│ │ ├── DlibFaceLandmarkDetectorExample.unity.meta
│ │ ├── EnoxSoftware.DlibFaceLandmarkDetectorExample.asmdef
│ │ ├── EnoxSoftware.DlibFaceLandmarkDetectorExample.asmdef.meta
│ │ ├── ExampleMaterial.mat
│ │ ├── ExampleMaterial.mat.meta
│ │ ├── LoadingIcon.png
│ │ ├── LoadingIcon.png.meta
│ │ ├── Resources.meta
│ │ ├── Resources
│ │ │ ├── benchmark_image_large.png
│ │ │ ├── benchmark_image_large.png.meta
│ │ │ ├── benchmark_image_small.png
│ │ │ ├── benchmark_image_small.png.meta
│ │ │ ├── cat.jpg
│ │ │ ├── cat.jpg.meta
│ │ │ ├── face.jpg
│ │ │ ├── face.jpg.meta
│ │ │ ├── family.png
│ │ │ └── family.png.meta
│ │ ├── ShowSystemInfo.cs
│ │ ├── ShowSystemInfo.cs.meta
│ │ ├── ShowSystemInfo.unity
│ │ ├── ShowSystemInfo.unity.meta
│ │ ├── Texture2DExample.meta
│ │ ├── Texture2DExample
│ │ │ ├── Texture2DExample.cs
│ │ │ ├── Texture2DExample.cs.meta
│ │ │ ├── Texture2DExample.unity
│ │ │ └── Texture2DExample.unity.meta
│ │ ├── Utils.meta
│ │ ├── Utils
│ │ │ ├── FpsMonitor.meta
│ │ │ ├── FpsMonitor
│ │ │ │ ├── FpsMonitor.cs
│ │ │ │ ├── FpsMonitor.cs.meta
│ │ │ │ ├── Resources.meta
│ │ │ │ └── Resources
│ │ │ │ │ ├── FpsMonitorCanvas_103.prefab
│ │ │ │ │ └── FpsMonitorCanvas_103.prefab.meta
│ │ │ ├── InputModuleSwitcher.cs
│ │ │ ├── InputModuleSwitcher.cs.meta
│ │ │ ├── TouchController.cs
│ │ │ └── TouchController.cs.meta
│ │ ├── WebCamTextureExample.meta
│ │ ├── WebCamTextureExample
│ │ │ ├── WebCamTextureExample.cs
│ │ │ ├── WebCamTextureExample.cs.meta
│ │ │ ├── WebCamTextureExample.unity
│ │ │ └── WebCamTextureExample.unity.meta
│ │ ├── link.xml
│ │ └── link.xml.meta
│ ├── Notices.txt
│ ├── Notices.txt.meta
│ ├── ReadMe.pdf
│ └── ReadMe.pdf.meta
├── DlibFaceLandmarkDetectorWithOpenCVExample.meta
└── DlibFaceLandmarkDetectorWithOpenCVExample
│ ├── ARHeadExample.meta
│ ├── ARHeadExample
│ ├── AR.meta
│ ├── AR
│ │ ├── EyeLaser.meta
│ │ ├── EyeLaser
│ │ │ ├── Materials.meta
│ │ │ ├── Materials
│ │ │ │ ├── eff_glitter_2.mat
│ │ │ │ ├── eff_glitter_2.mat.meta
│ │ │ │ ├── eff_par_1.mat
│ │ │ │ ├── eff_par_1.mat.meta
│ │ │ │ ├── eff_smoke_2.mat
│ │ │ │ └── eff_smoke_2.mat.meta
│ │ │ ├── Prefab.meta
│ │ │ ├── Prefab
│ │ │ │ ├── Eff_Laser_2.prefab
│ │ │ │ └── Eff_Laser_2.prefab.meta
│ │ │ ├── Textures.meta
│ │ │ └── Textures
│ │ │ │ ├── Eff_Glitter2.png
│ │ │ │ ├── Eff_Glitter2.png.meta
│ │ │ │ ├── Eff_smoke_1.png
│ │ │ │ ├── Eff_smoke_1.png.meta
│ │ │ │ ├── eff_par_1.tga
│ │ │ │ └── eff_par_1.tga.meta
│ │ ├── Materials.meta
│ │ ├── Materials
│ │ │ ├── axes_x_material_Built-in.mat
│ │ │ ├── axes_x_material_Built-in.mat.meta
│ │ │ ├── axes_x_material_SRP.mat
│ │ │ ├── axes_x_material_SRP.mat.meta
│ │ │ ├── axes_y_material_Built-in.mat
│ │ │ ├── axes_y_material_Built-in.mat.meta
│ │ │ ├── axes_y_material_SRP.mat
│ │ │ ├── axes_y_material_SRP.mat.meta
│ │ │ ├── axes_z_material_Built-in.mat
│ │ │ ├── axes_z_material_Built-in.mat.meta
│ │ │ ├── axes_z_material_SRP.mat
│ │ │ ├── axes_z_material_SRP.mat.meta
│ │ │ ├── head_material_Built-in.mat
│ │ │ ├── head_material_Built-in.mat.meta
│ │ │ ├── head_material_SRP.mat
│ │ │ ├── head_material_SRP.mat.meta
│ │ │ ├── quad_material.mat
│ │ │ └── quad_material.mat.meta
│ │ ├── MouthLaser.meta
│ │ ├── MouthLaser
│ │ │ ├── Materials.meta
│ │ │ ├── Materials
│ │ │ │ ├── eff_heart_1.mat
│ │ │ │ └── eff_heart_1.mat.meta
│ │ │ ├── Prefab.meta
│ │ │ ├── Prefab
│ │ │ │ ├── Eff_Laser_5.prefab
│ │ │ │ └── Eff_Laser_5.prefab.meta
│ │ │ ├── Textures.meta
│ │ │ └── Textures
│ │ │ │ ├── Eff_Heart_1.png
│ │ │ │ └── Eff_Heart_1.png.meta
│ │ ├── Prefabs.meta
│ │ └── Prefabs
│ │ │ ├── Axes_X.prefab
│ │ │ ├── Axes_X.prefab.meta
│ │ │ ├── Axes_Y.prefab
│ │ │ ├── Axes_Y.prefab.meta
│ │ │ ├── Axes_Z.prefab
│ │ │ ├── Axes_Z.prefab.meta
│ │ │ ├── Materials.meta
│ │ │ ├── Materials
│ │ │ ├── unnamed.mat
│ │ │ └── unnamed.mat.meta
│ │ │ ├── human_male.fbx
│ │ │ └── human_male.fbx.meta
│ ├── MultiSourceARHeadExample.cs
│ ├── MultiSourceARHeadExample.cs.meta
│ ├── VideoCaptureARHeadExample_Built-in.unity
│ ├── VideoCaptureARHeadExample_Built-in.unity.meta
│ ├── VideoCaptureARHeadExample_SRP.unity
│ ├── VideoCaptureARHeadExample_SRP.unity.meta
│ ├── WebCamTextureARHeadExample_Built-in.unity
│ ├── WebCamTextureARHeadExample_Built-in.unity.meta
│ ├── WebCamTextureARHeadExample_SRP.unity
│ └── WebCamTextureARHeadExample_SRP.unity.meta
│ ├── EnoxSoftware.DlibFaceLandmarkDetectorWithOpenCVExample.asmdef
│ ├── EnoxSoftware.DlibFaceLandmarkDetectorWithOpenCVExample.asmdef.meta
│ ├── ExampleMaterial.mat
│ ├── ExampleMaterial.mat.meta
│ ├── FrameOptimizationExample.meta
│ ├── FrameOptimizationExample
│ ├── FrameOptimizationExample.cs
│ ├── FrameOptimizationExample.cs.meta
│ ├── FrameOptimizationExample.unity
│ └── FrameOptimizationExample.unity.meta
│ ├── LoadingIcon.png
│ ├── LoadingIcon.png.meta
│ ├── MultiSource2MatHelperExample.meta
│ ├── MultiSource2MatHelperExample
│ ├── MultiSource2MatHelperExample.cs
│ ├── MultiSource2MatHelperExample.cs.meta
│ ├── VideoCapture2MatHelperExample.unity
│ ├── VideoCapture2MatHelperExample.unity.meta
│ ├── WebCamTexture2MatHelperExample.unity
│ └── WebCamTexture2MatHelperExample.unity.meta
│ ├── NoiseFilterExample.meta
│ ├── NoiseFilterExample
│ ├── MultiSourceNoiseFilterExample.cs
│ ├── MultiSourceNoiseFilterExample.cs.meta
│ ├── NoiseFilter.meta
│ ├── NoiseFilter
│ │ ├── KFPointsFilter.cs
│ │ ├── KFPointsFilter.cs.meta
│ │ ├── LowPassPointsFilter.cs
│ │ ├── LowPassPointsFilter.cs.meta
│ │ ├── OFPointsFilter.cs
│ │ ├── OFPointsFilter.cs.meta
│ │ ├── PointsFilterBase.cs
│ │ └── PointsFilterBase.cs.meta
│ ├── VideoCaptureNoiseFilterExample.unity
│ ├── VideoCaptureNoiseFilterExample.unity.meta
│ ├── WebCamTextureNoiseFilterExample.unity
│ └── WebCamTextureNoiseFilterExample.unity.meta
│ ├── OpenCVForUnityUtils.cs
│ ├── OpenCVForUnityUtils.cs.meta
│ ├── ShowLicense.cs
│ ├── ShowLicense.cs.meta
│ ├── ShowLicense.unity
│ ├── ShowLicense.unity.meta
│ ├── Texture2DToMatExample.meta
│ ├── Texture2DToMatExample
│ ├── Texture2DToMatExample.cs
│ ├── Texture2DToMatExample.cs.meta
│ ├── Texture2DToMatExample.unity
│ └── Texture2DToMatExample.unity.meta
│ ├── Utils.meta
│ └── Utils
│ ├── FpsMonitor.meta
│ ├── FpsMonitor
│ ├── FpsMonitor.cs
│ ├── FpsMonitor.cs.meta
│ ├── Resources.meta
│ └── Resources
│ │ ├── FpsMonitorCanvas_103.prefab
│ │ └── FpsMonitorCanvas_103.prefab.meta
│ ├── InputModuleSwitcher.cs
│ ├── InputModuleSwitcher.cs.meta
│ ├── TouchController.cs
│ └── TouchController.cs.meta
└── README.md
/Assets/DlibFaceLandmarkDetector.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4cad3b29bd0ad0b419633f67a0198273
3 | folderAsset: yes
4 | timeCreated: 1460557717
5 | licenseType: Pro
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/DlibLicense.txt:
--------------------------------------------------------------------------------
1 | Boost Software License - Version 1.0 - August 17th, 2003
2 |
3 | Permission is hereby granted, free of charge, to any person or organization
4 | obtaining a copy of the software and accompanying documentation covered by
5 | this license (the "Software") to use, reproduce, display, distribute,
6 | execute, and transmit the Software, and to prepare derivative works of the
7 | Software, and to permit third-parties to whom the Software is furnished to
8 | do so, all subject to the following:
9 |
10 | The copyright notices in the Software and this entire statement, including
11 | the above license grant, this restriction and the following disclaimer,
12 | must be included in all copies of the Software, in whole or in part, and
13 | all derivative works of the Software, unless such copies or derivative
14 | works are solely in the form of machine-executable object code generated by
15 | a source language processor.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 | DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/DlibLicense.txt.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ce43373fc02bf0d41a63c54958f810e1
3 | timeCreated: 1531911535
4 | licenseType: Pro
5 | TextScriptImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/EnoxSoftware.DlibFaceLandmarkDetector.asmdef:
--------------------------------------------------------------------------------
1 | {
2 | "name": "EnoxSoftware.DlibFaceLandmarkDetector",
3 | "references": [],
4 | "includePlatforms": [],
5 | "excludePlatforms": [],
6 | "allowUnsafeCode": true,
7 | "overrideReferences": false,
8 | "precompiledReferences": [],
9 | "autoReferenced": true,
10 | "defineConstraints": [],
11 | "versionDefines": [],
12 | "noEngineReferences": false
13 | }
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/EnoxSoftware.DlibFaceLandmarkDetector.asmdef.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7166fda719c99694d9297ead935e2a9d
3 | AssemblyDefinitionImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 65639e7e41c0da94aaf9cd09e0134076
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/BenchmarkExample.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 380f1978c0937a24a96075251c940b04
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/BenchmarkExample/BenchmarkExample.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 029a69d2775e26c4d947b9106bd1c039
3 | timeCreated: 1547467264
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/BenchmarkExample/BenchmarkExample.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2a06413d2e8e9de4ea2b4f41f72d5836
3 | timeCreated: 1547467264
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/CatDetectionExample.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a347262af0949c341b91647031e2095b
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/CatDetectionExample/CatDetectionExample.cs:
--------------------------------------------------------------------------------
1 | using DlibFaceLandmarkDetector;
2 | using DlibFaceLandmarkDetector.UnityUtils;
3 | using System;
4 | using System.Collections;
5 | using System.Collections.Generic;
6 | using System.Threading;
7 | using UnityEngine;
8 | using UnityEngine.SceneManagement;
9 | using UnityEngine.UI;
10 |
11 | namespace DlibFaceLandmarkDetectorExample
12 | {
13 | ///
14 | /// Cat Detection Example
15 | /// An example of detecting cat face landmarks in a Texture2D image.
16 | ///
17 | public class CatDetectionExample : MonoBehaviour
18 | {
19 | [Header("Output")]
20 | ///
21 | /// The RawImage for previewing the result.
22 | ///
23 | public RawImage resultPreview;
24 |
25 | [Space(10)]
26 |
27 | ///
28 | /// The texture2D.
29 | ///
30 | public Texture2D texture2D;
31 |
32 | ///
33 | /// The FPS monitor.
34 | ///
35 | FpsMonitor fpsMonitor;
36 |
37 | ///
38 | /// OBJECT_DETECTOR_FILENAME
39 | ///
40 | protected static readonly string OBJECT_DETECTOR_FILENAME = "DlibFaceLandmarkDetector/frontal_cat_face.svm";
41 |
42 | ///
43 | /// The object_detector_filepath.
44 | ///
45 | string object_detector_filepath;
46 |
47 | ///
48 | /// SHAPE_PREDICTOR_FILENAME
49 | ///
50 | protected static readonly string SHAPE_PREDICTOR_FILENAME = "DlibFaceLandmarkDetector/sp_cat_face_68.dat";
51 |
52 | ///
53 | /// The shape_predictor_filepath.
54 | ///
55 | string shape_predictor_filepath;
56 |
57 | ///
58 | /// The CancellationTokenSource.
59 | ///
60 | CancellationTokenSource cts = new CancellationTokenSource();
61 |
62 | // Use this for initialization
63 | async void Start()
64 | {
65 | fpsMonitor = GetComponent();
66 |
67 | // Asynchronously retrieves the readable file path from the StreamingAssets directory.
68 | if (fpsMonitor != null)
69 | fpsMonitor.consoleText = "Preparing file access...";
70 |
71 | object_detector_filepath = await Utils.getFilePathAsyncTask(OBJECT_DETECTOR_FILENAME, cancellationToken: cts.Token);
72 | shape_predictor_filepath = await Utils.getFilePathAsyncTask(SHAPE_PREDICTOR_FILENAME, cancellationToken: cts.Token);
73 |
74 | if (fpsMonitor != null)
75 | fpsMonitor.consoleText = "";
76 |
77 | Run();
78 | }
79 |
80 | private void Run()
81 | {
82 | if (string.IsNullOrEmpty(object_detector_filepath))
83 | {
84 | Debug.LogError("object detecter file does not exist. Please copy from “DlibFaceLandmarkDetector/StreamingAssets/DlibFaceLandmarkDetector/” to “Assets/StreamingAssets/DlibFaceLandmarkDetector/” folder. ");
85 | }
86 | if (string.IsNullOrEmpty(shape_predictor_filepath))
87 | {
88 | Debug.LogError("shape predictor file does not exist. Please copy from “DlibFaceLandmarkDetector/StreamingAssets/DlibFaceLandmarkDetector/” to “Assets/StreamingAssets/DlibFaceLandmarkDetector/” folder. ");
89 | }
90 |
91 | Texture2D dstTexture2D = new Texture2D(texture2D.width, texture2D.height, texture2D.format, false);
92 | dstTexture2D.SetPixels32(texture2D.GetPixels32());
93 | dstTexture2D.Apply();
94 |
95 | FaceLandmarkDetector faceLandmarkDetector = new FaceLandmarkDetector(object_detector_filepath, shape_predictor_filepath);
96 | faceLandmarkDetector.SetImage(texture2D);
97 |
98 | //detect face rects
99 | List detectResult = faceLandmarkDetector.Detect();
100 |
101 | foreach (var rect in detectResult)
102 | {
103 | Debug.Log("face : " + rect);
104 |
105 | //detect landmark points
106 | List points = faceLandmarkDetector.DetectLandmark(rect);
107 |
108 | Debug.Log("face points count : " + points.Count);
109 | foreach (var point in points)
110 | {
111 | Debug.Log("face point : x " + point.x + " y " + point.y);
112 | }
113 |
114 | //draw landmark points
115 | faceLandmarkDetector.DrawDetectLandmarkResult(dstTexture2D, 0, 255, 0, 255);
116 | }
117 |
118 | //draw face rects
119 | faceLandmarkDetector.DrawDetectResult(dstTexture2D, 255, 0, 0, 255, 3);
120 |
121 | faceLandmarkDetector.Dispose();
122 |
123 | resultPreview.texture = dstTexture2D;
124 | resultPreview.GetComponent().aspectRatio = (float)dstTexture2D.width / dstTexture2D.height;
125 |
126 |
127 | if (fpsMonitor != null)
128 | {
129 | fpsMonitor.Add("dlib object detector", "frontal_cat_face.svm");
130 | fpsMonitor.Add("dlib shape predictor", "sp_cat_face_68.dat");
131 | fpsMonitor.Add("width", dstTexture2D.width.ToString());
132 | fpsMonitor.Add("height", dstTexture2D.height.ToString());
133 | fpsMonitor.Add("orientation", Screen.orientation.ToString());
134 | }
135 | }
136 |
137 | // Update is called once per frame
138 | void Update()
139 | {
140 |
141 | }
142 |
143 | ///
144 | /// Raises the destroy event.
145 | ///
146 | void OnDestroy()
147 | {
148 | if (cts != null)
149 | cts.Dispose();
150 | }
151 |
152 | ///
153 | /// Raises the back button click event.
154 | ///
155 | public void OnBackButtonClick()
156 | {
157 | SceneManager.LoadScene("DlibFaceLandmarkDetectorExample");
158 | }
159 | }
160 | }
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/CatDetectionExample/CatDetectionExample.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a59befc045462d34d817f0b9148067c0
3 | timeCreated: 1462530675
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/DlibFaceLandmarkDetector/Examples/CatDetectionExample/CatDetectionExample.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6c173eaaeba2da1408c7057b72cf8441
3 | timeCreated: 1462530674
4 | licenseType: Pro
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/DlibFaceLandmarkDetectorExample.cs:
--------------------------------------------------------------------------------
1 | using DlibFaceLandmarkDetector.UnityUtils;
2 | using UnityEngine;
3 | using UnityEngine.Rendering;
4 | using UnityEngine.SceneManagement;
5 | using UnityEngine.UI;
6 |
7 | namespace DlibFaceLandmarkDetectorExample
8 | {
9 | public class DlibFaceLandmarkDetectorExample : MonoBehaviour
10 | {
11 | public Text versionInfo;
12 | public ScrollRect scrollRect;
13 | static float verticalNormalizedPosition = 1f;
14 |
15 |
16 | public enum DlibShapePredictorNamePreset : int
17 | {
18 | sp_human_face_68,
19 | sp_human_face_68_for_mobile,
20 | sp_human_face_17,
21 | sp_human_face_17_for_mobile,
22 | sp_human_face_6,
23 | }
24 |
25 | public Dropdown dlibShapePredictorNameDropdown;
26 |
27 | static DlibShapePredictorNamePreset dlibShapePredictorName = DlibShapePredictorNamePreset.sp_human_face_68;
28 |
29 | ///
30 | /// The name of dlib shape predictor file to use in the example scenes.
31 | ///
32 | public static string dlibShapePredictorFileName
33 | {
34 | get
35 | {
36 | return "DlibFaceLandmarkDetector/" + dlibShapePredictorName.ToString() + ".dat";
37 | }
38 | }
39 |
40 | // Use this for initialization
41 | void Start()
42 | {
43 | versionInfo.text = "dlibfacelandmarkdetector" + " " + Utils.getVersion();
44 | versionInfo.text += " / UnityEditor " + Application.unityVersion;
45 | versionInfo.text += " / ";
46 |
47 | #if UNITY_EDITOR
48 | versionInfo.text += "Editor";
49 | #elif UNITY_STANDALONE_WIN
50 | versionInfo.text += "Windows";
51 | #elif UNITY_STANDALONE_OSX
52 | versionInfo.text += "Mac OSX";
53 | #elif UNITY_STANDALONE_LINUX
54 | versionInfo.text += "Linux";
55 | #elif UNITY_ANDROID
56 | versionInfo.text += "Android";
57 | #elif UNITY_IOS
58 | versionInfo.text += "iOS";
59 | #elif UNITY_WSA
60 | versionInfo.text += "WSA";
61 | #elif UNITY_WEBGL
62 | versionInfo.text += "WebGL";
63 | #endif
64 | versionInfo.text += " ";
65 | #if ENABLE_MONO
66 | versionInfo.text += "Mono";
67 | #elif ENABLE_IL2CPP
68 | versionInfo.text += "IL2CPP";
69 | #elif ENABLE_DOTNET
70 | versionInfo.text += ".NET";
71 | #endif
72 |
73 | scrollRect.verticalNormalizedPosition = verticalNormalizedPosition;
74 |
75 | dlibShapePredictorNameDropdown.value = (int)dlibShapePredictorName;
76 | }
77 |
78 | // Update is called once per frame
79 | void Update()
80 | {
81 |
82 | }
83 |
84 | public void OnScrollRectValueChanged()
85 | {
86 | verticalNormalizedPosition = scrollRect.verticalNormalizedPosition;
87 | }
88 |
89 |
90 | public void OnShowSystemInfoButtonClick()
91 | {
92 | SceneManager.LoadScene("ShowSystemInfo");
93 | }
94 |
95 | public void OnTexture2DExampleButtonClick()
96 | {
97 | SceneManager.LoadScene("Texture2DExample");
98 | }
99 |
100 | public void OnWebCamTextureExampleButtonClick()
101 | {
102 | SceneManager.LoadScene("WebCamTextureExample");
103 | }
104 |
105 | public void OnCatDetectionExampleButtonClick()
106 | {
107 | SceneManager.LoadScene("CatDetectionExample");
108 | }
109 |
110 | public void OnBenchmarkExampleButtonClick()
111 | {
112 | SceneManager.LoadScene("BenchmarkExample");
113 | }
114 |
115 |
116 |
117 | public void OnShowLicenseButtonClick()
118 | {
119 | SceneManager.LoadScene("ShowLicense");
120 | }
121 |
122 | public void OnTexture2DToMatExampleButtonClick()
123 | {
124 | SceneManager.LoadScene("Texture2DToMatExample");
125 | }
126 |
127 | public void OnWebCamTexture2MatHelperExampleButtonClick()
128 | {
129 | SceneManager.LoadScene("WebCamTexture2MatHelperExample");
130 | }
131 |
132 | public void OnVideoCapture2MatHelperExampleButtonClick()
133 | {
134 | SceneManager.LoadScene("VideoCapture2MatHelperExample");
135 | }
136 |
137 | public void OnWebCamTextureARHeadExampleButtonClick()
138 | {
139 | if (GraphicsSettings.defaultRenderPipeline == null)
140 | {
141 | SceneManager.LoadScene("WebCamTextureARHeadExample_Built-in");
142 | }
143 | else
144 | {
145 | SceneManager.LoadScene("WebCamTextureARHeadExample_SRP");
146 | }
147 | }
148 |
149 | public void OnVideoCaptureARHeadExampleButtonClick()
150 | {
151 | if (GraphicsSettings.defaultRenderPipeline == null)
152 | {
153 | SceneManager.LoadScene("VideoCaptureARHeadExample_Built-in");
154 | }
155 | else
156 | {
157 | SceneManager.LoadScene("VideoCaptureARHeadExample_SRP");
158 | }
159 | }
160 |
161 | public void OnFrameOptimizationExampleButtonClick()
162 | {
163 | SceneManager.LoadScene("FrameOptimizationExample");
164 | }
165 |
166 | public void OnWebCamTextureNoiseFilterExampleButtonClick()
167 | {
168 | SceneManager.LoadScene("WebCamTextureNoiseFilterExample");
169 | }
170 |
171 | public void OnVideoCaptureNoiseFilterExampleButtonClick()
172 | {
173 | SceneManager.LoadScene("VideoCaptureNoiseFilterExample");
174 | }
175 |
176 |
177 | ///
178 | /// Raises the dlib shape predictor name dropdown value changed event.
179 | ///
180 | public void OnDlibShapePredictorNameDropdownValueChanged(int result)
181 | {
182 | dlibShapePredictorName = (DlibShapePredictorNamePreset)result;
183 | }
184 | }
185 | }
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/DlibFaceLandmarkDetectorExample.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f490634625317c545b5e7d48aac913af
3 | timeCreated: 1461439312
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/DlibFaceLandmarkDetector/Examples/DlibFaceLandmarkDetectorExample.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f14b07666e9ee894fac7f94624ef302d
3 | timeCreated: 1461439312
4 | licenseType: Pro
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/EnoxSoftware.DlibFaceLandmarkDetectorExample.asmdef:
--------------------------------------------------------------------------------
1 | {
2 | "name": "EnoxSoftware.DlibFaceLandmarkDetectorExample",
3 | "rootNamespace": "",
4 | "references": [
5 | "EnoxSoftware.DlibFaceLandmarkDetector",
6 | "Unity.InputSystem"
7 | ],
8 | "includePlatforms": [],
9 | "excludePlatforms": [],
10 | "allowUnsafeCode": true,
11 | "overrideReferences": false,
12 | "precompiledReferences": [],
13 | "autoReferenced": true,
14 | "defineConstraints": [],
15 | "versionDefines": [],
16 | "noEngineReferences": false
17 | }
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/EnoxSoftware.DlibFaceLandmarkDetectorExample.asmdef.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ffc1fa445a7832149a66ac36298c97ac
3 | AssemblyDefinitionImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/ExampleMaterial.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 5
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_CustomRenderQueue: -1
14 | m_SavedProperties:
15 | serializedVersion: 2
16 | m_TexEnvs:
17 | data:
18 | first:
19 | name: _MainTex
20 | second:
21 | m_Texture: {fileID: 2800000, guid: 2639e6dea8386244db10423fbefae982, type: 3}
22 | m_Scale: {x: 1, y: 1}
23 | m_Offset: {x: 0, y: 0}
24 | m_Floats: {}
25 | m_Colors:
26 | data:
27 | first:
28 | name: _Color
29 | second: {r: 1, g: 1, b: 1, a: 1}
30 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/ExampleMaterial.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 82cedaac19e0a3e40a59d980c2efc68e
3 | timeCreated: 1461439312
4 | licenseType: Pro
5 | NativeFormatImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/LoadingIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EnoxSoftware/DlibFaceLandmarkDetector/c0389436229346ed6a3dd1859fa0505d55d36e89/Assets/DlibFaceLandmarkDetector/Examples/LoadingIcon.png
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/LoadingIcon.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2639e6dea8386244db10423fbefae982
3 | timeCreated: 1479410294
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: 0
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: 0
49 | buildTargetSettings: []
50 | spriteSheet:
51 | sprites: []
52 | spritePackingTag:
53 | userData:
54 | assetBundleName:
55 | assetBundleVariant:
56 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Resources.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cace15390dd4dd64caf77bb4c5de64de
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Resources/benchmark_image_large.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EnoxSoftware/DlibFaceLandmarkDetector/c0389436229346ed6a3dd1859fa0505d55d36e89/Assets/DlibFaceLandmarkDetector/Examples/Resources/benchmark_image_large.png
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Resources/benchmark_image_large.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4eddcc316c98db64abfc30652c4f1dd6
3 | timeCreated: 1547483634
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 4
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 0
11 | sRGBTexture: 1
12 | linearTexture: 0
13 | fadeOut: 0
14 | borderMipMap: 0
15 | mipMapFadeDistanceStart: 1
16 | mipMapFadeDistanceEnd: 3
17 | bumpmap:
18 | convertToNormalMap: 0
19 | externalNormalMap: 0
20 | heightScale: 0.25
21 | normalMapFilter: 0
22 | isReadable: 1
23 | grayScaleToAlpha: 0
24 | generateCubemap: 6
25 | cubemapConvolution: 0
26 | seamlessCubemap: 0
27 | textureFormat: 1
28 | maxTextureSize: 2048
29 | textureSettings:
30 | filterMode: -1
31 | aniso: -1
32 | mipBias: -1
33 | wrapMode: -1
34 | nPOTScale: 0
35 | lightmap: 0
36 | compressionQuality: 50
37 | spriteMode: 0
38 | spriteExtrude: 1
39 | spriteMeshType: 1
40 | alignment: 0
41 | spritePivot: {x: 0.5, y: 0.5}
42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
43 | spritePixelsToUnits: 100
44 | alphaUsage: 1
45 | alphaIsTransparency: 0
46 | spriteTessellationDetail: -1
47 | textureType: 0
48 | textureShape: 1
49 | maxTextureSizeSet: 0
50 | compressionQualitySet: 0
51 | textureFormatSet: 0
52 | platformSettings:
53 | - buildTarget: DefaultTexturePlatform
54 | maxTextureSize: 1024
55 | textureFormat: -1
56 | textureCompression: 0
57 | compressionQuality: 50
58 | crunchedCompression: 1
59 | allowsAlphaSplitting: 0
60 | overridden: 0
61 | - buildTarget: Standalone
62 | maxTextureSize: 1024
63 | textureFormat: -1
64 | textureCompression: 0
65 | compressionQuality: 50
66 | crunchedCompression: 1
67 | allowsAlphaSplitting: 0
68 | overridden: 0
69 | - buildTarget: iPhone
70 | maxTextureSize: 1024
71 | textureFormat: -1
72 | textureCompression: 0
73 | compressionQuality: 50
74 | crunchedCompression: 1
75 | allowsAlphaSplitting: 0
76 | overridden: 0
77 | - buildTarget: Android
78 | maxTextureSize: 1024
79 | textureFormat: -1
80 | textureCompression: 0
81 | compressionQuality: 50
82 | crunchedCompression: 1
83 | allowsAlphaSplitting: 0
84 | overridden: 0
85 | - buildTarget: WebGL
86 | maxTextureSize: 1024
87 | textureFormat: -1
88 | textureCompression: 0
89 | compressionQuality: 50
90 | crunchedCompression: 1
91 | allowsAlphaSplitting: 0
92 | overridden: 0
93 | spriteSheet:
94 | serializedVersion: 2
95 | sprites: []
96 | outline: []
97 | spritePackingTag:
98 | userData:
99 | assetBundleName:
100 | assetBundleVariant:
101 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Resources/benchmark_image_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EnoxSoftware/DlibFaceLandmarkDetector/c0389436229346ed6a3dd1859fa0505d55d36e89/Assets/DlibFaceLandmarkDetector/Examples/Resources/benchmark_image_small.png
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Resources/benchmark_image_small.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d650bf66dd6f3e444a14dfe95ab29b09
3 | timeCreated: 1547483634
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 4
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 0
11 | sRGBTexture: 1
12 | linearTexture: 0
13 | fadeOut: 0
14 | borderMipMap: 0
15 | mipMapFadeDistanceStart: 1
16 | mipMapFadeDistanceEnd: 3
17 | bumpmap:
18 | convertToNormalMap: 0
19 | externalNormalMap: 0
20 | heightScale: 0.25
21 | normalMapFilter: 0
22 | isReadable: 1
23 | grayScaleToAlpha: 0
24 | generateCubemap: 6
25 | cubemapConvolution: 0
26 | seamlessCubemap: 0
27 | textureFormat: 1
28 | maxTextureSize: 2048
29 | textureSettings:
30 | filterMode: -1
31 | aniso: -1
32 | mipBias: -1
33 | wrapMode: -1
34 | nPOTScale: 0
35 | lightmap: 0
36 | compressionQuality: 50
37 | spriteMode: 0
38 | spriteExtrude: 1
39 | spriteMeshType: 1
40 | alignment: 0
41 | spritePivot: {x: 0.5, y: 0.5}
42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
43 | spritePixelsToUnits: 100
44 | alphaUsage: 1
45 | alphaIsTransparency: 0
46 | spriteTessellationDetail: -1
47 | textureType: 0
48 | textureShape: 1
49 | maxTextureSizeSet: 0
50 | compressionQualitySet: 0
51 | textureFormatSet: 0
52 | platformSettings:
53 | - buildTarget: DefaultTexturePlatform
54 | maxTextureSize: 1024
55 | textureFormat: -1
56 | textureCompression: 0
57 | compressionQuality: 50
58 | crunchedCompression: 0
59 | allowsAlphaSplitting: 0
60 | overridden: 0
61 | - buildTarget: Standalone
62 | maxTextureSize: 1024
63 | textureFormat: -1
64 | textureCompression: 0
65 | compressionQuality: 50
66 | crunchedCompression: 0
67 | allowsAlphaSplitting: 0
68 | overridden: 0
69 | - buildTarget: iPhone
70 | maxTextureSize: 1024
71 | textureFormat: -1
72 | textureCompression: 0
73 | compressionQuality: 50
74 | crunchedCompression: 0
75 | allowsAlphaSplitting: 0
76 | overridden: 0
77 | - buildTarget: Android
78 | maxTextureSize: 1024
79 | textureFormat: -1
80 | textureCompression: 0
81 | compressionQuality: 50
82 | crunchedCompression: 0
83 | allowsAlphaSplitting: 0
84 | overridden: 0
85 | - buildTarget: WebGL
86 | maxTextureSize: 1024
87 | textureFormat: -1
88 | textureCompression: 0
89 | compressionQuality: 50
90 | crunchedCompression: 0
91 | allowsAlphaSplitting: 0
92 | overridden: 0
93 | spriteSheet:
94 | serializedVersion: 2
95 | sprites: []
96 | outline: []
97 | spritePackingTag:
98 | userData:
99 | assetBundleName:
100 | assetBundleVariant:
101 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Resources/cat.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EnoxSoftware/DlibFaceLandmarkDetector/c0389436229346ed6a3dd1859fa0505d55d36e89/Assets/DlibFaceLandmarkDetector/Examples/Resources/cat.jpg
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Resources/cat.jpg.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 02f4f480b973f9748904cc7123edba99
3 | timeCreated: 1462821508
4 | licenseType: Pro
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 2
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 0
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: 1
23 | grayScaleToAlpha: 0
24 | generateCubemap: 0
25 | cubemapConvolution: 0
26 | cubemapConvolutionSteps: 8
27 | cubemapConvolutionExponent: 1.5
28 | seamlessCubemap: 0
29 | textureFormat: 4
30 | maxTextureSize: 1024
31 | textureSettings:
32 | filterMode: -1
33 | aniso: -1
34 | mipBias: -1
35 | wrapMode: -1
36 | nPOTScale: 0
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: 5
49 | buildTargetSettings: []
50 | spriteSheet:
51 | sprites: []
52 | spritePackingTag:
53 | userData:
54 | assetBundleName:
55 | assetBundleVariant:
56 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Resources/face.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EnoxSoftware/DlibFaceLandmarkDetector/c0389436229346ed6a3dd1859fa0505d55d36e89/Assets/DlibFaceLandmarkDetector/Examples/Resources/face.jpg
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Resources/face.jpg.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 10f9e7382298b7847bca861a899f738b
3 | timeCreated: 1594897092
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 4
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 0
11 | sRGBTexture: 1
12 | linearTexture: 0
13 | fadeOut: 0
14 | borderMipMap: 0
15 | mipMapsPreserveCoverage: 0
16 | alphaTestReferenceValue: 0.5
17 | mipMapFadeDistanceStart: 1
18 | mipMapFadeDistanceEnd: 3
19 | bumpmap:
20 | convertToNormalMap: 0
21 | externalNormalMap: 0
22 | heightScale: 0.25
23 | normalMapFilter: 0
24 | isReadable: 1
25 | grayScaleToAlpha: 0
26 | generateCubemap: 6
27 | cubemapConvolution: 0
28 | seamlessCubemap: 0
29 | textureFormat: 1
30 | maxTextureSize: 2048
31 | textureSettings:
32 | serializedVersion: 2
33 | filterMode: -1
34 | aniso: -1
35 | mipBias: -1
36 | wrapU: -1
37 | wrapV: -1
38 | wrapW: -1
39 | nPOTScale: 1
40 | lightmap: 0
41 | compressionQuality: 50
42 | spriteMode: 0
43 | spriteExtrude: 1
44 | spriteMeshType: 1
45 | alignment: 0
46 | spritePivot: {x: 0.5, y: 0.5}
47 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
48 | spritePixelsToUnits: 100
49 | alphaUsage: 1
50 | alphaIsTransparency: 0
51 | spriteTessellationDetail: -1
52 | textureType: 0
53 | textureShape: 1
54 | maxTextureSizeSet: 0
55 | compressionQualitySet: 0
56 | textureFormatSet: 0
57 | platformSettings:
58 | - buildTarget: DefaultTexturePlatform
59 | maxTextureSize: 1024
60 | textureFormat: -1
61 | textureCompression: 0
62 | compressionQuality: 50
63 | crunchedCompression: 0
64 | allowsAlphaSplitting: 0
65 | overridden: 0
66 | - buildTarget: Standalone
67 | maxTextureSize: 1024
68 | textureFormat: -1
69 | textureCompression: 0
70 | compressionQuality: 50
71 | crunchedCompression: 0
72 | allowsAlphaSplitting: 0
73 | overridden: 0
74 | - buildTarget: Android
75 | maxTextureSize: 1024
76 | textureFormat: -1
77 | textureCompression: 0
78 | compressionQuality: 50
79 | crunchedCompression: 0
80 | allowsAlphaSplitting: 0
81 | overridden: 0
82 | spriteSheet:
83 | serializedVersion: 2
84 | sprites: []
85 | outline: []
86 | physicsShape: []
87 | spritePackingTag:
88 | userData:
89 | assetBundleName:
90 | assetBundleVariant:
91 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Resources/family.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EnoxSoftware/DlibFaceLandmarkDetector/c0389436229346ed6a3dd1859fa0505d55d36e89/Assets/DlibFaceLandmarkDetector/Examples/Resources/family.png
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Resources/family.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1a1104c708dd5324ea04ed6e0da67610
3 | timeCreated: 1461853434
4 | licenseType: Pro
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 2
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 0
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: 1
23 | grayScaleToAlpha: 0
24 | generateCubemap: 0
25 | cubemapConvolution: 0
26 | cubemapConvolutionSteps: 8
27 | cubemapConvolutionExponent: 1.5
28 | seamlessCubemap: 0
29 | textureFormat: 4
30 | maxTextureSize: 1024
31 | textureSettings:
32 | filterMode: -1
33 | aniso: -1
34 | mipBias: -1
35 | wrapMode: -1
36 | nPOTScale: 0
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: 5
49 | buildTargetSettings: []
50 | spriteSheet:
51 | sprites: []
52 | spritePackingTag:
53 | userData:
54 | assetBundleName:
55 | assetBundleVariant:
56 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/ShowSystemInfo.cs:
--------------------------------------------------------------------------------
1 | using DlibFaceLandmarkDetector.UnityUtils;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Reflection;
5 | using System.Text;
6 | using UnityEngine;
7 | using UnityEngine.SceneManagement;
8 | using UnityEngine.UI;
9 |
10 | namespace DlibFaceLandmarkDetectorExample
11 | {
12 | public class ShowSystemInfo : MonoBehaviour
13 | {
14 | public Text systemInfoText;
15 | public InputField systemInfoInputField;
16 |
17 | private const string ASSET_NAME = "DlibFaceLandmarkDetector";
18 |
19 | // Use this for initialization
20 | void Start()
21 | {
22 |
23 | StringBuilder sb = new StringBuilder();
24 | sb.Append("###### Build Info ######\n");
25 | IDictionary buildInfo = GetBuildInfo();
26 | foreach (string key in buildInfo.Keys)
27 | {
28 | sb.Append(key).Append(" = ").Append(buildInfo[key]).Append("\n");
29 | }
30 | sb.Append("\n");
31 |
32 | #if UNITY_IOS || (UNITY_ANDROID && UNITY_2018_3_OR_NEWER)
33 | sb.Append("###### Device Info ######\n");
34 | IDictionary deviceInfo = GetDeviceInfo();
35 | foreach (string key in deviceInfo.Keys)
36 | {
37 | sb.Append(key).Append(" = ").Append(deviceInfo[key]).Append("\n");
38 | }
39 | sb.Append("\n");
40 | #endif
41 |
42 | sb.Append("###### System Info ######\n");
43 | IDictionary systemInfo = GetSystemInfo();
44 | foreach (string key in systemInfo.Keys)
45 | {
46 | sb.Append(key).Append(" = ").Append(systemInfo[key]).Append("\n");
47 | }
48 | sb.Append("#########################\n");
49 |
50 | systemInfoText.text = systemInfoInputField.text = sb.ToString();
51 | Debug.Log(sb.ToString());
52 | }
53 |
54 | // Update is called once per frame
55 | void Update()
56 | {
57 |
58 | }
59 |
60 | public Dictionary GetBuildInfo()
61 | {
62 | Dictionary dict = new Dictionary();
63 |
64 | dict.Add(ASSET_NAME + " version", Utils.getVersion());
65 | dict.Add("Build Unity version", Application.unityVersion);
66 |
67 | #if UNITY_EDITOR
68 | dict.Add("Build target", "Editor");
69 | #elif UNITY_STANDALONE_WIN
70 | dict.Add("Build target", "Windows");
71 | #elif UNITY_STANDALONE_OSX
72 | dict.Add("Build target", "Mac OSX");
73 | #elif UNITY_STANDALONE_LINUX
74 | dict.Add("Build target", "Linux");
75 | #elif UNITY_ANDROID
76 | dict.Add("Build target", "Android");
77 | #elif UNITY_IOS
78 | dict.Add("Build target", "iOS");
79 | #elif UNITY_WSA
80 | dict.Add("Build target", "WSA");
81 | #elif UNITY_WEBGL
82 | dict.Add("Build target", "WebGL");
83 | #else
84 | dict.Add("Build target", "");
85 | #endif
86 |
87 | #if ENABLE_MONO
88 | dict.Add("Scripting backend", "Mono");
89 | #elif ENABLE_IL2CPP
90 | dict.Add("Scripting backend", "IL2CPP");
91 | #elif ENABLE_DOTNET
92 | dict.Add("Scripting backend", ".NET");
93 | #else
94 | dict.Add("Scripting backend", "");
95 | #endif
96 |
97 | #if !DLIB_DONT_USE_UNSAFE_CODE
98 | dict.Add("Allow 'unsafe' Code", "Enabled");
99 | #else
100 | dict.Add("Allow 'unsafe' Code", "Disabled");
101 | #endif
102 |
103 | return dict;
104 | }
105 |
106 | public Dictionary GetDeviceInfo()
107 | {
108 | Dictionary dict = new Dictionary();
109 |
110 | #if UNITY_IOS
111 | dict.Add("iOS.Device.generation", UnityEngine.iOS.Device.generation.ToString());
112 | dict.Add("iOS.Device.systemVersion", UnityEngine.iOS.Device.systemVersion.ToString());
113 | #endif
114 | #if UNITY_IOS && UNITY_2018_1_OR_NEWER
115 | dict.Add("UserAuthorization.WebCam", Application.HasUserAuthorization(UserAuthorization.WebCam).ToString());
116 | dict.Add("UserAuthorization.Microphone", Application.HasUserAuthorization(UserAuthorization.Microphone).ToString());
117 | #endif
118 | #if UNITY_ANDROID && UNITY_2018_3_OR_NEWER
119 | dict.Add("Android.Permission.Camera", UnityEngine.Android.Permission.HasUserAuthorizedPermission(UnityEngine.Android.Permission.Camera).ToString());
120 | dict.Add("Android.Permission.CoarseLocation", UnityEngine.Android.Permission.HasUserAuthorizedPermission(UnityEngine.Android.Permission.CoarseLocation).ToString());
121 | dict.Add("Android.Permission.ExternalStorageRead", UnityEngine.Android.Permission.HasUserAuthorizedPermission(UnityEngine.Android.Permission.ExternalStorageRead).ToString());
122 | dict.Add("Android.Permission.ExternalStorageWrite", UnityEngine.Android.Permission.HasUserAuthorizedPermission(UnityEngine.Android.Permission.ExternalStorageWrite).ToString());
123 | dict.Add("Android.Permission.FineLocation", UnityEngine.Android.Permission.HasUserAuthorizedPermission(UnityEngine.Android.Permission.FineLocation).ToString());
124 | dict.Add("Android.Permission.Microphone", UnityEngine.Android.Permission.HasUserAuthorizedPermission(UnityEngine.Android.Permission.Microphone).ToString());
125 | #endif
126 |
127 | return dict;
128 | }
129 |
130 | /// SystemInfo Class Propertys
131 | public SortedDictionary GetSystemInfo()
132 | {
133 | SortedDictionary dict = new SortedDictionary();
134 |
135 | Type type = typeof(SystemInfo);
136 | MemberInfo[] members = type.GetMembers(
137 | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
138 |
139 | foreach (MemberInfo mb in members)
140 | {
141 | try
142 | {
143 | if (mb.MemberType == MemberTypes.Property)
144 | {
145 | if (mb.Name == "deviceUniqueIdentifier")
146 | {
147 | dict.Add(mb.Name, "xxxxxxxxxxxxxxxxxxxxxxxx");
148 | continue;
149 | }
150 |
151 | PropertyInfo pr = type.GetProperty(mb.Name);
152 |
153 | if (pr != null)
154 | {
155 | object resobj = pr.GetValue(type, null);
156 | dict.Add(mb.Name, resobj.ToString());
157 | }
158 | else
159 | {
160 | dict.Add(mb.Name, "");
161 | }
162 | }
163 | }
164 | catch (Exception e)
165 | {
166 | Debug.Log("Exception: " + e);
167 | }
168 | }
169 |
170 | return dict;
171 | }
172 |
173 | public void OnBackButtonClick()
174 | {
175 | SceneManager.LoadScene("DlibFaceLandmarkDetectorExample");
176 | }
177 | }
178 | }
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/ShowSystemInfo.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 65e9ea194865bdd44beecbde6ded985f
3 | timeCreated: 1522874906
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/ShowSystemInfo.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 505339b443d9bea4895ad7a35ac6be25
3 | timeCreated: 1522874905
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Texture2DExample.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f78c887814bab2f408b9aa7afcd6d30b
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Texture2DExample/Texture2DExample.cs:
--------------------------------------------------------------------------------
1 | using DlibFaceLandmarkDetector;
2 | using DlibFaceLandmarkDetector.UnityUtils;
3 | using System;
4 | using System.Collections;
5 | using System.Collections.Generic;
6 | using System.Threading;
7 | using UnityEngine;
8 | using UnityEngine.SceneManagement;
9 | using UnityEngine.UI;
10 |
11 | namespace DlibFaceLandmarkDetectorExample
12 | {
13 | ///
14 | /// Texture2D Example
15 | /// An example of detecting face landmarks in a Texture2D image.
16 | ///
17 | public class Texture2DExample : MonoBehaviour
18 | {
19 | [Header("Output")]
20 | ///
21 | /// The RawImage for previewing the result.
22 | ///
23 | public RawImage resultPreview;
24 |
25 | [Space(10)]
26 |
27 | ///
28 | /// The texture2D.
29 | ///
30 | public Texture2D texture2D;
31 |
32 | ///
33 | /// The FPS monitor.
34 | ///
35 | FpsMonitor fpsMonitor;
36 |
37 | ///
38 | /// The dlib shape predictor file name.
39 | ///
40 | string dlibShapePredictorFileName = "DlibFaceLandmarkDetector/sp_human_face_68.dat";
41 |
42 | ///
43 | /// The dlib shape predictor file path.
44 | ///
45 | string dlibShapePredictorFilePath;
46 |
47 | ///
48 | /// The CancellationTokenSource.
49 | ///
50 | CancellationTokenSource cts = new CancellationTokenSource();
51 |
52 | // Use this for initialization
53 | async void Start()
54 | {
55 | fpsMonitor = GetComponent();
56 |
57 | dlibShapePredictorFileName = DlibFaceLandmarkDetectorExample.dlibShapePredictorFileName;
58 |
59 | // Asynchronously retrieves the readable file path from the StreamingAssets directory.
60 | if (fpsMonitor != null)
61 | fpsMonitor.consoleText = "Preparing file access...";
62 |
63 | dlibShapePredictorFilePath = await Utils.getFilePathAsyncTask(dlibShapePredictorFileName, cancellationToken: cts.Token);
64 |
65 | if (fpsMonitor != null)
66 | fpsMonitor.consoleText = "";
67 |
68 | Run();
69 | }
70 |
71 | private void Run()
72 | {
73 | if (string.IsNullOrEmpty(dlibShapePredictorFilePath))
74 | {
75 | Debug.LogError("shape predictor file does not exist. Please copy from “DlibFaceLandmarkDetector/StreamingAssets/DlibFaceLandmarkDetector/” to “Assets/StreamingAssets/DlibFaceLandmarkDetector/” folder. ");
76 | }
77 |
78 | //if true, The error log of the Native side Dlib will be displayed on the Unity Editor Console.
79 | Utils.setDebugMode(true);
80 |
81 | Texture2D dstTexture2D = new Texture2D(texture2D.width, texture2D.height, texture2D.format, false);
82 | dstTexture2D.SetPixels32(texture2D.GetPixels32());
83 | dstTexture2D.Apply();
84 |
85 | FaceLandmarkDetector faceLandmarkDetector = new FaceLandmarkDetector(dlibShapePredictorFilePath);
86 | faceLandmarkDetector.SetImage(texture2D);
87 |
88 | //detect face rects
89 | List detectResult = faceLandmarkDetector.Detect();
90 |
91 |
92 | foreach (var rect in detectResult)
93 | {
94 | Debug.Log("face : " + rect);
95 |
96 | //detect landmark points
97 | List points = faceLandmarkDetector.DetectLandmark(rect);
98 |
99 | Debug.Log("face points count : " + points.Count);
100 | foreach (var point in points)
101 | {
102 | Debug.Log("face point : x " + point.x + " y " + point.y);
103 | }
104 |
105 | //draw landmark points
106 | faceLandmarkDetector.DrawDetectLandmarkResult(dstTexture2D, 0, 255, 0, 255);
107 |
108 | }
109 |
110 | if (faceLandmarkDetector.GetShapePredictorNumParts() != 68)
111 | Debug.LogWarning("The DrawDetectLandmarkResult method does not support ShapePredictorNumParts sizes other than 68 points, so the drawing will be incorrect."
112 | + " If you want to draw the result correctly, we recommend using the OpenCVForUnityUtils.DrawFaceLandmark method.");
113 |
114 | //draw face rect
115 | faceLandmarkDetector.DrawDetectResult(dstTexture2D, 255, 0, 0, 255, 2);
116 |
117 | faceLandmarkDetector.Dispose();
118 |
119 | resultPreview.texture = dstTexture2D;
120 | resultPreview.GetComponent().aspectRatio = (float)dstTexture2D.width / dstTexture2D.height;
121 |
122 |
123 | Utils.setDebugMode(false);
124 |
125 | if (fpsMonitor != null)
126 | {
127 | fpsMonitor.Add("dlib shape predictor", dlibShapePredictorFileName);
128 | fpsMonitor.Add("width", dstTexture2D.width.ToString());
129 | fpsMonitor.Add("height", dstTexture2D.height.ToString());
130 | fpsMonitor.Add("orientation", Screen.orientation.ToString());
131 | }
132 | }
133 |
134 | // Update is called once per frame
135 | void Update()
136 | {
137 |
138 | }
139 |
140 | ///
141 | /// Raises the disable event.
142 | ///
143 | void OnDisable()
144 | {
145 | if (cts != null)
146 | cts.Dispose();
147 | }
148 |
149 | ///
150 | /// Raises the back button click event.
151 | ///
152 | public void OnBackButtonClick()
153 | {
154 | SceneManager.LoadScene("DlibFaceLandmarkDetectorExample");
155 | }
156 | }
157 | }
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Texture2DExample/Texture2DExample.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f4d3f767ecb624f4bbc2e5a49c48fd0b
3 | timeCreated: 1461437970
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/DlibFaceLandmarkDetector/Examples/Texture2DExample/Texture2DExample.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 395c78d8a8e9cc54282ffbc365e28683
3 | timeCreated: 1461437970
4 | licenseType: Pro
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Utils.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7fea2866ce285cc4a816dee875af3c3f
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Utils/FpsMonitor.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e2a2cf2e440488b469909734cef79c8c
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/DlibFaceLandmarkDetector/Examples/Utils/FpsMonitor/FpsMonitor.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using UnityEngine;
3 | using UnityEngine.UI;
4 |
5 | namespace DlibFaceLandmarkDetectorExample
6 | {
7 | // v1.0.3
8 | public class FpsMonitor : MonoBehaviour
9 | {
10 | int tick = 0;
11 | float elapsed = 0;
12 | float fps = 0;
13 |
14 | public enum Alignment
15 | {
16 | LeftTop,
17 | RightTop,
18 | LeftBottom,
19 | RightBottom,
20 | }
21 |
22 | public Alignment alignment = Alignment.RightTop;
23 |
24 | const float GUI_WIDTH = 95f;
25 | const float GUI_HEIGHT = 35f;
26 | const float MARGIN_X = 10f;
27 | const float MARGIN_Y = 10f;
28 | const float INNER_X = 10f;
29 | const float INNER_Y = 10f;
30 | const float GUI_CONSOLE_HEIGHT = 100f;
31 |
32 | public Vector2 offset = new Vector2(MARGIN_X, MARGIN_Y);
33 | public bool boxVisible = true;
34 | public float boxWidth = GUI_WIDTH;
35 | public float boxHeight = GUI_HEIGHT;
36 | public Vector2 padding = new Vector2(INNER_X, INNER_Y);
37 | public float consoleHeight = GUI_CONSOLE_HEIGHT;
38 |
39 | private Text fpsTextComponent;
40 | private Text consoleTextComponent;
41 | private GameObject fpsPanel;
42 | private GameObject consolePanel;
43 | private Canvas canvas;
44 |
45 | Dictionary outputDict = new Dictionary();
46 |
47 | protected string _consoleText = null;
48 | public virtual string consoleText
49 | {
50 | get { return _consoleText; }
51 | set
52 | {
53 | _consoleText = value;
54 | toast_time = -1;
55 | UpdateConsoleText();
56 | }
57 | }
58 |
59 | float toast_time = -1; // Managed in milliseconds
60 |
61 | // Additional: Reference to the background Image GameObject
62 | private GameObject fpsBackgroundObj;
63 | private GameObject consoleBackgroundObj;
64 |
65 | private bool _needsUpdate = false;
66 | private bool _isInitialized = false;
67 |
68 | // Path to the prefab
69 | private const string CANVAS_PREFAB_PATH = "FpsMonitorCanvas_103";
70 |
71 | // Lifecycle methods
72 | void Awake()
73 | {
74 | LoadCanvasFromPrefab();
75 | LocateUI();
76 | _isInitialized = true;
77 | _needsUpdate = true;
78 | }
79 |
80 | void LoadCanvasFromPrefab()
81 | {
82 | // Load Canvas from Prefab
83 | GameObject prefab = Resources.Load(CANVAS_PREFAB_PATH);
84 | if (prefab == null)
85 | {
86 | Debug.LogError($"Failed to load FpsMonitorCanvas prefab from {CANVAS_PREFAB_PATH}");
87 | return;
88 | }
89 |
90 | // Instantiate Canvas
91 | GameObject canvasObj = Instantiate(prefab);
92 | // Set the name to the part before the first underscore (if any)
93 | int underscoreIndex = prefab.name.IndexOf('_');
94 | if (underscoreIndex > 0)
95 | canvasObj.name = prefab.name.Substring(0, underscoreIndex);
96 | else
97 | canvasObj.name = prefab.name;
98 | canvas = canvasObj.GetComponent