2014-10-22 3 views
0

저는 두 가지 라이브러리를 서로 다른 기능을 허용했기 때문에 지금까지 도약 모션 프로젝트로 사용할 수있었습니다. 그러나 여러 라이브러리가 문제를 일으키기 때문에 하나의 라이브러리 만 사용하고 싶습니다.도약 동작 - 처리 - 제스처 방향을 스 와이프 하시겠습니까?

기본적으로 나는 Michael Heuer의 Leap Motion을 사용하고 있습니다. (현재이 라이브러리는 필자가 찾을 수있는 유일한 라이브러리이기 때문에 hmd와 scale factor를 최적화 할 수 있습니다.)

제스처 구현은 다음과 같습니다. 여기에서 스 와이프 방향을 가져 오는 방법이 있습니까?

void onInit(final Controller controller) 
{ 
    controller.enableGesture(Gesture.Type.TYPE_SWIPE); 
    // enable top mounted policy 
    controller.setPolicyFlags(Controller.PolicyFlag.POLICY_OPTIMIZE_HMD); 
} 

void onFrame(final Controller controller) 
{ 
    Frame frame = controller.frame(); 
    for (Gesture gesture : frame.gestures()) 
    { 
     if ("TYPE_SWIPE".equals(gesture.type().toString()) && "STATE_START".equals(gesture.state().toString())) { 
    } 

    println("gesture " + gesture + " id " + gesture.id() + " type " + gesture.type() + " state " + gesture.state() + " duration " + gesture.duration() + " durationSeconds " + gesture.durationSeconds()); 

} 
} 

gesture.direction()을 시도해 보았지만 작동하지 않을 수도 있지만 방향은 인식 된 기능이 아닙니다.

은 어떤 도움이 많이 감사합니다! 미리 감사드립니다! Will

답변

0
import com.leapmotion.leap.Controller; 
import com.leapmotion.leap.Frame; 
import com.leapmotion.leap.Gesture; 
import com.leapmotion.leap.Hand; 
import com.leapmotion.leap.HandList; 
import com.leapmotion.leap.processing.LeapMotion; 
import com.leapmotion.leap.SwipeGesture; 
import com.leapmotion.leap.Vector; 

LeapMotion leapMotion; 

void setup() 
{ 
    size(16 * 50, 9 * 50); 
    background(20); 

    leapMotion = new LeapMotion(this); 
} 

void draw() 
{ 
    fill(20); 
    rect(0, 0, width, height); 
} 

void onInit(final Controller controller) 
{ 
    controller.enableGesture(Gesture.Type.TYPE_SWIPE); 
    // enable top mounted policy 
    //controller.setPolicyFlags(Controller.PolicyFlag.POLICY_OPTIMIZE_HMD); 
} 

void onFrame(final Controller controller) 
{ 
    Frame frame = controller.frame(); 
    for (Gesture gesture : frame.gestures()) 
    { 

if(gesture.type() == Gesture.Type.TYPE_SWIPE) { 
    SwipeGesture swipeGesture = new SwipeGesture(gesture); 

    Vector swipeVector = swipeGesture.direction(); 
    println("swipeVector : " + swipeVector); 

    float swipeDirection = swipeVector.getX(); 
    println(swipeDirection); 
    } 
} 

    HandList hands = frame.hands(); 
    //println(hands.count()); 
} 

나중에 참조 할 수 있도록이 정보는 다른 사람을 도울 수 있습니다.

+0

안녕하세요. [기여한 도서관] (https://developer.leapmotion.com/gallery/category/processing) 개발자입니다. 스 와이프 방향은 자연스럽게 요구됩니다. 그래서 나는 그 기능으로 라이브러리를 구현하고 업데이트 할 것이다. 그 후에 나는 짧은 코멘트와 함께 당신에게 여기에서 통지 할 것이다. –

0

먼저 Leap Motion 라이브러리를 Processing에서 직접 사용할 수 있습니다.

SwipeGesture swipe = SwipeGesture(gesture); 

제스처 기본 클래스는 모든 동작에 기능/일반 속성을 정의합니다

둘째, 당신은 방향() 함수를 액세스하기 위해 SwipeGesture의 인스턴스로 제스처 개체를 얻을 필요가있다. 이것이 Leap Motion API에서 작동하는 방법입니다. 그것은 아마도 당신이 사용하고있는 wrapper 라이브러리에서 같은 방식으로 작동합니다.

+0

답장을 보내 주셔서 감사합니다. 도약 모션 라이브러리에 직접 액세스 할 수 있습니다. (나는 이것을 어떻게하는지 조금 확신 할 수 없다.) 나는 두껍게 느껴질 수도 있지만 실제로 코드에서 구현하는 법을 배울 수 없다. 위의 코드와 통합하는 것이 가능 할까? –

+0

죄송합니다 내 마지막 코멘트를 무시합니다. 나는 그걸 가져 와서 스 와이프 방향을 얻었지만 내 문제는 이제 swipe.direction()이 Vector를 반환하고 PVector에 그것을 저장하려고 할 때 분명히 x 좌표를 잡으려고합니다. 작동하지 않습니다 및 오류 '벡터를 PVector 수 변환 할 수 없다', 나는 java.utils 가져 오기 및 벡터에 저장 시도하지만 내가 이것을 할 때 '벡터 벡터로 변환 할 수 없습니다' –

+0

다시 : 위의 의견을 무시, 나는 지금있다 해결 된 코드를 아래에 게시 할 것입니다, 올바른 방향으로 나를 가리켜 주셔서 감사합니다! –