资源简介
运行非常好,由于文件太大,请自己下载yolov3.weights添加到yolo-coco文件夹下面
代码片段和文件信息
# import the necessary packages
import numpy as np
import argparse
import time
import cv2
import os
# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument(“-i“ “--image“ required=True
help=“path to input image“)
ap.add_argument(“-y“ “--yolo“ required=True
help=“base path to YOLO directory“)
ap.add_argument(“-c“ “--confidence“ type=float default=0.5
help=“minimum probability to filter weak detections“)
ap.add_argument(“-t“ “--threshold“ type=float default=0.3
help=“threshold when applying non-maxima suppression“)
args = vars(ap.parse_args())
# load the COCO class labels our YOLO model was trained on
labelsPath = os.path.sep.join([args[“yolo“] “coco.names“])
LABELS = open(labelsPath).read().strip().split(“\n“)
# initialize a list of colors to represent each possible class label
np.random.seed(42)
COLORS = np.random.randint(0 255 size=(len(LABELS) 3)
dtype=“uint8“)
# derive the paths to the YOLO weights and model configuration
weightsPath = os.path.sep.join([args[“yolo“] “yolov3.weights“])
configPath = os.path.sep.join([args[“yolo“] “yolov3.cfg“])
# load our YOLO object detector trained on COCO dataset (80 classes)
print(“[INFO] loading YOLO from disk...“)
net = cv2.dnn.readNetFromDarknet(configPath weightsPath)
# load our input image and grab its spatial dimensions
image = cv2.imread(args[“image“])
(H W) = image.shape[:2]
# determine only the *output* layer names that we need from YOLO
ln = net.getlayerNames()
ln = [ln[i[0] - 1] for i in net.getUnconnectedOutlayers()]
# construct a blob from the input image and then perform a forward
# pass of the YOLO object detector giving us our bounding boxes and
# associated probabilities
blob = cv2.dnn.blobFromImage(image 1 / 255.0 (416 416)
swapRB=True crop=False)
net.setInput(blob)
start = time.time()
layerOutputs = net.forward(ln)
end = time.time()
# show timing information on YOLO
print(“[INFO] YOLO took {:.6f} seconds“.format(end - start))
# initialize our lists of detected bounding boxes confidences and
# class IDs respectively
boxes = []
confidences = []
classIDs = []
# loop over each of the layer outputs
for output in layerOutputs:
# loop over each of the detections
for detection in output:
# extract the class ID and confidence (i.e. probability) of
# the current object detection
scores = detection[5:]
classID = np.argmax(scores)
confidence = scores[classID]
# filter out weak predictions by ensuring the detected
# probability is greater than the minimum probability
if confidence > args[“confidence“]:
# scale the bounding box coordinates back relative to the
# size of the image keeping in mind that YOLO actually
# returns the center (x y)-coordinates of the bounding
# box followed by
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 138 2019-01-04 20:03 物体识别成功案例\.idea\encodings.xm
文件 294 2019-01-04 20:03 物体识别成功案例\.idea\misc.xm
文件 307 2019-01-04 20:03 物体识别成功案例\.idea\modules.xm
文件 239 2019-01-04 20:05 物体识别成功案例\.idea\other.xm
文件 7044 2019-01-04 20:28 物体识别成功案例\.idea\workspace.xm
文件 534 2019-01-04 20:04 物体识别成功案例\.idea\物体识别成功案例.iml
文件 54989 2019-01-04 19:57 物体识别成功案例\images\bird.jpg
文件 51596 2019-01-04 20:01 物体识别成功案例\images\people1.jpg
文件 940204 2019-01-04 20:16 物体识别成功案例\output\1.PNG
文件 894003 2019-01-05 12:49 物体识别成功案例\output\2.PNG
文件 705 2019-01-04 16:33 物体识别成功案例\yolo-coco\coco.names
文件 9131 2019-01-04 16:33 物体识别成功案例\yolo-coco\yolov3.cfg
文件 4499 2019-01-04 20:13 物体识别成功案例\yolo.py
文件 284 2019-01-06 17:13 物体识别成功案例\说明.txt
目录 0 2019-01-04 20:28 物体识别成功案例\.idea
目录 0 2019-01-04 20:14 物体识别成功案例\images
目录 0 2019-01-05 12:49 物体识别成功案例\output
目录 0 2019-01-04 19:51 物体识别成功案例\yolo-coco
目录 0 2019-01-04 20:30 物体识别成功案例
----------- --------- ---------- ----- ----
1963967 19
- 上一篇:2019王道考研计算机网络复习指导 Word版
- 下一篇:德尔福小发动机管理系统
相关资源
- svm颜色分类
- QT OPENCV车牌识别 识别结果输出到Tex
- opencv3.2交叉编译移植笔记
- OpenCV人脸识别290071
- openCV库文件卷3
- opencv运动目标跟踪
- opencv基于颜色直方图进行模板图像匹
- pytorch_yolov3_2.zip
- 双目标定以及双目测距程序.rar
- OpenCV插件UE4
- opencv_world420.dll
- OpenCV 4.2.0 Visual Studio 2017 32位 版本
- OpenCV实现的图像2D转3D Image-2D-to-3D.ra
- yolo3-tiny plate.rar
- 一幅图片中画两个矩形
- VS2015编译好的opencv3.4.1+contrib3.4.1
- 基于opencv的双目相机标定代码
- 图片合成视频OpenCV
- 视频人脸追踪
- opencv2410forMinGw
- Tesseract 4.0 for VS2015及OpenCV数字识别程
- Computer Vision with OpenCV3 and Qt5完整版
- pb模型转pbtxtopencv调用
- Computer Vision with OpenCV 3 and Qt5
- 基于hog+pca+svm行人检测源码
- labelImg.zip
- Kmeans的opencv实现
- 基于VS2017+opencv3.4.3的立体匹配SGBM与
- OpenCV345_build_MinGW32bit
- Opencv+VS米粒图像处理实验源代码
评论
共有 条评论