質問編集履歴

7

誤字

2019/12/08 13:38

投稿

cherei
cherei

スコア12

test CHANGED
File without changes
test CHANGED
@@ -16,6 +16,8 @@
16
16
 
17
17
  ]
18
18
 
19
+
20
+
19
21
  ```python
20
22
 
21
23
  import numpy as np

6

誤字

2019/12/08 13:38

投稿

cherei
cherei

スコア12

test CHANGED
File without changes
test CHANGED
@@ -12,9 +12,9 @@
12
12
 
13
13
  以下のサイトは見ましたがよくわかりませんでした。
14
14
 
15
- https://teratail.com/questions/149453
15
+ [https://teratail.com/questions/149453
16
+
16
-
17
+ ]
17
-
18
18
 
19
19
  ```python
20
20
 

5

誤字

2019/12/08 13:37

投稿

cherei
cherei

スコア12

test CHANGED
File without changes
test CHANGED
@@ -202,10 +202,14 @@
202
202
 
203
203
  Traceback (most recent call last):
204
204
 
205
+
206
+
205
207
  File "C:/Users/tampa/PycharmProjects/camera-calib/Camera_Calibration.py", line 134, in <module>
206
208
 
207
209
  A = Calibration('calb_test/test2/')
208
210
 
211
+
212
+
209
213
  File "C:/Users/tampa/PycharmProjects/camera-calib/Camera_Calibration.py", line 91, in Calibration
210
214
 
211
215
  ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[::-1], None, None)

4

誤字

2019/12/08 13:36

投稿

cherei
cherei

スコア12

test CHANGED
File without changes
test CHANGED
@@ -195,3 +195,21 @@
195
195
  print(A)
196
196
 
197
197
  ```
198
+
199
+
200
+
201
+ ```エラーコード
202
+
203
+ Traceback (most recent call last):
204
+
205
+ File "C:/Users/tampa/PycharmProjects/camera-calib/Camera_Calibration.py", line 134, in <module>
206
+
207
+ A = Calibration('calb_test/test2/')
208
+
209
+ File "C:/Users/tampa/PycharmProjects/camera-calib/Camera_Calibration.py", line 91, in Calibration
210
+
211
+ ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[::-1], None, None)
212
+
213
+ UnboundLocalError: local variable 'gray' referenced before assignment
214
+
215
+ ```

3

誤字

2019/12/08 13:30

投稿

cherei
cherei

スコア12

test CHANGED
File without changes
test CHANGED
@@ -18,27 +18,31 @@
18
18
 
19
19
  ```python
20
20
 
21
- #コード
22
-
23
21
  import numpy as np
24
22
 
25
23
  import cv2
26
24
 
27
25
  import glob
28
26
 
27
+
28
+
29
29
  def Calibration(path):
30
30
 
31
-
31
+ # termination criteria
32
32
 
33
- criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001
33
+ criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
34
34
 
35
+
36
+
35
-
37
+ # prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0)
36
38
 
37
39
  objp = np.zeros((6 * 8, 3), np.float32)
38
40
 
39
41
  objp[:, :2] = np.mgrid[0:8, 0:6].T.reshape(-1, 2)
40
42
 
41
43
 
44
+
45
+ # Arrays to store object points and image points from all the images.
42
46
 
43
47
  objpoints = [] # 3d point in real world space
44
48
 
@@ -60,11 +64,13 @@
60
64
 
61
65
 
62
66
 
67
+ # Find the chess board corners
68
+
63
69
  ret, corners = cv2.findChessboardCorners(gray, (8, 6), flags=cv2.CALIB_CB_FAST_CHECK)
64
70
 
65
71
  print(ret)
66
72
 
67
-
73
+ # If found, add object points, image points (after refining them)
68
74
 
69
75
  if ret == True:
70
76
 
@@ -78,7 +84,7 @@
78
84
 
79
85
 
80
86
 
81
-
87
+ # Draw and display the corners
82
88
 
83
89
  img = cv2.drawChessboardCorners(img, (8, 6), corners2, ret)
84
90
 
@@ -86,7 +92,7 @@
86
92
 
87
93
  width = img.shape[1]
88
94
 
89
-
95
+ # cv2.imshow('img',img)
90
96
 
91
97
 
92
98
 
@@ -110,11 +116,13 @@
110
116
 
111
117
  newcameramtx, roi = cv2.getOptimalNewCameraMatrix(mtx, dist, (w, h), 1, (w, h))
112
118
 
113
-
119
+ # undistort
120
+
121
+
114
122
 
115
123
  dst = cv2.undistort(img, mtx, dist, None, newcameramtx)
116
124
 
117
-
125
+ # crop the image
118
126
 
119
127
  x, y, w, h = roi
120
128
 
@@ -174,13 +182,13 @@
174
182
 
175
183
 
176
184
 
177
- cap.release()
185
+ cap.release() # When everything done, release the capture
178
186
 
179
-
187
+ #
180
188
 
181
189
  if __name__ == '__main__':
182
190
 
183
-
191
+ # video_split('calb_test/test.mov')
184
192
 
185
193
  A = Calibration('calb_test/test2/')
186
194
 

2

誤字

2019/12/08 09:36

投稿

cherei
cherei

スコア12

test CHANGED
File without changes
test CHANGED
@@ -10,7 +10,13 @@
10
10
 
11
11
 
12
12
 
13
+ 以下のサイトは見ましたがよくわかりませんでした。
13
14
 
15
+ https://teratail.com/questions/149453
16
+
17
+
18
+
19
+ ```python
14
20
 
15
21
  #コード
16
22
 
@@ -179,3 +185,5 @@
179
185
  A = Calibration('calb_test/test2/')
180
186
 
181
187
  print(A)
188
+
189
+ ```

1

誤字

2019/12/08 09:34

投稿

cherei
cherei

スコア12

test CHANGED
@@ -1 +1 @@
1
- エラー:UnboundLocalError: local variable 'gray' referenced before assignment
1
+ エラー:UnboundLocalError: local variable 'gray' referenced before assignment を解決したいです。
test CHANGED
File without changes