Python呼叫攝像頭

2021-10-10 17:04:51 字數 705 閱讀 1700

**如下:

import cv2

import numpy

# 建立攝像頭物件

cap = cv2.videocapture(

"videotest/test1.mp4"

)( cap = cv2.videocapture(0)

#引數為本地攝像頭 )

( cap = cv2.videocapture(1)

#引數為usb攝像頭 )

while 1:

ret, frame = cap.read(

)#讀取

cv2.imshow(

"capture", frame)

#顯示if cv2.waitkey(100)

& 0xff == ord(

'q'):   #按q退出

break

或 while

(cv2.waitkey(5)

!= 27): #按esc退出

ret, frame = cap.read(

)#讀取

cv2.imshow(

"capture", frame)

#顯示# 釋放攝像頭物件和視窗

cap.release(

)cv2.destroyallwindows(

)

參考部落格:

Android 呼叫攝像頭

androidmanifest新增許可權 intent呼叫開啟照相機 intent intent new intent mediastore.action image capture file file new file environment.getexternalstoragedirectory...

ffmpeg nginx dash呼叫攝像頭直播

參考 nginx安裝,需原始碼編譯,因為需要新增nginx rtmp module 模組 其次nginx的版本不要太低,以免make的時候出錯。安裝依賴 sudo apt get update sudo apt get install libpcre3 libpcre3 dev sudo apt g...

python遠端呼叫攝像頭 Python呼叫攝像頭

一 開啟攝像頭 import cv2 import numpy as np def video demo capture cv2.videocapture 0 0為電腦內建攝像頭 while true frame cv2.flip frame,1 攝像頭是和人對立的,將影象左右調換回來正常顯示。cv...