This commit is contained in:
EnoxSoftware 2017-02-07 05:04:40 +09:00
Родитель d72f21dbad
Коммит 67be94b220
102 изменённых файлов: 296 добавлений и 391 удалений

Просмотреть файл

Просмотреть файл

Просмотреть файл

Двоичные данные
FaceMaskExample/ReadMe.pdf Normal file

Двоичный файл не отображается.

Просмотреть файл

Просмотреть файл

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 3.8 KiB

После

Ширина:  |  Высота:  |  Размер: 3.8 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 127 KiB

После

Ширина:  |  Высота:  |  Размер: 127 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 126 KiB

После

Ширина:  |  Высота:  |  Размер: 126 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 148 KiB

После

Ширина:  |  Высота:  |  Размер: 148 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 112 KiB

После

Ширина:  |  Высота:  |  Размер: 112 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 134 KiB

После

Ширина:  |  Высота:  |  Размер: 134 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.4 MiB

После

Ширина:  |  Высота:  |  Размер: 1.4 MiB

Просмотреть файл

Просмотреть файл

@ -259,7 +259,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 1039786616}
m_HandleRect: {fileID: 1039786615}
m_Direction: 2
m_Value: 0
m_Value: 1
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:
@ -420,7 +420,7 @@ GameObject:
- 114: {fileID: 542799653}
- 114: {fileID: 542799652}
m_Layer: 5
m_Name: VideoCaptureFaceMaskSample
m_Name: VideoCaptureFaceMaskExample
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -505,7 +505,7 @@ MonoBehaviour:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 96283525}
m_MethodName: OnVideoCaptureFaceMaskSample
m_MethodName: OnVideoCaptureFaceMaskExample
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
@ -1021,7 +1021,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: WebCamTextureFaceMaskSample
m_Text: WebCamTextureFaceMaskExample
--- !u!222 &1097508686
CanvasRenderer:
m_ObjectHideFlags: 0
@ -1090,7 +1090,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: VideoCaptureFaceMaskSample
m_Text: VideoCaptureFaceMaskExample
--- !u!222 &1149847641
CanvasRenderer:
m_ObjectHideFlags: 0
@ -1159,7 +1159,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Texture2DFaceMaskSample
m_Text: Texture2DFaceMaskExample
--- !u!222 &1266655929
CanvasRenderer:
m_ObjectHideFlags: 0
@ -1348,7 +1348,7 @@ GameObject:
- 114: {fileID: 1718137807}
- 114: {fileID: 1718137806}
m_Layer: 5
m_Name: WebCamTextureFaceMaskSample
m_Name: WebCamTextureFaceMaskExample
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -1433,7 +1433,7 @@ MonoBehaviour:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 96283525}
m_MethodName: OnWebCamTextureFaceMaskSample
m_MethodName: OnWebCamTextureFaceMaskExample
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
@ -1488,7 +1488,7 @@ GameObject:
- 114: {fileID: 1775689016}
- 114: {fileID: 1775689015}
m_Layer: 5
m_Name: Texture2DFaceMaskSample
m_Name: Texture2DFaceMaskExample
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -1573,7 +1573,7 @@ MonoBehaviour:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 96283525}
m_MethodName: OnTexture2DFaceMaskSample
m_MethodName: OnTexture2DFaceMaskExample
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -3,9 +3,9 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace FaceMaskSample
namespace FaceMaskExample
{
public static class SampleDataSet
public static class ExampleDataSet
{
private static int index = 0;
public static int Index
@ -193,12 +193,12 @@ namespace FaceMaskSample
}
};
public static SampleMaskData GetData(){
return new SampleMaskData(filenames[index], faceRcts[index], landmarkPoints[index]);
public static ExampleMaskData GetData(){
return new ExampleMaskData(filenames[index], faceRcts[index], landmarkPoints[index]);
}
public static SampleMaskData GetData(int index){
return new SampleMaskData(filenames[index], faceRcts[index], landmarkPoints[index]);
public static ExampleMaskData GetData(int index){
return new ExampleMaskData(filenames[index], faceRcts[index], landmarkPoints[index]);
}
public static void Next(){
@ -208,7 +208,7 @@ namespace FaceMaskSample
}
}
public class SampleMaskData
public class ExampleMaskData
{
private string filename;
public string FileName
@ -228,7 +228,7 @@ namespace FaceMaskSample
get { return this.landmarkPoints; }
}
public SampleMaskData(string filename, Rect faceRect, List<Vector2> landmarkPoints){
public ExampleMaskData(string filename, Rect faceRect, List<Vector2> landmarkPoints){
this.filename = filename;
this.faceRect = faceRect;
this.landmarkPoints = landmarkPoints;

Просмотреть файл

@ -5,12 +5,12 @@ using System.Collections;
using UnityEngine.SceneManagement;
#endif
namespace FaceMaskSample
namespace FaceMaskExample
{
/// <summary>
/// Face mask sample.
/// Face mask example.
/// </summary>
public class FaceMaskSample : MonoBehaviour
public class FaceMaskExample : MonoBehaviour
{
// Use this for initialization
@ -34,30 +34,30 @@ namespace FaceMaskSample
#endif
}
public void OnTexture2DFaceMaskSample ()
public void OnTexture2DFaceMaskExample ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("Texture2DFaceMaskSample");
SceneManager.LoadScene ("Texture2DFaceMaskExample");
#else
Application.LoadLevel ("Texture2DFaceMaskSample");
Application.LoadLevel ("Texture2DFaceMaskExample");
#endif
}
public void OnVideoCaptureFaceMaskSample ()
public void OnVideoCaptureFaceMaskExample ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("VideoCaptureFaceMaskSample");
SceneManager.LoadScene ("VideoCaptureFaceMaskExample");
#else
Application.LoadLevel ("VideoCaptureFaceMaskSample");
Application.LoadLevel ("VideoCaptureFaceMaskExample");
#endif
}
public void OnWebCamTextureFaceMaskSample ()
public void OnWebCamTextureFaceMaskExample ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("WebCamTextureFaceMaskSample");
SceneManager.LoadScene ("WebCamTextureFaceMaskExample");
#else
Application.LoadLevel ("WebCamTextureFaceMaskSample");
Application.LoadLevel ("WebCamTextureFaceMaskExample");
#endif
}
}

Просмотреть файл

@ -2,7 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
namespace FaceMaskSample
namespace FaceMaskExample
{
public class ObjectPool : MonoBehaviour
{
@ -88,7 +88,7 @@ namespace FaceMaskSample
{
GameObject obj = (GameObject)GameObject.Instantiate(prefab);
obj.SetActive(true);
obj.transform.parent = parent;
obj.transform.SetParent(parent, false);
pooledObjectList.Add(obj);
return obj;
}

Просмотреть файл

@ -1,7 +1,7 @@
using System;
using UnityEngine;
namespace FaceMaskSample
namespace FaceMaskExample
{
[RequireComponent(typeof(MeshRenderer), typeof(MeshFilter), typeof(MeshCollider))]
public class TrackedMesh : MonoBehaviour
@ -50,6 +50,7 @@ namespace FaceMaskSample
throw new Exception("Material does not exist.");
material = meshRenderer.material;
meshRenderer.sortingOrder = 32767;
}
void OnDestroy(){

Просмотреть файл

@ -3,7 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
using OpenCVForUnity.RectangleTrack;
namespace FaceMaskSample
namespace FaceMaskExample
{
public class TrackedMeshOverlay : MonoBehaviour
{
@ -69,7 +69,7 @@ namespace FaceMaskSample
GameObject newObj = objectPool.GetInstance(parent);
if(newObj != null){
newObj.transform.parent = parent;
newObj.transform.SetParent(parent, false);
return newObj;
}else{
return null;
@ -81,7 +81,6 @@ namespace FaceMaskSample
GameObject obj = new GameObject(name);
overlayTransform = obj.transform;
overlayTransform.parent = gameObject.transform.parent;
UpdateOverlayTransform();
if(baseObject != null)
setBaseObject (baseObject);
@ -113,23 +112,13 @@ namespace FaceMaskSample
this.targetTransform = null;
return;
}
targetWidth = targetTransform.localScale.x;
targetHeight = targetTransform.localScale.y;
this.targetTransform = targetTransform;
overlayTransform.localPosition = new Vector3(targetTransform.localPosition.x, targetTransform.localPosition.y, targetTransform .localPosition.z - 0.1f);
}
public virtual void UpdateOverlayTransform()
{
Renderer renderer = gameObject.GetComponent<Renderer>();
if(renderer == null) return;
targetWidth = renderer.bounds.size.x;
targetHeight = renderer.bounds.size.y;
Vector3 center = renderer.bounds.center;
Debug.Log(targetWidth + " " + targetHeight + " " + center);
overlayTransform.localPosition = new Vector3(center.x, center.y, center.z - 0.1f);
overlayTransform.localPosition = targetTransform.localPosition;
overlayTransform.localRotation = targetTransform.localRotation;
overlayTransform.localScale = targetTransform.localScale;
}
public virtual TrackedMesh GetObjectById(int id)
@ -150,10 +139,14 @@ namespace FaceMaskSample
if (tm != null)
{
tm.Id = id;
tm.transform.localPosition = new Vector3(0, 0, 0);
tm.transform.localPosition = Vector3.zero;
tm.transform.localRotation = new Quaternion();
tm.transform.localScale = new Vector3(1, 1, 1);
if (tex != null) tm.Material.mainTexture = tex;
tm.transform.localScale = Vector3.one;
if (tex != null)
{
Renderer tmRenderer = tm.transform.GetComponent<Renderer>();
tmRenderer.sharedMaterial.SetTexture ("_MainTex", tex);
}
showingObjects.Add(id, tm);
}
return tm;

Просмотреть файл

@ -5,7 +5,7 @@ using System.Collections;
using UnityEngine.SceneManagement;
#endif
namespace FaceMaskSample
namespace FaceMaskExample
{
/// <summary>
@ -29,9 +29,9 @@ namespace FaceMaskSample
public void OnBackButton ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("FaceMaskSample");
SceneManager.LoadScene ("FaceMaskExample");
#else
Application.LoadLevel ("FaceMaskSample");
Application.LoadLevel ("FaceMaskExample");
#endif
}
}

Просмотреть файл

@ -12,12 +12,12 @@ using WebGLFileUploader;
using UnityEngine.SceneManagement;
#endif
namespace FaceMaskSample
namespace FaceMaskExample
{
/// <summary>
/// Texture2D face mask sample.
/// Texture2D face mask example.
/// </summary>
public class Texture2DFaceMaskSample : MonoBehaviour
public class Texture2DFaceMaskExample : MonoBehaviour
{
/// <summary>
@ -153,7 +153,7 @@ namespace FaceMaskSample
gameObject.transform.localScale = new Vector3 (imgTexture.width, imgTexture.height, 1);
Debug.Log ("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
meshOverlay.UpdateOverlayTransform ();
meshOverlay.UpdateOverlayTransform (gameObject.transform);
meshOverlay.Reset ();
@ -194,7 +194,7 @@ namespace FaceMaskSample
if (cascade == null)
cascade = new CascadeClassifier (haarcascade_frontalface_alt_xml_filepath);
if (cascade.empty ()) {
Debug.LogError ("cascade file is not loaded.Please copy from “FaceTrackerSample/StreamingAssets/” to “Assets/StreamingAssets/” folder. ");
Debug.LogError ("cascade file is not loaded.Please copy from “FaceTrackerExample/StreamingAssets/” to “Assets/StreamingAssets/” folder. ");
}
// convert image to greyscale.
@ -238,8 +238,8 @@ namespace FaceMaskSample
}
face_nums = face_nums.OrderBy (i => System.Guid.NewGuid ()).ToArray ();
float offsetX = meshOverlay.Width / 2f;
float offsetY = meshOverlay.Height / 2f;
float imageWidth = meshOverlay.Width;
float imageHeight = meshOverlay.Height;
float maskImageWidth = imgTexture.width;
float maskImageHeight = imgTexture.height;
@ -252,8 +252,8 @@ namespace FaceMaskSample
Vector3[] vertices = tm.MeshFilter.mesh.vertices;
if (vertices.Length == landmarkPoints [face_nums [i]].Count) {
for (int j = 0; j < vertices.Length; j++) {
vertices [j].x = landmarkPoints [face_nums [i]] [j].x - offsetX;
vertices [j].y = offsetY - landmarkPoints [face_nums [i]] [j].y;
vertices [j].x = landmarkPoints [face_nums [i]] [j].x / imageWidth - 0.5f;
vertices [j].y = 0.5f - landmarkPoints [face_nums [i]] [j].y / imageHeight;
}
}
Vector2[] uv = tm.MeshFilter.mesh.uv;
@ -324,9 +324,9 @@ namespace FaceMaskSample
public void OnBackButton ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("FaceMaskSample");
SceneManager.LoadScene ("FaceMaskExample");
#else
Application.LoadLevel ("FaceMaskSample");
Application.LoadLevel ("FaceMaskExample");
#endif
}

Просмотреть файл

Просмотреть файл

@ -4,7 +4,7 @@ using System.Collections.Generic;
using UnityEngine;
using OpenCVForUnity;
namespace FaceMaskSample
namespace FaceMaskExample
{
public class FrontalFaceParam : IDisposable
{

Просмотреть файл

@ -1,97 +1,97 @@
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
using OpenCVForUnity;
using DlibFaceLandmarkDetector;
namespace FaceMaskSample
{
/// <summary>
/// Utility class for the integration of DlibFaceLandmarkDetector and OpenCVForUnity.
/// </summary>
public static class OpenCVForUnityUtils
{
/// <summary>
/// Sets the image.
/// </summary>
/// <param name="faceLandmarkDetector">Face landmark detector.</param>
/// <param name="imgMat">Image mat.</param>
public static void SetImage (FaceLandmarkDetector faceLandmarkDetector, Mat imgMat)
{
if (!imgMat.isContinuous ()) {
throw new ArgumentException ("imgMat.isContinuous() must be true.");
}
faceLandmarkDetector.SetImage ((IntPtr)imgMat.dataAddr (), imgMat.width (), imgMat.height (), (int)imgMat.elemSize ());
}
/// <summary>
/// Draws the face rect.
/// </summary>
/// <param name="imgMat">Image mat.</param>
/// <param name="rect">Rect.</param>
/// <param name="color">Color.</param>
/// <param name="thickness">Thickness.</param>
public static void DrawFaceRect (Mat imgMat, UnityEngine.Rect rect, Scalar color, int thickness)
{
Imgproc.rectangle (imgMat, new Point (rect.xMin, rect.yMin), new Point (rect.xMax, rect.yMax), color, thickness);
}
/// <summary>
/// Draws the face landmark.
/// This method supports 68 landmark points.
/// </summary>
/// <param name="imgMat">Image mat.</param>
/// <param name="points">Points.</param>
/// <param name="color">Color.</param>
/// <param name="thickness">Thickness.</param>
public static void DrawFaceLandmark (Mat imgMat, List<Vector2> points, Scalar color, int thickness)
{
// //Draw the index number of facelandmark points.
// for (int i = 0; i < points.Count; i++) {
//
// Imgproc.putText (imgMat, "" + i, new Point (points [i].x, points [i].y), Core.FONT_HERSHEY_SIMPLEX, 0.4, new Scalar (0, 0, 255, 255), 1, Core.LINE_AA, false);
//
// }
if (points.Count == 68) {
for (int i = 1; i <= 16; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
for (int i = 28; i <= 30; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
for (int i = 18; i <= 21; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
for (int i = 23; i <= 26; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
for (int i = 31; i <= 35; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
Imgproc.line (imgMat, new Point (points [30].x, points [30].y), new Point (points [35].x, points [35].y), color, thickness);
for (int i = 37; i <= 41; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
Imgproc.line (imgMat, new Point (points [36].x, points [36].y), new Point (points [41].x, points [41].y), color, thickness);
for (int i = 43; i <= 47; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
Imgproc.line (imgMat, new Point (points [42].x, points [42].y), new Point (points [47].x, points [47].y), color, thickness);
for (int i = 49; i <= 59; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
Imgproc.line (imgMat, new Point (points [48].x, points [48].y), new Point (points [59].x, points [59].y), color, thickness);
for (int i = 61; i <= 67; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
Imgproc.line (imgMat, new Point (points [60].x, points [60].y), new Point (points [67].x, points [67].y), color, thickness);
} else {
for (int i = 0; i < points.Count; i++) {
Imgproc.circle (imgMat, new Point (points [i].x, points [i].y), 2, color, -1);
}
}
}
}
}
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
using OpenCVForUnity;
using DlibFaceLandmarkDetector;
namespace FaceMaskExample
{
/// <summary>
/// Utility class for the integration of DlibFaceLandmarkDetector and OpenCVForUnity.
/// </summary>
public static class OpenCVForUnityUtils
{
/// <summary>
/// Sets the image.
/// </summary>
/// <param name="faceLandmarkDetector">Face landmark detector.</param>
/// <param name="imgMat">Image mat.</param>
public static void SetImage (FaceLandmarkDetector faceLandmarkDetector, Mat imgMat)
{
if (!imgMat.isContinuous ()) {
throw new ArgumentException ("imgMat.isContinuous() must be true.");
}
faceLandmarkDetector.SetImage ((IntPtr)imgMat.dataAddr (), imgMat.width (), imgMat.height (), (int)imgMat.elemSize ());
}
/// <summary>
/// Draws the face rect.
/// </summary>
/// <param name="imgMat">Image mat.</param>
/// <param name="rect">Rect.</param>
/// <param name="color">Color.</param>
/// <param name="thickness">Thickness.</param>
public static void DrawFaceRect (Mat imgMat, UnityEngine.Rect rect, Scalar color, int thickness)
{
Imgproc.rectangle (imgMat, new Point (rect.xMin, rect.yMin), new Point (rect.xMax, rect.yMax), color, thickness);
}
/// <summary>
/// Draws the face landmark.
/// This method supports 68 landmark points.
/// </summary>
/// <param name="imgMat">Image mat.</param>
/// <param name="points">Points.</param>
/// <param name="color">Color.</param>
/// <param name="thickness">Thickness.</param>
public static void DrawFaceLandmark (Mat imgMat, List<Vector2> points, Scalar color, int thickness)
{
// //Draw the index number of facelandmark points.
// for (int i = 0; i < points.Count; i++) {
//
// Imgproc.putText (imgMat, "" + i, new Point (points [i].x, points [i].y), Core.FONT_HERSHEY_SIMPLEX, 0.4, new Scalar (0, 0, 255, 255), 1, Core.LINE_AA, false);
//
// }
if (points.Count == 68) {
for (int i = 1; i <= 16; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
for (int i = 28; i <= 30; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
for (int i = 18; i <= 21; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
for (int i = 23; i <= 26; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
for (int i = 31; i <= 35; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
Imgproc.line (imgMat, new Point (points [30].x, points [30].y), new Point (points [35].x, points [35].y), color, thickness);
for (int i = 37; i <= 41; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
Imgproc.line (imgMat, new Point (points [36].x, points [36].y), new Point (points [41].x, points [41].y), color, thickness);
for (int i = 43; i <= 47; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
Imgproc.line (imgMat, new Point (points [42].x, points [42].y), new Point (points [47].x, points [47].y), color, thickness);
for (int i = 49; i <= 59; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
Imgproc.line (imgMat, new Point (points [48].x, points [48].y), new Point (points [59].x, points [59].y), color, thickness);
for (int i = 61; i <= 67; ++i)
Imgproc.line (imgMat, new Point (points [i].x, points [i].y), new Point (points [i - 1].x, points [i - 1].y), color, thickness);
Imgproc.line (imgMat, new Point (points [60].x, points [60].y), new Point (points [67].x, points [67].y), color, thickness);
} else {
for (int i = 0; i < points.Count; i++) {
Imgproc.circle (imgMat, new Point (points [i].x, points [i].y), 2, color, -1);
}
}
}
}
}

Просмотреть файл

@ -4,7 +4,7 @@ using System.Collections;
using UnityEngine;
using UnityEngine.Events;
namespace FaceMaskSample
namespace FaceMaskExample
{
/// <summary>
/// Web cam texture to mat helper.

Просмотреть файл

@ -12,12 +12,12 @@ using WebGLFileUploader;
using UnityEngine.SceneManagement;
#endif
namespace FaceMaskSample
namespace FaceMaskExample
{
/// <summary>
/// Face Mask from VideoCapture Sample.
/// Face Mask from videoCapture example.
/// </summary>
public class VideoCaptureFaceMaskSample : MonoBehaviour
public class VideoCaptureFaceMaskExample : MonoBehaviour
{
/// <summary>
/// The width of the frame.
@ -253,13 +253,13 @@ namespace FaceMaskSample
gameObject.GetComponent<Renderer> ().material.mainTexture = texture;
meshOverlay.UpdateOverlayTransform ();
meshOverlay.UpdateOverlayTransform (gameObject.transform);
grayMat = new Mat ((int)frameHeight, (int)frameWidth, CvType.CV_8UC1);
cascade = new CascadeClassifier (haarcascade_frontalface_alt_xml_filepath);
if (cascade.empty ()) {
Debug.LogError ("cascade file is not loaded.Please copy from “FaceTrackerSample/StreamingAssets/” to “Assets/StreamingAssets/” folder. ");
Debug.LogError ("cascade file is not loaded.Please copy from “FaceTrackerExample/StreamingAssets/” to “Assets/StreamingAssets/” folder. ");
}
isShowingFaceRectsToggle.isOn = isShowingFaceRects;
@ -334,9 +334,9 @@ namespace FaceMaskSample
// face masking.
if (faceMaskTexture != null && landmarkPoints.Count >= 1) {
OpenCVForUnity.Utils.texture2DToMat (faceMaskTexture, faceMaskMat);
float offsetX = meshOverlay.Width / 2f;
float offsetY = meshOverlay.Height / 2f;
float imageWidth = meshOverlay.Width;
float imageHeight = meshOverlay.Height;
float maskImageWidth = faceMaskTexture.width;
float maskImageHeight = faceMaskTexture.height;
@ -354,8 +354,8 @@ namespace FaceMaskSample
Vector3[] vertices = tm.MeshFilter.mesh.vertices;
if (vertices.Length == landmarkPoints [i].Count) {
for (int j = 0; j < vertices.Length; j++) {
vertices [j].x = landmarkPoints [i] [j].x - offsetX;
vertices [j].y = offsetY - landmarkPoints [i] [j].y;
vertices [j].x = landmarkPoints [i] [j].x / imageWidth - 0.5f;
vertices [j].y = 0.5f - landmarkPoints [i] [j].y / imageHeight;
}
}
Vector2[] uv = tm.MeshFilter.mesh.uv;
@ -385,9 +385,9 @@ namespace FaceMaskSample
}
}
} else if (landmarkPoints.Count >= 1) {
float offsetX = meshOverlay.Width / 2f;
float offsetY = meshOverlay.Height / 2f;
float imageWidth = meshOverlay.Width;
float imageHeight = meshOverlay.Height;
float maskImageWidth = texture.width;
float maskImageHeight = texture.height;
@ -405,8 +405,8 @@ namespace FaceMaskSample
Vector3[] vertices = tm.MeshFilter.mesh.vertices;
if (vertices.Length == landmarkPoints [i].Count) {
for (int j = 0; j < vertices.Length; j++) {
vertices [j].x = landmarkPoints[i][j].x - offsetX;
vertices [j].y = offsetY - landmarkPoints[i][j].y;
vertices [j].x = landmarkPoints[i][j].x / imageWidth - 0.5f;
vertices [j].y = 0.5f - landmarkPoints[i][j].y / imageHeight;
}
}
Vector2[] uv = tm.MeshFilter.mesh.uv;
@ -520,9 +520,9 @@ namespace FaceMaskSample
public void OnBackButton ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("FaceMaskSample");
SceneManager.LoadScene ("FaceMaskExample");
#else
Application.LoadLevel ("FaceMaskSample");
Application.LoadLevel ("FaceMaskExample");
#endif
}
@ -581,7 +581,7 @@ namespace FaceMaskSample
{
removeFaceMask ();
SampleMaskData maskData = SampleDataSet.GetData();
ExampleMaskData maskData = ExampleDataSet.GetData();
faceMaskTexture = Resources.Load (maskData.FileName) as Texture2D;
faceMaskMat = new Mat (faceMaskTexture.height, faceMaskTexture.width, CvType.CV_8UC3);
@ -596,7 +596,7 @@ namespace FaceMaskSample
faceLandmarkPointsInMask = detectFaceLandmarkPoints (faceMaskMat, faceRectInMask);
}
SampleDataSet.Next();
ExampleDataSet.Next();
if (faceRectInMask.width == 0 && faceRectInMask.height == 0){
removeFaceMask ();

Просмотреть файл

@ -12,13 +12,13 @@ using WebGLFileUploader;
using UnityEngine.SceneManagement;
#endif
namespace FaceMaskSample
namespace FaceMaskExample
{
/// <summary>
/// WebCamTexture face mask sample.
/// WebCamTexture face mask example.
/// </summary>
[RequireComponent (typeof(WebCamTextureToMatHelper), typeof(TrackedMeshOverlay))]
public class WebCamTextureFaceMaskSample : MonoBehaviour
public class WebCamTextureFaceMaskExample : MonoBehaviour
{
/// <summary>
/// The colors.
@ -241,10 +241,10 @@ namespace FaceMaskSample
grayMat = new Mat (webCamTextureMat.rows (), webCamTextureMat.cols (), CvType.CV_8UC1);
cascade = new CascadeClassifier (haarcascade_frontalface_alt_xml_filepath);
if (cascade.empty ()) {
Debug.LogError ("cascade file is not loaded.Please copy from “FaceTrackerSample/StreamingAssets/” to “Assets/StreamingAssets/” folder. ");
Debug.LogError ("cascade file is not loaded.Please copy from “FaceTrackerExample/StreamingAssets/” to “Assets/StreamingAssets/” folder. ");
}
meshOverlay.UpdateOverlayTransform ();
meshOverlay.UpdateOverlayTransform (gameObject.transform);
OnChangeFaceMaskButton ();
}
@ -326,8 +326,8 @@ namespace FaceMaskSample
if (faceMaskTexture != null && landmarkPoints.Count >= 1) {
OpenCVForUnity.Utils.texture2DToMat (faceMaskTexture, faceMaskMat);
float offsetX = meshOverlay.Width / 2f;
float offsetY = meshOverlay.Height / 2f;
float imageWidth = meshOverlay.Width;
float imageHeight = meshOverlay.Height;
float maskImageWidth = faceMaskTexture.width;
float maskImageHeight = faceMaskTexture.height;
@ -345,8 +345,8 @@ namespace FaceMaskSample
Vector3[] vertices = tm.MeshFilter.mesh.vertices;
if (vertices.Length == landmarkPoints [i].Count) {
for (int j = 0; j < vertices.Length; j++) {
vertices [j].x = landmarkPoints [i] [j].x - offsetX;
vertices [j].y = offsetY - landmarkPoints [i] [j].y;
vertices [j].x = landmarkPoints [i] [j].x / imageWidth - 0.5f;
vertices [j].y = 0.5f - landmarkPoints [i] [j].y / imageHeight;
}
}
Vector2[] uv = tm.MeshFilter.mesh.uv;
@ -377,8 +377,8 @@ namespace FaceMaskSample
}
} else if (landmarkPoints.Count >= 1) {
float offsetX = meshOverlay.Width / 2f;
float offsetY = meshOverlay.Height / 2f;
float imageWidth = meshOverlay.Width;
float imageHeight = meshOverlay.Height;
float maskImageWidth = texture.width;
float maskImageHeight = texture.height;
@ -396,8 +396,8 @@ namespace FaceMaskSample
Vector3[] vertices = tm.MeshFilter.mesh.vertices;
if (vertices.Length == landmarkPoints [i].Count) {
for (int j = 0; j < vertices.Length; j++) {
vertices [j].x = landmarkPoints[i][j].x - offsetX;
vertices [j].y = offsetY - landmarkPoints[i][j].y;
vertices [j].x = landmarkPoints[i][j].x / imageWidth - 0.5f;
vertices [j].y = 0.5f - landmarkPoints[i][j].y / imageHeight;
}
}
Vector2[] uv = tm.MeshFilter.mesh.uv;
@ -511,9 +511,9 @@ namespace FaceMaskSample
public void OnBackButton ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("FaceMaskSample");
SceneManager.LoadScene ("FaceMaskExample");
#else
Application.LoadLevel ("FaceMaskSample");
Application.LoadLevel ("FaceMaskExample");
#endif
}
@ -596,7 +596,7 @@ namespace FaceMaskSample
{
removeFaceMask ();
SampleMaskData maskData = SampleDataSet.GetData();
ExampleMaskData maskData = ExampleDataSet.GetData();
faceMaskTexture = Resources.Load (maskData.FileName) as Texture2D;
faceMaskMat = new Mat (faceMaskTexture.height, faceMaskTexture.width, CvType.CV_8UC4);
@ -611,7 +611,7 @@ namespace FaceMaskSample
faceLandmarkPointsInMask = detectFaceLandmarkPoints (faceMaskMat, faceRectInMask);
}
SampleDataSet.Next();
ExampleDataSet.Next();
if (faceRectInMask.width == 0 && faceRectInMask.height == 0){
removeFaceMask ();
@ -622,7 +622,7 @@ namespace FaceMaskSample
//dumpVector2(faceLandmarkPointsInMask);
//dumpVector3(faceLandmarkPointsInMask);
//MeshFilter mf = createFaceMesh(faceMaskTexture.width, faceMaskTexture.height);
//ObjExporter.MeshToFile(mf, "Assets/FaceMaskSample/Resources/FaceMesh.obj");
//ObjExporter.MeshToFile(mf, "Assets/FaceMaskExample/Resources/FaceMesh.obj");
}
/// <summary>

Двоичные данные
FaceMaskSample/ReadMe.pdf

Двоичный файл не отображается.

Просмотреть файл

@ -1,4 +1,4 @@
FaceMask Sample
FaceMask Example
====================
Overview
@ -12,15 +12,15 @@ Demo Video
Demo
-----
- WebGL
<https://enoxsoftware.github.io/FaceMaskSample/webgl_sample/index.html>
<https://enoxsoftware.github.io/FaceMaskExample/webgl_example/index.html>
- WebGL(using shape_predictor_68_face_landmarks_for_mobile.dat)
<https://enoxsoftware.github.io/FaceMaskSample/webgl_sample_for_mobile/index.html>
<https://enoxsoftware.github.io/FaceMaskExample/webgl_example_for_mobile/index.html>
- Android
<https://play.google.com/store/apps/details?id=com.enoxsoftware.facemasksample>
<https://play.google.com/store/apps/details?id=com.enoxsoftware.facemaskexample>
Manual
-----
[ReadMe.pdf](/FaceMaskSample/ReadMe.pdf)
[ReadMe.pdf](/FaceMaskExample/ReadMe.pdf)

Просмотреть файл

Просмотреть файл

@ -7,12 +7,12 @@ using WebGLFileUploader;
using UnityEngine.SceneManagement;
#endif
namespace WebGLFileUploaderSample
namespace WebGLFileUploaderExample
{
/// <summary>
/// File Upload sample.
/// File Upload example.
/// </summary>
public class FileUploadSample : MonoBehaviour
public class FileUploadExample : MonoBehaviour
{
// Use this for initialization
@ -83,9 +83,9 @@ namespace WebGLFileUploaderSample
public void OnBackButton ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("WebGLFileUploaderSample");
SceneManager.LoadScene ("WebGLFileUploaderExample");
#else
Application.LoadLevel ("WebGLFileUploaderSample");
Application.LoadLevel ("WebGLFileUploaderExample");
#endif
}

Просмотреть файл

@ -5,7 +5,7 @@ using System.Collections;
using UnityEngine.SceneManagement;
#endif
namespace WebGLFileUploaderSample
namespace WebGLFileUploaderExample
{
public class ShowLicense : MonoBehaviour
{
@ -25,9 +25,9 @@ namespace WebGLFileUploaderSample
public void OnBackButton ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("WebGLFileUploaderSample");
SceneManager.LoadScene ("WebGLFileUploaderExample");
#else
Application.LoadLevel ("WebGLFileUploaderSample");
Application.LoadLevel ("WebGLFileUploaderExample");
#endif
}
}

Просмотреть файл

@ -8,12 +8,12 @@ using UnityEngine.SceneManagement;
#endif
using OpenCVForUnity;
namespace WebGLFileUploaderSample
namespace WebGLFileUploaderExample
{
/// <summary>
/// Texture2D to mat sample.
/// Texture2D to mat example.
/// </summary>
public class Texture2DToMatSample : MonoBehaviour
public class Texture2DToMatExample : MonoBehaviour
{
// Use this for initialization
@ -85,9 +85,9 @@ namespace WebGLFileUploaderSample
public void OnBackButton ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("WebGLFileUploaderSample");
SceneManager.LoadScene ("WebGLFileUploaderExample");
#else
Application.LoadLevel ("WebGLFileUploaderSample");
Application.LoadLevel ("WebGLFileUploaderExample");
#endif
}

Просмотреть файл

@ -5,9 +5,9 @@ using System.Collections;
using UnityEngine.SceneManagement;
#endif
namespace WebGLFileUploaderSample
namespace WebGLFileUploaderExample
{
public class WebGLFileUploaderSample : MonoBehaviour
public class WebGLFileUploaderExample : MonoBehaviour
{
// Use this for initialization
@ -31,21 +31,21 @@ namespace WebGLFileUploaderSample
#endif
}
public void OnFileUploadSample ()
public void OnFileUploadExample ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("FileUploadSample");
SceneManager.LoadScene ("FileUploadExample");
#else
Application.LoadLevel ("FileUploadSample");
Application.LoadLevel ("FileUploadExample");
#endif
}
public void OnTexture2DToMatSample ()
public void OnTexture2DToMatExample ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("Texture2DToMatSample");
SceneManager.LoadScene ("Texture2DToMatExample");
#else
Application.LoadLevel ("Texture2DToMatSample");
Application.LoadLevel ("Texture2DToMatExample");
#endif
}
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше