欧美三区_成人在线免费观看视频_欧美极品少妇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條評論
主站蜘蛛池模板: 一级黄片毛片免费看 | 99热久久这里只有精品首页 | 天天久久综合网站 | 成年视频在线观看免费 | 欧美精品在线一区二区三区 | 久久成人一区二区 | 国产成人精品一区二区三区四区 | 亚洲日韩中文字幕一区 | 国产亚洲综合成人91精品 | 久久99精品久久久久久秒播 | 国产日韩精品一区 | 全黄性性激高免费视频 | 亚洲第一黄色网址 | 神马九九 | 午夜丁香| 免费黄色在线观看 | 成人免费视频网站 | 欧美视频第一页 | 国产黄在线观看免费观看软件视频 | 91视频无限看 | 四虎影视网站 | 黄免费在线观看 | 一区二区三区四区精品 | 久久免费看少妇高潮A片麻豆 | 亚洲一区免费 | 国产精品久久久久久久免费 | 日韩伦理一区 | 在线播放亚洲 | av官网在线| 久草这里只有精品 | 特级全黄| 免费的污污网站 | 午夜视频高清在线aaa | 欧美激情无码成人A片 | 欧美成人一级视频 | 天天综合亚洲 | 欧美一区二区三区在线可观看 | www.天天操| 欧美一级特黄毛片免费 | 亚洲免费在线视频 | 操操日|