opencv呼叫cv2.dnn_DetectionModel 用法
注意:opencv-python 目前只有 4.4.0 版本適配了 YOLOv4
1.模型獲取
百度網盤下載連結:https://pan.baidu.com/s/1XrcPHdp2_4c-dKge2Guw4w 提取碼:xsxb 。
2.匯入 YOLOv4配置和權重檔案並載入網路:
例:net =cv2.dnn_DetectionModel('yolov4.cfg', 'yolov4.weights')
3.檢測函式 cv2.dnn_DetectionModel.detect(frame[, confThreshold[, nmsThreshold]])
[in] frame:識別影像
[in] confThreshold 用於根據置信度篩選框的閾值
[in] nmsThreshold非極大值抑制中使用的閾值
該函式返回值:
[out] classIds 結果檢測中的類索引
[out] confidences 一組相應的置信度
[out] boxes 一組邊界框。
例:detection=net.detect(img)
4.畫出檢測框
函式cv2.rectangle(img, pt1, pt2, color[, thickness[, lineType[, shift]]])
pt1:左上的點座標,pt2:右下的點座標
[1] x,y,w,h=detection[2][0][0:4]
[2] cv2.rectangle(img, (x, y),(x+w, y+h),(255, 0,0 ), 2)
[3] cv2.imshow('detect',img)
相關文章
- opencv呼叫caffe模型OpenCV模型
- OpenCV findContours 與 drawContours 用法OpenCV
- C++中函式呼叫的用法C++函式
- GO 同 (異) 包呼叫以及 struct 的用法GoStruct
- Python基於opencv呼叫攝像頭獲取個人圖片PythonOpenCV
- java高階用法之:呼叫本地方法的利器JNAJava
- OpenCV()OpenCV
- opencvOpenCV
- java高階用法之:無所不能的java,本地方法呼叫實況Java
- delphi opencvOpenCV
- 【OpenCV教程】OpenCV中的資料型別OpenCV資料型別
- VS2019+opencv4.2.0+opencv contrib4.2.0OpenCV
- 【opencv學習筆記】001之opencv配置(win10+VS2015+OpenCV3.1.0)OpenCV筆記Win10
- get_images_similarity 呼叫失敗,提示沒有安裝 opencv4nodejs,實際已安裝MILAOpenCVNodeJS
- 【OpenCV教程】OpenCV中對矩陣的常用操作OpenCV矩陣
- opencv中SVMOpenCV
- opencv 學習OpenCV
- OpenCV(cv::minMaxLoc())OpenCV
- OpenCV(cv::convertScaleAbs())OpenCV
- OpenCV(cv::Canny())OpenCV
- OpenCV(Alpha通道)OpenCV
- OpenCV(cv::bilateralFilter())OpenCVFilter
- OpenCV(cv::circle())OpenCV
- OpenCV(cv::NAryMatIterator)OpenCV
- OpenCv(cv::undistort())OpenCV
- OpenCV(cv::findChessboardCorners())OpenCV
- OpenCV 基本使用OpenCV
- opencv-debugtoolOpenCV
- 使用vs2015+cmake編譯opencv+opencv_contrib編譯OpenCV
- 解決OpenCV(4.1.2) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:376: error: (-215:AOpenCVProjectPythonGUIError
- OpenCV 初體驗OpenCV
- 配置QT Mingw & opencvQTOpenCV
- OpenCV新增中文(五)OpenCV
- opencv + SVM 程式碼OpenCV
- opencv圖片操作OpenCV
- opencv SVM的使用OpenCV
- opencv 修改畫素OpenCV
- opencv 黑帽操作OpenCV