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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

利用深度學(xué)習(xí)和OpenCV實(shí)現(xiàn)物體檢測(cè)

標(biāo)簽:
Java

FR-CNNs慢但是准确性高,YOLO很快但是精度差点。SSDs平衡了这两种算法。如果再结合Google提出的MobileNets优化网络结构,可以得到很理想的效果。

下面贴出源码:

import numpy as npimport cv2

imagefile = 'images/test02.jpg'deploy_prototxt = 'MobileNetSSD_deploy.prototxt'model = 'MobileNetSSD_deploy.caffemodel'confidence_default = 0.2CLASSES = ["background", "aeroplane", "bicycle", "bird", "boat",           "bottle", "bus", "car", "cat", "chair", "cow", "diningtable",           "dog", "horse", "motorbike", "person", "pottedplant", "sheep",           "sofa", "train", "tvmonitor"]
COLORS = np.random.uniform(0, 255, size=(len(CLASSES), 3))

print("[info] loading model...")
net = cv2.dnn.readNetFromCaffe(deploy_prototxt, model)

image = cv2.imread(imagefile)
(h, w) = image.shape[:2]
blob = cv2.dnn.blobFromImage(cv2.resize(image, (300, 300)), 0.007843, (300, 300), 127.5)

print("[info] computing object detections...")
net.setInput(blob)
detections = net.forward()for i in np.arange(0, detections.shape[2]):
    confidence = detections[0, 0, i, 2]    if confidence > confidence_default:
        idx = int(detections[0, 0, i, 1])
        box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
        (startX, startY, endX, endY) = box.astype("int")

        label = "{}: {:.2f}%".format(CLASSES[idx], confidence * 100)
        print("[info] {}".format(label))
        cv2.rectangle(image, (startX, startY), (endX, endY), COLORS[idx], 2)
        y = startY - 15 if startY - 15 > 15 else startY + 15
        cv2.putText(image, label, (startX, y), cv2.FONT_HERSHEY_SIMPLEX, 0.5, COLORS[idx], 2)

cv2.imshow("output", image)
cv2.waitKey(0)

OpenCV需要3.3以上支持,因为代码中用到了cv2.dnn模块。

检测效果:

webp

output



作者:飞天小小猫
链接:https://www.jianshu.com/p/e9a6c1eac2c9
x


點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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

舉報(bào)

0/150
提交
取消