回答編集履歴

2

検証結果を追記

2017/09/15 09:31

投稿

can110
can110

スコア38262

test CHANGED
@@ -45,3 +45,23 @@
45
45
  cv2.error
46
46
 
47
47
  ```
48
+
49
+
50
+
51
+ ちなみに上記のコードの最後の2行を以下に変えても、`cv2.resize`で発生する例外は捕捉できていますし
52
+
53
+ ```Python
54
+
55
+ except:
56
+
57
+ print('except')
58
+
59
+ ```
60
+
61
+ ```cv2.resize(frame, (200,300))```をコメントアウトすると、例外は発生せずプログラムは正常終了します。
62
+
63
+
64
+
65
+ 以上の検証結果より`cap = VideoCapture(~`では**例外は発生しない**と判断しています。
66
+
67
+ この検証結果を踏まえ、採るべき対応はmt08さんの回答のとおりと考えます。

1

実行結果を追記

2017/09/15 09:31

投稿

can110
can110

スコア38262

test CHANGED
@@ -27,3 +27,21 @@
27
27
  print('cv2.error')
28
28
 
29
29
  ```
30
+
31
+
32
+
33
+ 実行結果(resizeでの例外を捕捉)
34
+
35
+ ```
36
+
37
+ False
38
+
39
+ False
40
+
41
+ None
42
+
43
+ OpenCV Error: Assertion failed (ssize.area() > 0) in cv::resize, file ..\..\..\modules\imgproc\src\imgwarp.cpp, line 3229
44
+
45
+ cv2.error
46
+
47
+ ```