だから私はリープモーションSDKを学び、4〜5年でそれに触れなかった後、Pythonを再学習しようとしています.Python 2.7のジェネレーターで問題が発生しています.
基本的に私は単語のリストを持っており、リープモーションが新しい「円」ジェスチャーを拾うたびにリストの次の単語を出力したいと考えています。私が見ているのは、on_frame
コールバックが発生するたびに、リストの最初の単語だけが出力されるということです。起こっていることは、Python ランタイムがイベント間のジェネレーターの状態を忘れていることだと思います。ジェスチャ イベント間でジェネレータの状態を維持する方法はありますか?
if not frame.hands.is_empty:
for gesture in frame.gestures():
if gesture.type == Leap.Gesture.TYPE_CIRCLE:
circle = CircleGesture(gesture)
# Determine clock direction using the angle between the pointable and the circle normal
action = None
if circle.pointable.direction.angle_to(circle.normal) <= Leap.PI/4:
action = GestureActions.clockwiseCircleGesture()
else:
action = GestureActions.counterClockwiseCircleGesture()
print action.next()
def clockwiseCircleGesture():
words = ["You", "spin", "me", "right", "round", "baby", "right", "round", "like", "a", "record", "baby", "Right", "round", "round", "round", "You", "spin", "me", "right", "round", "baby", "Right", "round", "like", "a",
"record", "baby", "Right", "round", "round", "round"]
for word in words:
yield word
これについての洞察は素晴らしいでしょう。ありがとう