일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 중고나라
- 로맨스스캠
- shell_gpt
- 네이버카페
- intelmac
- speed-measure-webpack-plugin
- ue4dumper
- 채팅환전사기
- Sequoia
- 안전결제
- esbuild
- 취약점
- open redirect
- 보이스피싱 #대검찰청 #명의도용 #비밀번호 #계좌번호 #공공기관 #가짜검찰청
- MongoDB #NoSQL #CreateUser #DropUser #mongod #mognod.conf
- CJ대한통운 #쿠팡 #통관번호오류 #통관고유번호오류 #안주원팀장 #모건인베스트
- ssrf
- 허리디스크
- Malware Sample
- react
- 많다..
- Frida
- self-signed
- NUGU
- XSS
- 변태는
- 모의해킹
- 거래사기
- 척추관협착증
- CryptoJS
Archives
- Today
- Total
annyoung
python get image from video using cv2 (VIDEOIO ERROR: V4L: can't find camera device) 본문
프로그래밍
python get image from video using cv2 (VIDEOIO ERROR: V4L: can't find camera device)
nopsled 2019. 1. 30. 10:59* MENTION : Ubuntu 16.05 LTS with python 2.7 installed on Azure.
This example works fine on my local. but doesn't work on my VM. so i'm keep messing up.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import cv2 def video2frame(invideofilename, save_path): vidcap = cv2.VideoCapture(invideofilename) count = 0 while True: success,image = vidcap.read() if not success: break print ('Read a new frame: ', success) fname = "{}.jpg".format("{0:05d}".format(count)) cv2.imwrite(save_path + fname, image) # save frame as JPEG file count += 1 print("{} images are extracted in {}.". format(count, save_path)) | cs |
but, finally i realized that my virtual machine doesn't have any carmera device.
1 2 3 4 5 6 7 8 9 10 11 | Python 2.7.12 (default, Nov 12 2018, 14:36:49) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> cv2.VideoCapture(0) VIDEOIO ERROR: V4L: can't open camera by index 0 <VideoCapture 0x7f44197b6810> >>> cv2.VideoCapture(-1) VIDEOIO ERROR: V4L: can't find camera device <VideoCapture 0x7f44197b6770> >>> | cs |
i'm try to install many things.
1 2 3 4 5 6 7 8 9 | git clone https://github.com/opencv/opencv.git mkdir build cd build cmake ../opencv make | cs |
1 | sudo apt-get install cheese libav-tools libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libx264-dev | cs |
but finally resolve this problem when i install this opencv and many libs.
* additional : still doesn't work if i use cv2.VideoCapture from video url. so i have to change logic. just use local video path if you use get video meta from video url.
1 2 3 4 5 6 7 | # don't use like this if you doing on VM with cv2 module. import cv2 vid = cv2.VideoCapture("https://example.com/test.mp4") success, img = vid.read() if success: print len(img) print type(img) | cs |
1 2 3 4 5 6 7 | # change from video url to local path. import cv2 vid = cv2.VideoCapture("./video.mp4") success, img = vid.read() if success: print len(img) print type(img) | cs |
Don't use video url. if you doing on VM with cv2 module.
'프로그래밍' 카테고리의 다른 글
ubuntu apache2+tomcat command line tool as python instead of service (0) | 2019.02.22 |
---|---|
Azure blob storage SDK set Content-Type using php (0) | 2019.02.12 |
python pyodbc 설치 탐험기 (0) | 2018.06.04 |
[javascript] calculate datetime (0) | 2018.04.24 |
[javascript] get ip only using javascript (5) | 2018.04.19 |
Comments