質問編集履歴
4
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
###期待結果
|
7
|
-
anaconda仮想環境
|
7
|
+
anaconda仮想環境python2.7
|
8
8
|
```python
|
9
9
|
・
|
10
10
|
・
|
3
title
CHANGED
File without changes
|
body
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
Traceback (most recent call last):
|
36
36
|
File "sample.py", line 37, in on_frame
|
37
|
-
for hand in frame.
|
37
|
+
for hand in frame.hands:
|
38
38
|
SystemError: <built-in function delete_HandList>returned a result with an error set
|
39
39
|
・
|
40
40
|
・
|
2
自分なりに進めていたら変更点があった
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,29 +1,144 @@
|
|
1
1
|
### 質問内容
|
2
|
-
OpenCVとLeap Motionを同時に使いたいのでpython3でLeap Motionを使えるように調べたところ「[Python3でLeap Motion](https://qiita.com/issakuss/items/39caec385f057b9c4ab3#comment-fed9cfd05ac37c9f9e80)」というサイトを発見しました。
|
2
|
+
OpenCVとLeap Motionを同時に使いたいのでpython3でLeap Motionを使えるように調べたところ「[Python3でLeap Motion](https://qiita.com/issakuss/items/39caec385f057b9c4ab3#comment-fed9cfd05ac37c9f9e80)」というサイトを発見しました。サイトの作成者の方に質問させていただいたり自分なりにやってみたりしたのですがよくわからないエラーが出てしまいました。
|
3
3
|
もしわかる方がいらっしゃったら解決していただきたいです。
|
4
4
|
|
5
5
|
|
6
|
-
###
|
6
|
+
###期待結果
|
7
|
-
ファイル内はこのようになっています。
|
8
|
-
上記したサイト内で質問時に載せているエラーとanaconda仮想環境python3.7でのエラーが異なっていますがSDKのversionを2.3.1に変更したところエラーも変わりました。
|
9
|
-
|
10
|
-
anaconda仮想環境
|
7
|
+
anaconda仮想環境python3.7
|
11
8
|
```python
|
9
|
+
・
|
10
|
+
・
|
11
|
+
・
|
12
|
-
|
12
|
+
Frame id:10683, timestamp: 50514813528, hands:0, fingers:0
|
13
|
+
Frame id:10680, timestamp: 50514813538, hands:0, fingers:0
|
13
|
-
|
14
|
+
Frame id:10675, timestamp: 50514813549, hands:0, fingers:0
|
14
|
-
import Leap, sys,thread,time
|
15
|
-
File "C:\Users(ユーザー名)\Leap\LeapSDK\Leap.py", line 26, in <module>
|
16
|
-
LeapPython = swig_import_helper()
|
17
|
-
File "C:\Users(ユーザー名)\Leap\LeapSDK\Leap.py", line 22, in swig_import_helper
|
18
|
-
|
15
|
+
Frame id:10674, timestamp: 50514813555, hands:0, fingers:0
|
19
|
-
|
16
|
+
Frame id:10668, timestamp: 50514813566, hands:0, fingers:0
|
17
|
+
Frame id:10664, timestamp: 50514813573, hands:0, fingers:0
|
18
|
+
Frame id:10659, timestamp: 50514813589, hands:0, fingers:0
|
19
|
+
・
|
20
|
+
・
|
21
|
+
・
|
20
22
|
```
|
23
|
+
### エラーメッセージ
|
24
|
+
以下のエラーが繰り返されます
|
21
25
|
anaconda仮想環境python3.7
|
22
26
|
```python
|
27
|
+
・
|
28
|
+
・
|
29
|
+
・
|
30
|
+
Frame id:10683, timestamp: 50514813528, hands:0, fingers:0
|
31
|
+
StopIteration
|
32
|
+
|
33
|
+
The above exception was the direct cause of the following exception:
|
34
|
+
|
23
35
|
Traceback (most recent call last):
|
24
|
-
File "sample.py", line
|
36
|
+
File "sample.py", line 37, in on_frame
|
25
|
-
|
37
|
+
for hand in frame.hans:
|
26
|
-
|
38
|
+
SystemError: <built-in function delete_HandList>returned a result with an error set
|
39
|
+
・
|
40
|
+
・
|
41
|
+
・
|
27
42
|
```
|
28
43
|
###ソースコード
|
29
|
-
|
44
|
+
LeapmotionをダウンロードしたときについてきたSample.pyです。
|
45
|
+
元は``import Leap, sys, thread, time``でしたが、``thread``でエラーが出てしまいました。しかしpython2.7環境で``thread``抜きでも期待どおりの結果が出たので抜きました。
|
46
|
+
|
47
|
+
Sample.py
|
48
|
+
```python
|
49
|
+
import Leap, sys, time
|
50
|
+
|
51
|
+
|
52
|
+
class SampleListener(Leap.Listener):
|
53
|
+
finger_names = ['Thumb', 'Index', 'Middle', 'Ring', 'Pinky']
|
54
|
+
bone_names = ['Metacarpal', 'Proximal', 'Intermediate', 'Distal']
|
55
|
+
|
56
|
+
def on_init(self, controller):
|
57
|
+
print ("Initialized")
|
58
|
+
|
59
|
+
def on_connect(self, controller):
|
60
|
+
print ("Connected")
|
61
|
+
|
62
|
+
def on_disconnect(self, controller):
|
63
|
+
# Note: not dispatched when running in a debugger.
|
64
|
+
print ("Disconnected")
|
65
|
+
|
66
|
+
def on_exit(self, controller):
|
67
|
+
print ("Exited")
|
68
|
+
|
69
|
+
def on_frame(self, controller):
|
70
|
+
# Get the most recent frame and report some basic information
|
71
|
+
frame = controller.frame()
|
72
|
+
|
73
|
+
print ("Frame id: %d, timestamp: %d, hands: %d, fingers: %d" % (
|
74
|
+
frame.id, frame.timestamp, len(frame.hands), len(frame.fingers)))
|
75
|
+
|
76
|
+
# Get hands
|
77
|
+
for hand in frame.hands:
|
78
|
+
|
79
|
+
handType = "Left hand" if hand.is_left else "Right hand"
|
80
|
+
|
81
|
+
print (" %s, id %d, position: %s" % (
|
82
|
+
handType, hand.id, hand.palm_position))
|
83
|
+
|
84
|
+
# Get the hand's normal vector and direction
|
85
|
+
normal = hand.palm_normal
|
86
|
+
direction = hand.direction
|
87
|
+
|
88
|
+
# Calculate the hand's pitch, roll, and yaw angles
|
89
|
+
print (" pitch: %f degrees, roll: %f degrees, yaw: %f degrees" % (
|
90
|
+
direction.pitch * Leap.RAD_TO_DEG,
|
91
|
+
normal.roll * Leap.RAD_TO_DEG,
|
92
|
+
direction.yaw * Leap.RAD_TO_DEG))
|
93
|
+
|
94
|
+
# Get arm bone
|
95
|
+
arm = hand.arm
|
96
|
+
print (" Arm direction: %s, wrist position: %s, elbow position: %s" % (
|
97
|
+
arm.direction,
|
98
|
+
arm.wrist_position,
|
99
|
+
arm.elbow_position))
|
100
|
+
|
101
|
+
# Get fingers
|
102
|
+
for finger in hand.fingers:
|
103
|
+
|
104
|
+
print (" %s finger, id: %d, length: %fmm, width: %fmm" % (
|
105
|
+
self.finger_names[finger.type],
|
106
|
+
finger.id,
|
107
|
+
finger.length,
|
108
|
+
finger.width))
|
109
|
+
|
110
|
+
# Get bones
|
111
|
+
for b in range(0, 4):
|
112
|
+
bone = finger.bone(b)
|
113
|
+
print (" Bone: %s, start: %s, end: %s, direction: %s" % (
|
114
|
+
self.bone_names[bone.type],
|
115
|
+
bone.prev_joint,
|
116
|
+
bone.next_joint,
|
117
|
+
bone.direction))
|
118
|
+
|
119
|
+
if not frame.hands.is_empty:
|
120
|
+
print ("")
|
121
|
+
|
122
|
+
def main():
|
123
|
+
# Create a sample listener and controller
|
124
|
+
listener = SampleListener()
|
125
|
+
controller = Leap.Controller()
|
126
|
+
|
127
|
+
# Have the sample listener receive events from the controller
|
128
|
+
controller.add_listener(listener)
|
129
|
+
|
130
|
+
# Keep this process running until Enter is pressed
|
131
|
+
print ("Press Enter to quit...")
|
132
|
+
try:
|
133
|
+
sys.stdin.readline()
|
134
|
+
except KeyboardInterrupt:
|
135
|
+
pass
|
136
|
+
finally:
|
137
|
+
# Remove the sample listener when done
|
138
|
+
controller.remove_listener(listener)
|
139
|
+
|
140
|
+
|
141
|
+
if __name__ == "__main__":
|
142
|
+
main()
|
143
|
+
|
144
|
+
```
|
1
答えてもらえなかったため
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
### エラーメッセージ
|
7
|
-
ファイル内はこのようになっています。
|
8
|
-
|
8
|
+
上記したサイト内で質問時に載せているエラーとanaconda仮想環境python3.7でのエラーが異なっていますがSDKのversionを2.3.1に変更したところエラーも変わりました。
|
9
9
|
|
10
10
|
anaconda仮想環境python2.7
|
11
11
|
```python
|
@@ -23,15 +23,7 @@
|
|
23
23
|
Traceback (most recent call last):
|
24
24
|
File "sample.py", line 9, in <module>
|
25
25
|
import Leap, sys, thread, time
|
26
|
-
File "C:\Users(ユーザー名)\Leap\LeapSDK\Leap.py", line 26, in <module>
|
27
|
-
LeapPython = swig_import_helper()
|
28
|
-
File "C:\Users(ユーザー名)\Leap\LeapSDK\Leap.py", line 22, in swig_import_helper
|
29
|
-
_mode = imp.load_module('LeapPython' , fp, pathname, description)
|
30
|
-
File "C:\Users(ユーザー名)\anaconda3\envs\py37\lib\imp.py", line 242, in load_module
|
31
|
-
return load_dynamic(name, filename, file)
|
32
|
-
File "C:\Users(ユーザー名)\anaconda3\envs\py37\lib\imp.py", line 342, in load_dynamic
|
33
|
-
return load(spec)
|
34
|
-
|
26
|
+
ModuleNotFoundError:No module named 'thread'
|
35
27
|
```
|
36
28
|
###ソースコード
|
37
29
|
実行にはLeap Motionをダウンロードしたときに付いてきた`sample.py`を使っているのですが今回はあまり関係ないと思うのでカットさせていただきます。
|