質問編集履歴
3
初心者アイコンの付け足し
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|
2
書式改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,15 +7,18 @@
|
|
7
7
|
### 発生している問題・エラーメッセージ
|
8
8
|
|
9
9
|
```
|
10
|
+
Traceback (most recent call last):
|
11
|
+
|
10
|
-
|
12
|
+
File "tennis_line.py", line 66, in <module>
|
13
|
+
|
11
|
-
|
14
|
+
cv2.setMouseCallback(wname, onMouse, [wname, self.frame, ptlist])
|
12
15
|
|
13
|
-
|
16
|
+
NameError: name 'self' is not defined
|
14
17
|
|
15
|
-
```ここに言語名を入力
|
16
|
-
Python
|
17
|
-
コード
|
18
18
|
```
|
19
|
+
|
20
|
+
### プログラム
|
21
|
+
```python
|
19
22
|
import numpy as np
|
20
23
|
import cv2
|
21
24
|
|
@@ -25,7 +28,7 @@
|
|
25
28
|
|
26
29
|
class PointList():
|
27
30
|
def __init__(self, npoints):
|
28
|
-
|
31
|
+
self.video = cv2.VideoCapture(VIDEO_DATE)
|
29
32
|
self.frame = None
|
30
33
|
self.npoints = npoints
|
31
34
|
self.ptlist = np.empty((npoints, 2), dtype=int)
|
@@ -80,7 +83,9 @@
|
|
80
83
|
cv2.imshow(wname, self.frame)
|
81
84
|
cv2.waitKey()
|
82
85
|
cv2.destroyAllWindows()
|
86
|
+
```
|
83
87
|
|
88
|
+
|
84
89
|
### 参考サイト
|
85
90
|
https://qiita.com/otakoma/items/04e525ac74b7191dffe6
|
86
91
|
https://qiita.com/hitomatagi/items/3d8973f855e963c9d999
|
1
コードの付け足し
title
CHANGED
File without changes
|
body
CHANGED
@@ -19,14 +19,12 @@
|
|
19
19
|
import numpy as np
|
20
20
|
import cv2
|
21
21
|
|
22
|
-
|
22
|
+
|
23
23
|
VIDEO_DATE = 'tennis.AVI'
|
24
24
|
|
25
25
|
|
26
26
|
class PointList():
|
27
|
-
#コンストラクタ
|
28
27
|
def __init__(self, npoints):
|
29
|
-
#映像
|
30
28
|
self.video = cv2.VideoCapture(VIDEO_DATE)
|
31
29
|
self.frame = None
|
32
30
|
self.npoints = npoints
|
@@ -42,7 +40,7 @@
|
|
42
40
|
|
43
41
|
def run(self):
|
44
42
|
while(self.video.isOpened()):
|
45
|
-
|
43
|
+
|
46
44
|
end_flag,selt.frame = self.video.read()
|
47
45
|
|
48
46
|
def onMouse(self,event, x, y, flag, params):
|
@@ -78,7 +76,10 @@
|
|
78
76
|
cv2.namedWindow(wname)
|
79
77
|
npoints = 4
|
80
78
|
ptlist = PointList(npoints)
|
79
|
+
cv2.setMouseCallback(wname, onMouse, [wname, self.frame, ptlist])
|
80
|
+
cv2.imshow(wname, self.frame)
|
81
|
-
|
81
|
+
cv2.waitKey()
|
82
|
+
cv2.destroyAllWindows()
|
82
83
|
|
83
84
|
### 参考サイト
|
84
85
|
https://qiita.com/otakoma/items/04e525ac74b7191dffe6
|