第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

為什么我會(huì)收到此錯(cuò)誤?'NoneType'對(duì)象在opencv中沒(méi)有屬性'shape'

為什么我會(huì)收到此錯(cuò)誤?'NoneType'對(duì)象在opencv中沒(méi)有屬性'shape'

天涯盡頭無(wú)女友 2023-09-02 16:22:31
我正在研究實(shí)時(shí)服裝檢測(cè)。所以我從 GitHub 借用了這樣的代碼: https: //github.com/rajkbharali/Real-time-clothes-detection 但是(H, W) = frame.shape[:2]:最后一行出現(xiàn)以下錯(cuò)誤。我應(yīng)該在哪里修復(fù)它?from time import sleepimport cv2 as cvimport argparseimport sysimport numpy as npimport os.pathfrom glob import globimport imutilsfrom imutils.video import WebcamVideoStreamfrom imutils.video import FPSfrom google.colab import drivedrive.mount('/content/drive')%cd /content/drive/My Drive/experiment/Yolo_mark-master/x64/Release/Labels = []classesFile1 = "data/obj.names";with open(classesFile1, 'rt') as f:    Labels = f.read().rstrip('\n').split('\n')np.random.seed(42)COLORS = np.random.randint(0, 255, size=(len(Labels), 3), dtype="uint8")weightsPath = "obj_4000.weights"configPath = "obj.cfg"net1 = cv.dnn.readNetFromDarknet(configPath, weightsPath)net1.setPreferableBackend(cv.dnn.DNN_BACKEND_OPENCV)net1.setPreferableTarget(cv.dnn.DNN_TARGET_CPU)image = WebcamVideoStream(src=0).start()fps = FPS().start()#'/home/raj/Documents/yolov3-Helmet-Detection-master/safety.mp4'#while fps._numFrames<100:while True:#for fn in glob('images/*.jpg'):    frame = image.read()    #frame = imutils.resize(frame,width=500)    (H, W) = frame.shape[:2]
查看完整描述

1 回答

?
蕭十郎

TA貢獻(xiàn)1815條經(jīng)驗(yàn) 獲得超13個(gè)贊

您的錯(cuò)誤背后的原因是框架是None(Null). 有時(shí),從網(wǎng)絡(luò)攝像頭捕獲的第一幀是“無(wú)”,主要是因?yàn)?(1)網(wǎng)絡(luò)攝像頭尚未準(zhǔn)備好(并且需要一些額外的時(shí)間才能準(zhǔn)備好)或者(2)操作系統(tǒng)不允許您的代碼訪問(wèn)網(wǎng)絡(luò)攝像頭。


在第一種情況下,在對(duì)框架執(zhí)行任何操作之前,您需要檢查框架是否有效:


while True:

?

? ? frame = image.read()

? ? if frame is not None:? # add this line

? ? ? ?

? ? ? (H, W) = frame.shape[:2]

在其他情況下,您需要檢查操作系統(tǒng)中的相機(jī)設(shè)置。


此外,為了捕獲網(wǎng)絡(luò)攝像頭幀,還有另一種基于Opencv 中的VideoCapure類的方法,該方法可能更容易調(diào)試。



查看完整回答
反對(duì) 回復(fù) 2023-09-02
  • 1 回答
  • 0 關(guān)注
  • 171 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)