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

回答編集履歴

4

追記

2018/12/07 08:27

投稿

8524ba23
8524ba23

スコア38352

answer CHANGED
@@ -116,4 +116,10 @@
116
116
  Install to: C:/Miniconda3/conda-bld/opencv-suite_1533128839831/_h_env/Library
117
117
  -----------------------------------------------------------------
118
118
  ```
119
+ おそらく`sudo apt-get install python-opencv`でプレビルドなパッケージをインストールしたと思われますが、提示結果では`libv4l/libv4l2: NO`となっているのでWebカメラ機能が組み込まれていないようですのでソースからの再インストール(ビルド)が必要です。
120
+
121
+ 再インストール(ビルド)については
119
- 再インストール(ビルド)については[Linux - OpenCV VideoCaptureが動作しない](https://teratail.com/questions/58787)が参考になりそうです(とても面倒そうですが)
122
+ - [Linux - OpenCV VideoCaptureが動作しない](https://teratail.com/questions/58787)
123
+ - [Install OpenCV-Python in Ubuntu](https://docs.opencv.org/master/d2/de6/tutorial_py_setup_in_ubuntu.html)
124
+
125
+ が参考になりますが、正直、茨の道を進むことになります。(とても面倒そう)

3

追記

2018/12/07 08:27

投稿

8524ba23
8524ba23

スコア38352

answer CHANGED
@@ -6,4 +6,114 @@
6
6
  のいずれか動作するか試してみてはいかがでしょうか?
7
7
 
8
8
  ダメであれば、そもそも`OpenCV`に動画関連の機能が組み込まれていないのかもしれませんので、`OpenCV`の導入方法から詳細確認、あるいは再インストール(ビルド)が必要だと思います。
9
+ `OpenCV`の詳細情報は
10
+ ```Python
11
+ import cv2
12
+ print(cv2.getBuildInformation())
13
+ ```
14
+ で確認できます。以下Win10上での実行例です。
15
+ ```
16
+ General configuration for OpenCV 3.4.1 =====================================
17
+ Version control: unknown
18
+
19
+ Extra modules:
20
+ Location (extra): C:/Miniconda3/conda-bld/opencv-suite_1533128839831/work/opencv_contrib-3.4.1/modules
21
+ Version control (extra): unknown
22
+
23
+ Platform:
24
+ Timestamp: 2018-08-01T13:09:43Z
25
+ Host: Windows 10.0.16299 AMD64
26
+ CMake: 3.12.0
27
+ CMake generator: NMake Makefiles JOM
28
+ CMake build tool: jom
29
+ MSVC: 1900
30
+ Configuration: Release
31
+
32
+ CPU/HW features:
33
+ Baseline: SSE SSE2 SSE3
34
+ requested: SSE3
35
+ Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2
36
+ requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
37
+ SSE4_1 (3 files): + SSSE3 SSE4_1
38
+ SSE4_2 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2
39
+ FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
40
+ AVX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
41
+ AVX2 (9 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
42
+
43
+ C/C++:
44
+ Built as dynamic libs?: YES
45
+ C++11: YES
46
+ C++ Compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe (ver 19.0.23918.0)
47
+ C++ flags (Release): -MD -GL /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /FS /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP6 /MD /O2 /Ob2 /DNDEBUG
48
+ C++ flags (Debug): -MD -GL /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /FS /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP6 /MDd /Zi /Ob0 /Od /RTC1
49
+ C Compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe
50
+ C flags (Release): -MD -GL /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /FS /MP6 /MD /O2 /Ob2 /DNDEBUG
51
+ C flags (Debug): -MD -GL /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /FS /MP6 /MDd /Zi /Ob0 /Od /RTC1
52
+ Linker flags (Release): /machine:x64 /INCREMENTAL:NO
53
+ Linker flags (Debug): /machine:x64 /debug /INCREMENTAL
54
+ ccache: NO
55
+ Precompiled headers: NO
56
+ Extra dependencies:
57
+ 3rdparty dependencies:
58
+
59
+ OpenCV modules:
60
+ To be built: aruco bgsegm calib3d ccalib core datasets dnn dnn_objdetect dpm face features2d flann fuzzy hfs highgui img_hash imgcodecs imgproc java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot python_bindings_generator reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
61
+ Disabled: bioinspired js world
62
+ Disabled by dependency: -
63
+ Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv dnn_modern freetype hdf java matlab ovis python2 python3 sfm ts viz
64
+ Applications: apps
65
+ Documentation: NO
66
+ Non-free algorithms: NO
67
+
68
+ Windows RT support: NO
69
+
70
+ GUI:
71
+ Win32 UI: YES
72
+
73
+ Media I/O:
74
+ ZLib: C:/Miniconda3/conda-bld/opencv-suite_1533128839831/_h_env/Library/lib/z.lib (ver 1.2.11)
75
+ JPEG: C:/Miniconda3/conda-bld/opencv-suite_1533128839831/_h_env/Library/lib/jpeg.lib (ver 90)
76
+ WEBP: build (ver encoder: 0x020e)
77
+ PNG: C:/Miniconda3/conda-bld/opencv-suite_1533128839831/_h_env/Library/lib/libpng.lib (ver 1.6.34)
78
+ TIFF: C:/Miniconda3/conda-bld/opencv-suite_1533128839831/_h_env/Library/lib/tiff.lib (ver 42 / 4.0.9)
79
+ JPEG 2000: build (ver 1.900.1)
80
+ OpenEXR: build (ver 1.7.1)
81
+
82
+ Video I/O:
83
+ Video for Windows: YES
84
+ DC1394: NO
85
+ FFMPEG: YES (prebuilt binaries)
86
+ avcodec: YES (ver 57.107.100)
87
+ avformat: YES (ver 57.83.100)
88
+ avutil: YES (ver 55.78.100)
89
+ swscale: YES (ver 4.8.100)
90
+ avresample: YES (ver 3.7.0)
91
+ GStreamer: NO
92
+ DirectShow: YES
93
+
94
+ Parallel framework: Concurrency
95
+
96
+ Trace: YES (with Intel ITT)
97
+
98
+ Other third-party libraries:
99
+ Intel IPP: 2017.0.3 [2017.0.3]
100
+ at: C:/Miniconda3/conda-bld/opencv-suite_1533128839831/work/build/3rdparty/ippicv/ippicv_win
101
+ Intel IPP IW: sources (2017.0.3)
102
+ at: C:/Miniconda3/conda-bld/opencv-suite_1533128839831/work/build/3rdparty/ippicv/ippiw_win
103
+ Lapack: NO
104
+ Eigen: YES (ver 3.3.3)
105
+ Custom HAL: NO
106
+ Protobuf: build (3.5.1)
107
+
108
+ Python (for build): C:/Miniconda3/python.exe
109
+
110
+ Java:
111
+ ant: NO
112
+ JNI: NO
113
+ Java wrappers: NO
114
+ Java tests: NO
115
+
116
+ Install to: C:/Miniconda3/conda-bld/opencv-suite_1533128839831/_h_env/Library
117
+ -----------------------------------------------------------------
118
+ ```
9
119
  再インストール(ビルド)については[Linux - OpenCV VideoCaptureが動作しない](https://teratail.com/questions/58787)が参考になりそうです(とても面倒そうですが)

2

修正

2018/12/07 08:01

投稿

8524ba23
8524ba23

スコア38352

answer CHANGED
@@ -1,9 +1,9 @@
1
1
  動作未検証ですが
2
2
 
3
3
  - `cap = cv2.VideoCapture(-1)`でアクティブなカメラを自動指定する。
4
- - `cap = cv2.VideoCapture('適当な動画.mp4')を指定する。
4
+ - `cap = cv2.VideoCapture('適当な動画.mp4')`を指定する。
5
5
 
6
6
  のいずれか動作するか試してみてはいかがでしょうか?
7
7
 
8
- ダメであれば、そもそも`OpenCV`に動画関連の機能が組み込まれていないのかもしれませんので、`OpenCV`の導入方法から詳細確認、あるいは再インストールが必要だと思います。
8
+ ダメであれば、そもそも`OpenCV`に動画関連の機能が組み込まれていないのかもしれませんので、`OpenCV`の導入方法から詳細確認、あるいは再インストール(ビルド)が必要だと思います。
9
- 再インストールについては[Linux - OpenCV VideoCaptureが動作しない](https://teratail.com/questions/58787)が参考になりそうです(とても面倒そうですが)
9
+ 再インストール(ビルド)については[Linux - OpenCV VideoCaptureが動作しない](https://teratail.com/questions/58787)が参考になりそうです(とても面倒そうですが)

1

追記

2018/12/07 07:41

投稿

8524ba23
8524ba23

スコア38352

answer CHANGED
@@ -5,4 +5,5 @@
5
5
 
6
6
  のいずれか動作するか試してみてはいかがでしょうか?
7
7
 
8
- ダメであれば、そもそも`OpenCV`に動画関連の機能が組み込まれていないのかもしれませんので、`OpenCV`の導入方法から詳細確認が必要だと思います。
8
+ ダメであれば、そもそも`OpenCV`に動画関連の機能が組み込まれていないのかもしれませんので、`OpenCV`の導入方法から詳細確認、あるいは再インストールが必要だと思います。
9
+ 再インストールについては[Linux - OpenCV VideoCaptureが動作しない](https://teratail.com/questions/58787)が参考になりそうです(とても面倒そうですが)