3. 립모션에서 손의 특징 얻기 / 립모션에서 손의 정보 얻기 / 립모션에서 손의 데이터 얻기
-
isRight, isLeft — Whether the hand is a left or a right hand.
-
Palm Position — The center of the palm measured in millimeters from the Leap Motion origin.
-
Palm Velocity — The speed and movement direction of the palm in millimeters per second.
-
Palm Normal — A vector perpendicular to the plane formed by the palm of the hand. The vector points downward out of the palm.
-
Direction — A vector pointing from the center of the palm toward the fingers.
-
grabStrength, pinchStrength — Describe the posture of the hand.
-
Motion factors — Provide relative scale, rotation, and translation factors for movement between two frames.
-
==================================== 한국어 해석
-
isRight, isLeft— 손이 왼손인지 오른손인지.
-
Palm Position — Leap Motion 원점에서 밀리미터 단위로 측정 한 손바닥 중심.
-
Palm Velocity — 초당 밀리미터 단위의 손바닥 속도 및 이동 방향.
-
Palm Normal— 손바닥으로 형성된 평면에 수직 인 벡터. 벡터는 손바닥에서 아래쪽을 가리 킵니다.
-
Direction — 손바닥 중앙에서 손가락을 가리키는 벡터입니다.
-
grabStrength, pinchStrength- 손의 자세를 설명하십시오.
-
Motion factors — 두 프레임 사이의 이동에 대한 상대 배율, 회전 및 평행 이동 계수를 제공합니다.
Hand hand = frame.Hands[0];
Vector position = hand.PalmPosition;
Vector velocity = hand.PalmVelocity;
Vector direction = hand.Direction;
4. 손가락 얻기
List<Finger> fingers = hand.Fingers;
5. 손 좌표 얻기
Frame frame = controller.Frame();
for (int h = 0; h < frame.Hands.Count; h++)
{
Hand leapHand = frame.Hands[h];
Vector handXBasis = leapHand.PalmNormal.Cross(leapHand.Direction).Normalized;
Debug.Log("handXBasis : " + handXBasis);
Vector handYBasis = -leapHand.PalmNormal;
Debug.Log("handYBasis : " + handYBasis);
Vector handZBasis = -leapHand.Direction;
Debug.Log("handZBasis : " + handZBasis);
Vector handOrigin = leapHand.PalmPosition;
Debug.Log("handOrigin : " + handOrigin);
Matrix handTransform = new Matrix(handXBasis, handYBasis, handZBasis, handOrigin);
Debug.Log("handTransform : " + handTransform);
handTransform = handTransform.RigidInverse();
}
handXBasis : X축으로 이동할 때의 좌표 제공
handYBasis : Y축으로 이동할 때의 좌표 제공
handZBasis : Z축으로 이동할 때의 좌표 제공
handOrigin : 기본 X, Y, Z 좌표 제공
-> X : 오른쪽으로 이동시에 + 왼쪽으로 이동시 -
-> Y : 위로 이동시에 + 아래로 이동시에 -
-> Z : 사용자 몸 쪽으로 이동 시에 + 사용자와 멀어질 수록 -
< 오브젝트 사라지게 하는 제스처와 손 접힘으로 오브젝트 색 바꾸기 >
handOrigin X 좌표와 속도를 이용하여 휘두르는 모션 인식
손 잡고 피고를 통해서 색 바꾸기
관련 코드 :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Leap;
public class gesture : MonoBehaviour
{
Controller controller;
List<float> mo = new List<float>();
public GameObject cube;
bool DTtime = false;
float HandPalmPitch;
int num = 0;
void Start()
{
mo.Clear();
controller = new Controller();
}
void Update()
{
if (controller.IsConnected)
{
Frame frame = controller.Frame(); //The latest frame
Frame previous = controller.Frame(1); //The previous frame
for (int h = 0; h < frame.Hands.Count; h++)
{
Hand leapHand = frame.Hands[0];
Hand previous_leapHand = previous.Hands[0];
Vector handOrigin = leapHand.PalmPosition;
Vector previoushandOrigin = previous_leapHand.PalmPosition;
HandPalmPitch = leapHand.PalmNormal.Pitch;
if (System.Math.Abs(handOrigin.x - previoushandOrigin.x) > 5 && System.Math.Abs(leapHand.PalmVelocity.x) > 30)
{
Debug.Log("휘두름");
mo.Add(1);
int lastcount = mo.Count;
if(mo[lastcount-2] != mo[lastcount-1])
{
if (cube.activeSelf == true)
{
//Debug.Log("사라지게");
cube.SetActive(false);
}
else
{
//Debug.Log("생기게");
cube.SetActive(true);
}
}
}
else
{
mo.Add(0);
}
}
}
}
public void PrintActivateMessage()
{
print("A");
}
public void PrintDeactivateMessage()
{
if(HandPalmPitch > 1.4f)
{
Color[] co = new Color[3];
co[0] = Color.red;
co[1] = Color.blue;
co[2] = Color.green;
cube.GetComponent<MeshRenderer>().material.color = co[num % 3];
num++;
}
}
}
결과 동영상 : https://youtu.be/MP2wtTIYAdo
참고 사이트 :
https://developer-archive.leapmotion.com/documentation/csharp/devguide/Leap_Hand.html
Hands — Leap Motion C# SDK v3.2 Beta documentation
Hands Hands are the main entity tracked by the Leap Motion controller. The controller maintains an inner model of the human hand and validates the data from its sensors against this model. This allows the controller to track finger positions even when a fi
developer-archive.leapmotion.com
https://developer-archive.leapmotion.com/documentation/csharp/devguide/Leap_Frames.html#id533
Frames — Leap Motion C# SDK v3.2 Beta documentation
The Leap Motion API presents motion tracking data to your application as a series of snapshots called frames. Each frame of tracking data contains the measured positions and other information about each entity detected in that snapshot. This article discus
developer-archive.leapmotion.com
'Project' 카테고리의 다른 글
[unity + leap motion project] 립모션 제스처 만들기 프로젝트 4번째 정리 (0) | 2020.03.25 |
---|---|
[unity + leap motion project] 립모션 제스처 만들기 프로젝트 3번째 정리 (0) | 2020.03.23 |
[unity + leap motion project] 립모션 제스처 만들기 프로젝트 1번째 정리 (1) | 2020.03.16 |
[3D MAX] 2019-1 3D 모델링 프로젝트 (0) | 2020.03.14 |
수화 인식 프로젝트 - [7일차] 5일차 + convex Defects (openCV) (2) | 2020.03.09 |
댓글