资源简介
运行非常好,由于文件太大,请自己下载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版
- 下一篇:德尔福小发动机管理系统
相关资源
- 支持向量机的船舶目标识别
- 基于OpenCV的数字识别468815
- 使用opencv去掉二值化图像中黑色面积
- opencv环境配置
- win10 64位下编译的opencv4.5.5库,opencv
- NVIDIAOpticalFlowSDK-79c6cee80a2df9a196f20afd6
- opencv_contrib-3.4.0.zip
- opencv2.4.9源码分析——SIFT
- 用两个摄像头实现,双目标定,双目
- opencv_traincascade训练分类器,手势识别
- opencv3.0交叉编译用parallel.cpp
- 基于opencv的图像识别识别图像中的色
- 基于openCV的识别特定颜色区域
- 基于OpenCV的分水岭算法实现
- QT+opencv+OCR 身份证号码,银行卡号识别
- opencv视频特定颜色区域识别
- 把RGB转换为HSV和HSI然后根据黄色和蓝
- opencv视觉测距
- 基于Qt和opencv的身份证号码识别系统
- opencv_ffmpeg249.dll
- SfM稀疏三维点云重建--完整工程文件
- 基于opencv的数人头程序源代码
- 自然场景OCRYOLOv3+CTPN+CRNN检测
- darknet——yolov3
- 利用OpenCV中的Stitcher类实现全景图像拼
- opencv实现的sift算法源码,包含了图像
- openCV 上的小波变换
- 基于OPENCV的车牌识别系统设计
- 617张国内车牌60-17bmp图片用于OpenCV正样
- hog特征提取,c版本代码
评论
共有 条评论