# (left + round(1.5 * labelSize[0]), top + baseLine),(0, 255, 255), cv.FILLED) cv.putText(img, label, (left, top), cv.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 1) cv.imshow('camera', img) t = time.time() - prev_time print("FPS = %.2f , time=%.2fs" % (1 / t, t)) k = cv.waitKey(1) if k == 27: # esc ok = False elif k == 32: # ' ' bPause = not bPause cv.destroyAllWindows() cap.release() if __name__ == "__main__": fClasses = "./mod/dark/tiny/tiny.names" modelCfg = "./mod/dark/tiny/tiny.cfg" modelWeights = "./mod/dark/tiny/tiny.weights" # 初始化对象 yolo = yolo3.CV_Yolo3(fClasses, confThreshold=0.5, nmsThreshold=0.5) print("Classes =", len(yolo3.Yolo3_Classes)) # 设置配置文件 yolo.cv_dnn_init(modelCfg, modelWeights) openvideo(yolo, './img/v1.mp4')
# coding: utf-8 # # 程序功能 :调用 Yolo3 库,识别图片中的 object import cv2 as cv import numpy as np import opencv_yolo3 as yolo3 import time fClasses = "./mod/dark/coco/coco.names" modelCfg = "./mod/dark/coco/coco.cfg" modelWeights = "./mod/dark/coco/coco.weights" # 初始化对象 bt = time.time() yolo = yolo3.CV_Yolo3(fClasses) print("Classes =", len(yolo3.Yolo3_Classes)) # 设置配置文件 yolo.cv_dnn_init(modelCfg, modelWeights) t1 = time.time() print("Time of Init Yolo :", t1 - bt) image_path = "./img/jj001.jpg" img = cv.imread(image_path) dects, runtime = yolo.yolov3_predict(img) # 识别图片, 返回 对象集 和 运行时间 t2 = time.time() print("Time of Detect Img :", t2 - t1) #print(dects) yolo3.Yolo3_ShowInfos(img, dects, runtime)