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的SVM用法OpenCV
- opencv呼叫caffe模型OpenCV模型
- 命令列引數 opencv呼叫命令列OpenCV
- OpenCV findContours 與 drawContours 用法OpenCV
- opencv查詢輪廓---cvFindContours && cvDrawCountours 用法及例子OpenCV
- C++中函式呼叫的用法C++函式
- 用opencv實現的PCA演算法,非API呼叫OpenCVPCA演算法API
- GO 同 (異) 包呼叫以及 struct 的用法GoStruct
- Python基於opencv呼叫攝像頭獲取個人圖片PythonOpenCV
- java高階用法之:呼叫本地方法的利器JNAJava
- 對JavaScript呼叫堆疊和setTimeout用法的深入研究JavaScript
- 【OpenCV】OpenCV中GPU模組使用OpenCVGPU
- opencvOpenCV
- OpenCV()OpenCV
- delphi opencvOpenCV
- 【OpenCV教程】OpenCV中的資料型別OpenCV資料型別
- java高階用法之:無所不能的java,本地方法呼叫實況Java
- 【OpenCV教程】OpenCV中對矩陣的常用操作OpenCV矩陣
- opencv中SVMOpenCV
- opencv 學習OpenCV
- OpenCV 與 SVMOpenCV
- opencv SVM 使用OpenCV
- OpenCV學習OpenCV
- OpenCV(cv::minMaxLoc())OpenCV
- OpenCV(Alpha通道)OpenCV
- OpenCV 基本使用OpenCV
- OpenCV(cv::circle())OpenCV
- OpenCv(cv::undistort())OpenCV
- OpenCV(cv::findChessboardCorners())OpenCV
- OpenCV(cv::NAryMatIterator)OpenCV
- OpenCV(cv::bilateralFilter())OpenCVFilter
- CMake生成OpenCV解決方案&&編譯OpenCV原始碼OpenCV編譯原始碼
- get_images_similarity 呼叫失敗,提示沒有安裝 opencv4nodejs,實際已安裝MILAOpenCVNodeJS
- 【opencv學習筆記】001之opencv配置(win10+VS2015+OpenCV3.1.0)OpenCV筆記Win10
- mui點選訊息框的用法,及其點選呼叫按鈕撥打電話UI
- opencv mat轉IplImage*OpenCV
- opencv 黑帽操作OpenCV
- opencv 修改畫素OpenCV