欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

python opencv捕獲攝像頭并顯示內容的實現

系統 1652 0

1、捕獲攝像頭和實時顯示

            
import cv2
import numpy as np
import pickle
import matplotlib.pyplot as plt
 
cap = cv2.VideoCapture(0)
 
while True:
  ret,frame = cap.read()
  # Our operations on the frame come here
  gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
  # Display the resulting frame
  cv2.imshow('frame',gray)
  if cv2.waitKey(1) & 0xFF == ord('q'):
    break
 
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows() 

          

2、從攝像頭內抓拍圖片

            
import cv2
import numpy as np
import pickle
import matplotlib.pyplot as plt
 
cap = cv2.VideoCapture(0)
index = 0
while True:
  ret,frame = cap.read()
  # Our operations on the frame come here
  gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
  # Display the resulting frame
  cv2.imshow('frame',gray)
  if cv2.waitKey(1) & 0xFF == ord('p'):
    cv2.imwrite("kk.jpg",frame)
    index = index + 1
  if cv2.waitKey(1) & 0xFF == ord('q'):
    break
 
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows() 

          

補充:python-----從本地攝像頭和網絡攝像頭截取圖片

            
import cv2

# 獲取本地攝像頭
# folder_path 截取圖片的存儲目錄
def get_img_from_camera_local(folder_path):
  cap = cv2.VideoCapture(0)
  i = 1
  while True:
    ret, frame = cap.read()
    cv2.imshow("capture", frame)
    print str(i)
    cv2.imwrite(folder_path + str(i) + '.jpg', frame) # 存儲為圖像
    if cv2.waitKey(1) & 0xFF == ord('q'):
      break
    i += 1
  cap.release()
  cv2.destroyAllWindows()

# 獲取網絡攝像頭,格式:rtsp://username:pwd@ip/
# folder_path 截取圖片的存儲目錄
def get_img_from_camera_net(folder_path):
  cap = cv2.VideoCapture('rtsp://username:pwd@ip/')
  i = 1
  while True:
    ret, frame = cap.read()
    cv2.imshow("capture", frame)
    print str(i)
    cv2.imwrite(folder_path + str(i) + '.jpg', frame) # 存儲為圖像
    if cv2.waitKey(1) & 0xFF == ord('q'):
      break
    i += 1
  cap.release()
  cv2.destroyAllWindows()

# 測試
if __name__ == '__main__':
  folder_path = 'D:\\img_from_camera\\'
  get_img_from_camera_local(folder_path)


          

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 亚洲日本久久久午夜精品 | 国产91精品久久久久久久 | 男女一进一出无遮挡黄 | 成人免费在线视频网站 | 色屁屁影院www免费 特片网久久 | 色在线免费 | 色婷婷久久久亚洲一区二区三区 | 羞羞在线视频 | 97一本大道波多野吉衣 | 就去色成人网 | 羞羞视频免费网站在线看 | 欧美国产激情二区三区 | 91精品国产91久久久久久 | 国产美女高清片免费观看 | 日日爽天天 | 九九九九精品视频在线播放 | 久久色伦理资源站 | 日韩大片免费在线观看 | 亚洲视频 欧美视频 | 中文字幕日韩欧美一区二区三区 | 欧美综合亚洲 | 日本一区免费 | 亚洲视频欧美 | 国内成人自拍视频 | 九九热在线免费观看 | 中文字幕 在线观看 | 久久久久久久av | 国产亚洲精品久久久久久久久动漫 | 五月综合久久 | 色婷婷视频 | 天堂成人在线 | 国产精品久久久久久久免费大片 | 浮力影院最新地址 | 国产高清一区二区三区 | 小明永久成人一区二区 | 黄色激情小视频 | 亚洲成人日韩 | 超碰97人| 国产精品久久久久久亚洲伦理 | 激情深爱 | 久久99国产精品 |