python如何調(diào)用攝像頭拍攝數(shù)據(jù)集-創(chuàng)新互聯(lián)

這篇文章主要為大家展示了“python如何調(diào)用攝像頭拍攝數(shù)據(jù)集”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“python如何調(diào)用攝像頭拍攝數(shù)據(jù)集”這篇文章吧。

禮縣網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),禮縣網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為禮縣上1000+提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)要多少錢,請找那個售后服務(wù)好的禮縣做網(wǎng)站的公司定做!

使用方法:

  • 指定name的名稱,name為分類的標(biāo)簽

  • 按n鍵拍攝圖片

  • 程序會在當(dāng)前目錄下生成一個pictures的文件夾,圖片存放在其中

print("正在初始化攝像頭...")
import cv2
import os
import datetime
cap = cv2.VideoCapture(0)
print("初始化成功!")
 
# name='play_phone'
# name='haqian'
# name='spleeing'
# name='zhengchang'
# name="zhedang"
name="waitou"
 
savedpath =r'./pictures/'+name
isExists = os.path.exists(savedpath)
if not isExists:
  os.makedirs(savedpath)
  print('path of %s is build' % (savedpath))
else:
  print('path of %s already exist and rebuild' % (savedpath))
print("按N鍵拍攝圖片")
i=0
while(True):
  ret, frame = cap.read()
  gray = cv2.cvtColor(frame, 1)
  cv2.imshow('test',frame)
  now = datetime.datetime.now()
  now = now.strftime('%m-%d-%H-%M-%S')
  savedname = '/'+name+ '_' + str(i) + '_{0}' '.jpg'.format(now)
  if cv2.waitKey(1) & 0xFF == ord('n'):  #按N拍攝
    i += 1
    cv2.imwrite(savedpath + savedname, frame)
    cv2.namedWindow("Image")
    cv2.imshow("Image", frame)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
 
cap.release()
cv2.destroyAllWindows()

以上是“python如何調(diào)用攝像頭拍攝數(shù)據(jù)集”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

分享標(biāo)題:python如何調(diào)用攝像頭拍攝數(shù)據(jù)集-創(chuàng)新互聯(lián)
標(biāo)題網(wǎng)址:http://muchs.cn/article6/dscjog.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計、網(wǎng)頁設(shè)計公司用戶體驗、面包屑導(dǎo)航小程序開發(fā)、關(guān)鍵詞優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)