import cv2
import numpy as np
import urllib.request
url = 'http://192.168.31.152/cam-hi.jpg'
cap = cv2.VideoCapture(url)
whT = 320
confThreshold = 0.5
nmsThreshold = 0.3
classesfile = 'coco.names'
classNames = []
with open(classesfile, 'rt') as f:
classNames = f.read().rstrip('\n').split('\n')
modelConfig = 'yolov3.cfg'
modelWeights = 'yolov3.weights'
net = cv2.dnn.readNetFromDarknet(modelConfig, modelWeights)
net.setPreferableBackend(cv2.dnn.DNN_BACKEND_OPENCV)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU)
def findObject(outputs, im):
hT, wT, cT = im.shape
bbox = []
classIds = []
confs = []
found_cat = False
found_bird = False
for output in outputs:
for det in output:
scores = det[5:]
classId = np.argmax(scores)
confidence = scores[cla
ESP32-CAM 的识别代码
于 2024-02-13 20:57:21 首次发布