Opencv 之 DNN 与 CUDA综述
Posted 明月醉窗台
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Opencv 之 DNN 与 CUDA综述相关的知识,希望对你有一定的参考价值。
Opencv 之 DNN 与 CUDA 目录
- Opencv官方手稿(包含各模块API介绍及使用例程)
- Opencv中官方给定的DNN模块介绍:https://github.com/opencv/opencv/wiki/Deep-Learning-in-OpenCV
- Opencv在github的仓库地址:https://github.com/opencv
- Opencv额外的测试数据 下载:https://github.com/opencv/opencv_extra
#可通过git下载拉取
git clone https://github.com/opencv/opencv_extra.git
-
开源Opencv+contrib - 455:https://gitcode.net/openmodel/opencv
- 深度学习是当今计算机视觉中最受欢迎和增长最快的领域。从 OpenCV 3.1 开始,库中有 DNN 模块,该模块通过深度网络实现正向传递(推理),并使用一些流行的深度学习框架(如 Caffe)进行预训练。在OpenCV 3.3中,该模块已从opencv_contrib存储库提升到主存储库(https://github.com/opencv/opencv/tree/master/modules/dnn),并已显着加速。
- 该模块没有任何额外的依赖关系,除了libprotobuf,libprotobuf现在包含在OpenCV中。
1.DNN模块
- opencv中的DNN模块对接深度学习框架的一些API、C++复现过来的深度学习模型(目标检测、分割)
- 官方介绍:https://docs.opencv.org/4.x/d2/d58/tutorial_table_of_content_dnn.html
#ifndef OPENCV_DNN_HPP
#define OPENCV_DNN_HPP
// This is an umbrella header to include into you project.
// We are free to change headers layout in dnn subfolder, so please include
// this header for future compatibility
/** @defgroup dnn Deep Neural Network module
@
This module contains:
- API for new layers creation, layers are building bricks of neural networks;
- set of built-in most-useful Layers;
- API to construct and modify comprehensive neural networks from layers;
- functionality for loading serialized networks models from different frameworks.
Functionality of this module is designed only for forward pass computations (i.e. network testing).
A network training is in principle not supported.
@
*/
/** @example samples/dnn/classification.cpp
Check @ref tutorial_dnn_googlenet "the corresponding tutorial" for more details
*/
/** @example samples/dnn/colorization.cpp
*/
/** @example samples/dnn/object_detection.cpp
Check @ref tutorial_dnn_yolo "the corresponding tutorial" for more details
*/
/** @example samples/dnn/openpose.cpp
*/
/** @example samples/dnn/segmentation.cpp
*/
/** @example samples/dnn/text_detection.cpp
*/
#include <opencv2/dnn/dnn.hpp>
#endif /* OPENCV_DNN_HPP */
2. CUDA模块
- CUDA模块即Opencv中的GPU模块,用于视觉算法实现过程中的加速
- 官方介绍:https://docs.opencv.org/4.x/da/d2c/tutorial_table_of_content_gpu.html
cuda的使用在目录.\\opencv-contrib\\include\\opencv2\\dnn\\dnn.cpp
中可以找到
//其中包括
/**
* @brief Enum of computation backends supported by layers.
* @see Net::setPreferableBackend
*/
enum Backend
//! DNN_BACKEND_DEFAULT equals to DNN_BACKEND_INFERENCE_ENGINE if
//! OpenCV is built with Intel's Inference Engine library or
//! DNN_BACKEND_OPENCV otherwise.
DNN_BACKEND_DEFAULT = 0,
DNN_BACKEND_HALIDE,
DNN_BACKEND_INFERENCE_ENGINE, //!< Intel's Inference Engine computational backend
//!< @sa setInferenceEngineBackendType
DNN_BACKEND_OPENCV,
DNN_BACKEND_VKCOM,
DNN_BACKEND_CUDA,
DNN_BACKEND_WEBNN,
#ifdef __OPENCV_BUILD
DNN_BACKEND_INFERENCE_ENGINE_NGRAPH = 1000000, // internal - use DNN_BACKEND_INFERENCE_ENGINE + setInferenceEngineBackendType()
DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019, // internal - use DNN_BACKEND_INFERENCE_ENGINE + setInferenceEngineBackendType()
#endif
;
/**
* @brief Enum of target devices for computations.
* @see Net::setPreferableTarget
*/
enum Target
DNN_TARGET_CPU = 0,
DNN_TARGET_OPENCL,
DNN_TARGET_OPENCL_FP16,
DNN_TARGET_MYRIAD,
DNN_TARGET_VULKAN,
DNN_TARGET_FPGA, //!< FPGA device with CPU fallbacks using Inference Engine's Heterogeneous plugin.
DNN_TARGET_CUDA,
DNN_TARGET_CUDA_FP16,
DNN_TARGET_HDDL
;
专栏目录
以上是关于Opencv 之 DNN 与 CUDA综述的主要内容,如果未能解决你的问题,请参考以下文章