teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

4

d

2018/11/15 04:21

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -6,7 +6,7 @@
6
6
  import os
7
7
  import cv2
8
8
 
9
- filepath = handcoat_all.gif
9
+ filepath = 'handcoat_all.gif'
10
10
 
11
11
  # 画像の読み込み
12
12
  if not os.path.exists(filepath):
@@ -24,4 +24,5 @@
24
24
  cv2.imshow("img", img)
25
25
  cv2.waitKey(0)
26
26
  cv2.destroyAllWindows()
27
+
27
28
  ```

3

d

2018/11/15 04:21

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -6,15 +6,18 @@
6
6
  import os
7
7
  import cv2
8
8
 
9
+ filepath = handcoat_all.gif
10
+
9
11
  # 画像の読み込み
12
+ if not os.path.exists(filepath):
13
+ print('File Not Found')
14
+ exit(1)
15
+
10
- img = cv2.imread("test.jpg", 1)
16
+ img = cv2.imread(filepath, 1)
11
17
  if img is None:
12
18
  print('Failed to load image.')
13
19
  exit(1)
14
20
 
15
- if not os.path.exists('handcoat_all.gif'):
16
- print('File Not Found')
17
- exit(1)
18
21
 
19
22
  cv2.namedWindow("img", cv2.WINDOW_NORMAL)
20
23
 

2

d

2018/11/15 04:21

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -3,6 +3,7 @@
3
3
  試した画像以外の他の画像でも同様に失敗するか確認してみてください。
4
4
 
5
5
  ```
6
+ import os
6
7
  import cv2
7
8
 
8
9
  # 画像の読み込み
@@ -11,6 +12,10 @@
11
12
  print('Failed to load image.')
12
13
  exit(1)
13
14
 
15
+ if not os.path.exists('handcoat_all.gif'):
16
+ print('File Not Found')
17
+ exit(1)
18
+
14
19
  cv2.namedWindow("img", cv2.WINDOW_NORMAL)
15
20
 
16
21
  cv2.imshow("img", img)

1

d

2018/11/15 04:20

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -8,6 +8,7 @@
8
8
  # 画像の読み込み
9
9
  img = cv2.imread("test.jpg", 1)
10
10
  if img is None:
11
+ print('Failed to load image.')
11
12
  exit(1)
12
13
 
13
14
  cv2.namedWindow("img", cv2.WINDOW_NORMAL)