質問編集履歴

4

誤字

2020/12/11 14:18

投稿

krenda
krenda

スコア0

test CHANGED
File without changes
test CHANGED
@@ -10,6 +10,42 @@
10
10
 
11
11
  ###期待結果
12
12
 
13
+ anaconda仮想環境python2.7
14
+
15
+ ```python
16
+
17
+                 ・
18
+
19
+                 ・
20
+
21
+                 ・
22
+
23
+ Frame id:10683, timestamp: 50514813528, hands:0, fingers:0
24
+
25
+ Frame id:10680, timestamp: 50514813538, hands:0, fingers:0
26
+
27
+ Frame id:10675, timestamp: 50514813549, hands:0, fingers:0
28
+
29
+ Frame id:10674, timestamp: 50514813555, hands:0, fingers:0
30
+
31
+ Frame id:10668, timestamp: 50514813566, hands:0, fingers:0
32
+
33
+ Frame id:10664, timestamp: 50514813573, hands:0, fingers:0
34
+
35
+ Frame id:10659, timestamp: 50514813589, hands:0, fingers:0
36
+
37
+                 ・
38
+
39
+                 ・
40
+
41
+                 ・
42
+
43
+ ```
44
+
45
+ ### エラーメッセージ
46
+
47
+ 以下のエラーが繰り返されます
48
+
13
49
  anaconda仮想環境python3.7
14
50
 
15
51
  ```python
@@ -18,21 +54,25 @@
18
54
 
19
55
                  ・
20
56
 
21
-                 ・
57
+                 ・
22
58
 
23
59
  Frame id:10683, timestamp: 50514813528, hands:0, fingers:0
24
60
 
61
+ StopIteration
62
+
63
+
64
+
65
+ The above exception was the direct cause of the following exception:
66
+
67
+
68
+
69
+ Traceback (most recent call last):
70
+
25
- Frame id:10680, timestamp: 50514813538, hands:0, fingers:0
71
+ File "sample.py", line 37, in on_frame
72
+
26
-
73
+ for hand in frame.hands:
74
+
27
- Frame id:10675, timestamp: 50514813549, hands:0, fingers:0
75
+ SystemError: <built-in function delete_HandList>returned a result with an error set
28
-
29
- Frame id:10674, timestamp: 50514813555, hands:0, fingers:0
30
-
31
- Frame id:10668, timestamp: 50514813566, hands:0, fingers:0
32
-
33
- Frame id:10664, timestamp: 50514813573, hands:0, fingers:0
34
-
35
- Frame id:10659, timestamp: 50514813589, hands:0, fingers:0
36
76
 
37
77
                  ・
38
78
 
@@ -42,246 +82,206 @@
42
82
 
43
83
  ```
44
84
 
45
- ### エラメッセ
46
-
47
- 以下のエラが繰り返されま
48
-
49
- anaconda仮想環境python3.7
50
-
51
- ```python
52
-
53
-                 ・
54
-
55
-                 ・
56
-
57
-                 ・
58
-
59
- Frame id:10683, timestamp: 50514813528, hands:0, fingers:0
60
-
61
- StopIteration
62
-
63
-
64
-
65
- The above exception was the direct cause of the following exception:
66
-
67
-
68
-
69
- Traceback (most recent call last):
70
-
71
- File "sample.py", line 37, in on_frame
72
-
73
- for hand in frame.hands:
74
-
75
- SystemError: <built-in function delete_HandList>returned a result with an error set
76
-
77
-                 ・
78
-
79
-                 ・
80
-
81
-                 ・
85
+ ###スコ
86
+
87
+ LeapmotionをダウンロドしたときについてきたSample.pyで
88
+
89
+ 元は``import Leap, sys, thread, time``でしたが、``thread``でエラーが出てしまいました。しかしpython2.7環境で``thread``抜きでも期待どおりの結果が出たので抜きました。
90
+
91
+
92
+
93
+ Sample.py
94
+
95
+ ```python
96
+
97
+ import Leap, sys, time
98
+
99
+
100
+
101
+
102
+
103
+ class SampleListener(Leap.Listener):
104
+
105
+ finger_names = ['Thumb', 'Index', 'Middle', 'Ring', 'Pinky']
106
+
107
+ bone_names = ['Metacarpal', 'Proximal', 'Intermediate', 'Distal']
108
+
109
+
110
+
111
+ def on_init(self, controller):
112
+
113
+ print ("Initialized")
114
+
115
+
116
+
117
+ def on_connect(self, controller):
118
+
119
+ print ("Connected")
120
+
121
+
122
+
123
+ def on_disconnect(self, controller):
124
+
125
+ # Note: not dispatched when running in a debugger.
126
+
127
+ print ("Disconnected")
128
+
129
+
130
+
131
+ def on_exit(self, controller):
132
+
133
+ print ("Exited")
134
+
135
+
136
+
137
+ def on_frame(self, controller):
138
+
139
+ # Get the most recent frame and report some basic information
140
+
141
+ frame = controller.frame()
142
+
143
+
144
+
145
+ print ("Frame id: %d, timestamp: %d, hands: %d, fingers: %d" % (
146
+
147
+ frame.id, frame.timestamp, len(frame.hands), len(frame.fingers)))
148
+
149
+
150
+
151
+ # Get hands
152
+
153
+ for hand in frame.hands:
154
+
155
+
156
+
157
+ handType = "Left hand" if hand.is_left else "Right hand"
158
+
159
+
160
+
161
+ print (" %s, id %d, position: %s" % (
162
+
163
+ handType, hand.id, hand.palm_position))
164
+
165
+
166
+
167
+ # Get the hand's normal vector and direction
168
+
169
+ normal = hand.palm_normal
170
+
171
+ direction = hand.direction
172
+
173
+
174
+
175
+ # Calculate the hand's pitch, roll, and yaw angles
176
+
177
+ print (" pitch: %f degrees, roll: %f degrees, yaw: %f degrees" % (
178
+
179
+ direction.pitch * Leap.RAD_TO_DEG,
180
+
181
+ normal.roll * Leap.RAD_TO_DEG,
182
+
183
+ direction.yaw * Leap.RAD_TO_DEG))
184
+
185
+
186
+
187
+ # Get arm bone
188
+
189
+ arm = hand.arm
190
+
191
+ print (" Arm direction: %s, wrist position: %s, elbow position: %s" % (
192
+
193
+ arm.direction,
194
+
195
+ arm.wrist_position,
196
+
197
+ arm.elbow_position))
198
+
199
+
200
+
201
+ # Get fingers
202
+
203
+ for finger in hand.fingers:
204
+
205
+
206
+
207
+ print (" %s finger, id: %d, length: %fmm, width: %fmm" % (
208
+
209
+ self.finger_names[finger.type],
210
+
211
+ finger.id,
212
+
213
+ finger.length,
214
+
215
+ finger.width))
216
+
217
+
218
+
219
+ # Get bones
220
+
221
+ for b in range(0, 4):
222
+
223
+ bone = finger.bone(b)
224
+
225
+ print (" Bone: %s, start: %s, end: %s, direction: %s" % (
226
+
227
+ self.bone_names[bone.type],
228
+
229
+ bone.prev_joint,
230
+
231
+ bone.next_joint,
232
+
233
+ bone.direction))
234
+
235
+
236
+
237
+ if not frame.hands.is_empty:
238
+
239
+ print ("")
240
+
241
+
242
+
243
+ def main():
244
+
245
+ # Create a sample listener and controller
246
+
247
+ listener = SampleListener()
248
+
249
+ controller = Leap.Controller()
250
+
251
+
252
+
253
+ # Have the sample listener receive events from the controller
254
+
255
+ controller.add_listener(listener)
256
+
257
+
258
+
259
+ # Keep this process running until Enter is pressed
260
+
261
+ print ("Press Enter to quit...")
262
+
263
+ try:
264
+
265
+ sys.stdin.readline()
266
+
267
+ except KeyboardInterrupt:
268
+
269
+ pass
270
+
271
+ finally:
272
+
273
+ # Remove the sample listener when done
274
+
275
+ controller.remove_listener(listener)
276
+
277
+
278
+
279
+
280
+
281
+ if __name__ == "__main__":
282
+
283
+ main()
284
+
285
+
82
286
 
83
287
  ```
84
-
85
- ###ソースコード
86
-
87
- LeapmotionをダウンロードしたときについてきたSample.pyです。
88
-
89
- 元は``import Leap, sys, thread, time``でしたが、``thread``でエラーが出てしまいました。しかしpython2.7環境で``thread``抜きでも期待どおりの結果が出たので抜きました。
90
-
91
-
92
-
93
- Sample.py
94
-
95
- ```python
96
-
97
- import Leap, sys, time
98
-
99
-
100
-
101
-
102
-
103
- class SampleListener(Leap.Listener):
104
-
105
- finger_names = ['Thumb', 'Index', 'Middle', 'Ring', 'Pinky']
106
-
107
- bone_names = ['Metacarpal', 'Proximal', 'Intermediate', 'Distal']
108
-
109
-
110
-
111
- def on_init(self, controller):
112
-
113
- print ("Initialized")
114
-
115
-
116
-
117
- def on_connect(self, controller):
118
-
119
- print ("Connected")
120
-
121
-
122
-
123
- def on_disconnect(self, controller):
124
-
125
- # Note: not dispatched when running in a debugger.
126
-
127
- print ("Disconnected")
128
-
129
-
130
-
131
- def on_exit(self, controller):
132
-
133
- print ("Exited")
134
-
135
-
136
-
137
- def on_frame(self, controller):
138
-
139
- # Get the most recent frame and report some basic information
140
-
141
- frame = controller.frame()
142
-
143
-
144
-
145
- print ("Frame id: %d, timestamp: %d, hands: %d, fingers: %d" % (
146
-
147
- frame.id, frame.timestamp, len(frame.hands), len(frame.fingers)))
148
-
149
-
150
-
151
- # Get hands
152
-
153
- for hand in frame.hands:
154
-
155
-
156
-
157
- handType = "Left hand" if hand.is_left else "Right hand"
158
-
159
-
160
-
161
- print (" %s, id %d, position: %s" % (
162
-
163
- handType, hand.id, hand.palm_position))
164
-
165
-
166
-
167
- # Get the hand's normal vector and direction
168
-
169
- normal = hand.palm_normal
170
-
171
- direction = hand.direction
172
-
173
-
174
-
175
- # Calculate the hand's pitch, roll, and yaw angles
176
-
177
- print (" pitch: %f degrees, roll: %f degrees, yaw: %f degrees" % (
178
-
179
- direction.pitch * Leap.RAD_TO_DEG,
180
-
181
- normal.roll * Leap.RAD_TO_DEG,
182
-
183
- direction.yaw * Leap.RAD_TO_DEG))
184
-
185
-
186
-
187
- # Get arm bone
188
-
189
- arm = hand.arm
190
-
191
- print (" Arm direction: %s, wrist position: %s, elbow position: %s" % (
192
-
193
- arm.direction,
194
-
195
- arm.wrist_position,
196
-
197
- arm.elbow_position))
198
-
199
-
200
-
201
- # Get fingers
202
-
203
- for finger in hand.fingers:
204
-
205
-
206
-
207
- print (" %s finger, id: %d, length: %fmm, width: %fmm" % (
208
-
209
- self.finger_names[finger.type],
210
-
211
- finger.id,
212
-
213
- finger.length,
214
-
215
- finger.width))
216
-
217
-
218
-
219
- # Get bones
220
-
221
- for b in range(0, 4):
222
-
223
- bone = finger.bone(b)
224
-
225
- print (" Bone: %s, start: %s, end: %s, direction: %s" % (
226
-
227
- self.bone_names[bone.type],
228
-
229
- bone.prev_joint,
230
-
231
- bone.next_joint,
232
-
233
- bone.direction))
234
-
235
-
236
-
237
- if not frame.hands.is_empty:
238
-
239
- print ("")
240
-
241
-
242
-
243
- def main():
244
-
245
- # Create a sample listener and controller
246
-
247
- listener = SampleListener()
248
-
249
- controller = Leap.Controller()
250
-
251
-
252
-
253
- # Have the sample listener receive events from the controller
254
-
255
- controller.add_listener(listener)
256
-
257
-
258
-
259
- # Keep this process running until Enter is pressed
260
-
261
- print ("Press Enter to quit...")
262
-
263
- try:
264
-
265
- sys.stdin.readline()
266
-
267
- except KeyboardInterrupt:
268
-
269
- pass
270
-
271
- finally:
272
-
273
- # Remove the sample listener when done
274
-
275
- controller.remove_listener(listener)
276
-
277
-
278
-
279
-
280
-
281
- if __name__ == "__main__":
282
-
283
- main()
284
-
285
-
286
-
287
- ```

3

2020/12/11 14:18

投稿

krenda
krenda

スコア0

test CHANGED
File without changes
test CHANGED
@@ -70,7 +70,7 @@
70
70
 
71
71
  File "sample.py", line 37, in on_frame
72
72
 
73
- for hand in frame.hans:
73
+ for hand in frame.hands:
74
74
 
75
75
  SystemError: <built-in function delete_HandList>returned a result with an error set
76
76
 

2

自分なりに進めていたら変更点があった

2020/11/28 21:03

投稿

krenda
krenda

スコア0

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  ### 質問内容
2
2
 
3
- OpenCVとLeap Motionを同時に使いたいのでpython3でLeap Motionを使えるように調べたところ「[Python3でLeap Motion](https://qiita.com/issakuss/items/39caec385f057b9c4ab3#comment-fed9cfd05ac37c9f9e80)」というサイトを発見しました。しかし`LeadPython.pyd`、`Leap.py`をサイト内に載せていただいている「生成されたLeadPython.pyd」「手直ししたLeap.py」に変えてもうまくいきませんでした。なでサイトの作成者の方に質問させていただいたのですがそれでも原因は判明しませんでした。(サイト内で質問している@krenda933が私です。)
3
+ OpenCVとLeap Motionを同時に使いたいのでpython3でLeap Motionを使えるように調べたところ「[Python3でLeap Motion](https://qiita.com/issakuss/items/39caec385f057b9c4ab3#comment-fed9cfd05ac37c9f9e80)」というサイトを発見しました。サイトの作成者の方に質問させていただいたり自分なりにやってみたりしたのですがよくわからないエラーが出てしまいました。
4
4
 
5
5
  もしわかる方がいらっしゃったら解決していただきたいです。
6
6
 
@@ -8,50 +8,280 @@
8
8
 
9
9
 
10
10
 
11
+ ###期待結果
12
+
13
+ anaconda仮想環境python3.7
14
+
15
+ ```python
16
+
17
+                 ・
18
+
19
+                 ・
20
+
21
+                 ・
22
+
23
+ Frame id:10683, timestamp: 50514813528, hands:0, fingers:0
24
+
25
+ Frame id:10680, timestamp: 50514813538, hands:0, fingers:0
26
+
27
+ Frame id:10675, timestamp: 50514813549, hands:0, fingers:0
28
+
29
+ Frame id:10674, timestamp: 50514813555, hands:0, fingers:0
30
+
31
+ Frame id:10668, timestamp: 50514813566, hands:0, fingers:0
32
+
33
+ Frame id:10664, timestamp: 50514813573, hands:0, fingers:0
34
+
35
+ Frame id:10659, timestamp: 50514813589, hands:0, fingers:0
36
+
37
+                 ・
38
+
39
+                 ・
40
+
41
+                 ・
42
+
43
+ ```
44
+
11
45
  ### エラーメッセージ
12
46
 
13
- ファイル内はこようになっています。![イメージ説明](061c1e52130e6582f5c6753019d3cae6.png)
47
+ 以下エラーが繰り返されます
14
-
15
- 上記したサイト内で質問時に載せているエラーとanaconda仮想環境python3.7でのエラーが異なっていますがSDKのversionを2.3.1に変更したところエラーも変わりました。
48
+
16
-
17
-
18
-
19
- anaconda仮想環境python2.7
49
+ anaconda仮想環境python3.7
20
50
 
21
51
  ```python
22
52
 
53
+                 ・
54
+
55
+                 ・
56
+
57
+                 ・
58
+
59
+ Frame id:10683, timestamp: 50514813528, hands:0, fingers:0
60
+
61
+ StopIteration
62
+
63
+
64
+
65
+ The above exception was the direct cause of the following exception:
66
+
67
+
68
+
23
69
  Traceback (most recent call last):
24
70
 
25
- File "sample.py", line 9, in <module>
71
+ File "sample.py", line 37, in on_frame
26
-
72
+
27
- import Leap, sys,thread,time
73
+ for hand in frame.hans:
28
-
29
- File "C:\Users(ユーザー名)\Leap\LeapSDK\Leap.py", line 26, in <module>
74
+
30
-
31
- LeapPython = swig_import_helper()
32
-
33
- File "C:\Users(ユーザー名)\Leap\LeapSDK\Leap.py", line 22, in swig_import_helper
75
+ SystemError: <built-in function delete_HandList>returned a result with an error set
34
-
35
- _mode = imp.load_module('LeapPython',fp,pathname,description)
76
+
36
-
37
- ImportError:DLL load failed:指定されたモジュールが見つかりません。
77
+                 ・
78
+
79
+                 ・
80
+
81
+                 ・
38
82
 
39
83
  ```
40
84
 
85
+ ###ソースコード
86
+
41
- anaconda仮想環境python3.7
87
+ LeapmotionをダウンロードしたときについてきたSample.pyです。
88
+
42
-
89
+ 元は``import Leap, sys, thread, time``でしたが、``thread``でエラーが出てしまいました。しかしpython2.7環境で``thread``抜きでも期待どおりの結果が出たので抜きました。
90
+
91
+
92
+
93
+ Sample.py
94
+
43
- ```python
95
+ ```python
44
-
45
- Traceback (most recent call last):
96
+
46
-
47
- File "sample.py", line 9, in <module>
48
-
49
- import Leap, sys, thread, time
97
+ import Leap, sys, time
98
+
99
+
100
+
101
+
102
+
50
-
103
+ class SampleListener(Leap.Listener):
104
+
105
+ finger_names = ['Thumb', 'Index', 'Middle', 'Ring', 'Pinky']
106
+
107
+ bone_names = ['Metacarpal', 'Proximal', 'Intermediate', 'Distal']
108
+
109
+
110
+
111
+ def on_init(self, controller):
112
+
113
+ print ("Initialized")
114
+
115
+
116
+
117
+ def on_connect(self, controller):
118
+
119
+ print ("Connected")
120
+
121
+
122
+
123
+ def on_disconnect(self, controller):
124
+
125
+ # Note: not dispatched when running in a debugger.
126
+
127
+ print ("Disconnected")
128
+
129
+
130
+
131
+ def on_exit(self, controller):
132
+
133
+ print ("Exited")
134
+
135
+
136
+
137
+ def on_frame(self, controller):
138
+
139
+ # Get the most recent frame and report some basic information
140
+
141
+ frame = controller.frame()
142
+
143
+
144
+
145
+ print ("Frame id: %d, timestamp: %d, hands: %d, fingers: %d" % (
146
+
147
+ frame.id, frame.timestamp, len(frame.hands), len(frame.fingers)))
148
+
149
+
150
+
151
+ # Get hands
152
+
153
+ for hand in frame.hands:
154
+
155
+
156
+
51
- ModuleNotFoundError:No module named 'thread'
157
+ handType = "Left hand" if hand.is_left else "Right hand"
158
+
159
+
160
+
161
+ print (" %s, id %d, position: %s" % (
162
+
163
+ handType, hand.id, hand.palm_position))
164
+
165
+
166
+
167
+ # Get the hand's normal vector and direction
168
+
169
+ normal = hand.palm_normal
170
+
171
+ direction = hand.direction
172
+
173
+
174
+
175
+ # Calculate the hand's pitch, roll, and yaw angles
176
+
177
+ print (" pitch: %f degrees, roll: %f degrees, yaw: %f degrees" % (
178
+
179
+ direction.pitch * Leap.RAD_TO_DEG,
180
+
181
+ normal.roll * Leap.RAD_TO_DEG,
182
+
183
+ direction.yaw * Leap.RAD_TO_DEG))
184
+
185
+
186
+
187
+ # Get arm bone
188
+
189
+ arm = hand.arm
190
+
191
+ print (" Arm direction: %s, wrist position: %s, elbow position: %s" % (
192
+
193
+ arm.direction,
194
+
195
+ arm.wrist_position,
196
+
197
+ arm.elbow_position))
198
+
199
+
200
+
201
+ # Get fingers
202
+
203
+ for finger in hand.fingers:
204
+
205
+
206
+
207
+ print (" %s finger, id: %d, length: %fmm, width: %fmm" % (
208
+
209
+ self.finger_names[finger.type],
210
+
211
+ finger.id,
212
+
213
+ finger.length,
214
+
215
+ finger.width))
216
+
217
+
218
+
219
+ # Get bones
220
+
221
+ for b in range(0, 4):
222
+
223
+ bone = finger.bone(b)
224
+
225
+ print (" Bone: %s, start: %s, end: %s, direction: %s" % (
226
+
227
+ self.bone_names[bone.type],
228
+
229
+ bone.prev_joint,
230
+
231
+ bone.next_joint,
232
+
233
+ bone.direction))
234
+
235
+
236
+
237
+ if not frame.hands.is_empty:
238
+
239
+ print ("")
240
+
241
+
242
+
243
+ def main():
244
+
245
+ # Create a sample listener and controller
246
+
247
+ listener = SampleListener()
248
+
249
+ controller = Leap.Controller()
250
+
251
+
252
+
253
+ # Have the sample listener receive events from the controller
254
+
255
+ controller.add_listener(listener)
256
+
257
+
258
+
259
+ # Keep this process running until Enter is pressed
260
+
261
+ print ("Press Enter to quit...")
262
+
263
+ try:
264
+
265
+ sys.stdin.readline()
266
+
267
+ except KeyboardInterrupt:
268
+
269
+ pass
270
+
271
+ finally:
272
+
273
+ # Remove the sample listener when done
274
+
275
+ controller.remove_listener(listener)
276
+
277
+
278
+
279
+
280
+
281
+ if __name__ == "__main__":
282
+
283
+ main()
284
+
285
+
52
286
 
53
287
  ```
54
-
55
- ###ソースコード
56
-
57
- 実行にはLeap Motionをダウンロードしたときに付いてきた`sample.py`を使っているのですが今回はあまり関係ないと思うのでカットさせていただきます。

1

答えてもらえなかったため

2020/11/23 14:48

投稿

krenda
krenda

スコア0

test CHANGED
File without changes
test CHANGED
@@ -10,9 +10,9 @@
10
10
 
11
11
  ### エラーメッセージ
12
12
 
13
- ファイル内はこのようになっています。![イメージ説明](fed61a485ce8ba1d171b194bb5208fdb.png)
13
+ ファイル内はこのようになっています。![イメージ説明](061c1e52130e6582f5c6753019d3cae6.png)
14
14
 
15
- にエラーメッセ必要場合は追加しま
15
+ 上記たサイト内で質問時載せているエラーとanaconda仮想環境python3.7でのエラーが異なっていますがSDKversionを2.3.1に変更たところエラーも変わりした
16
16
 
17
17
 
18
18
 
@@ -48,23 +48,7 @@
48
48
 
49
49
  import Leap, sys, thread, time
50
50
 
51
- File "C:\Users(ユーザー名)\Leap\LeapSDK\Leap.py", line 26, in <module>
52
-
53
- LeapPython = swig_import_helper()
54
-
55
- File "C:\Users(ユーザー名)\Leap\LeapSDK\Leap.py", line 22, in swig_import_helper
56
-
57
- _mode = imp.load_module('LeapPython' , fp, pathname, description)
58
-
59
- File "C:\Users(ユーザー名)\anaconda3\envs\py37\lib\imp.py", line 242, in load_module
60
-
61
- return load_dynamic(name, filename, file)
62
-
63
- File "C:\Users(ユーザー名)\anaconda3\envs\py37\lib\imp.py", line 342, in load_dynamic
64
-
65
- return load(spec)
66
-
67
- ImportError:DLL load failed:指定されたプロシージャが見つかりません。
51
+ ModuleNotFoundError:No module named 'thread'
68
52
 
69
53
  ```
70
54