Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ In order to keep a clean overview containing all contributed modules, the follow
1. Update the README.md file under the modules folder. Here, you add your model with a single-line description.

2. Add a README.md inside your own module folder. This README explains which functionality (separate functions) is available, links to the corresponding samples, and explains in somewhat more detail what the module is expected to do. If any extra requirements are needed to build the module without problems, add them here also.

fjut
2 changes: 2 additions & 0 deletions modules/hed/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set(the_module opencv_hed)
ocv_define_module(hed opencv_core opencv_imgproc opencv_dnn WRAP python)
26 changes: 26 additions & 0 deletions modules/hed/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# hed — Holistically-nested Edge Detection

Implements HED edge detection (Xie & Tu, 2015) as an OpenCV contrib module.
Unlike Canny, HED uses a pretrained VGG network to detect semantically
meaningful edges rather than raw pixel contrast changes.

## Paper
Xie, S., & Tu, 2015. Holistically-nested edge detection.
https://arxiv.org/abs/1504.06375

## Model files
Download from: https://vcl.ucsd.edu/hed/
- hed_pretrained_bsds.caffemodel
- deploy.prototxt

## Python usage
```python
detector = cv2.hed.HEDDetector.create("model.caffemodel", "deploy.prototxt")
edges = detector.detectEdges(image) # float32, values 0..1
```

## C++ usage
```cpp
auto det = cv::hed::HEDDetector::create("model.caffemodel", "deploy.prototxt");
cv::Mat edges = det->detectEdges(image);
```
52 changes: 52 additions & 0 deletions modules/hed/include/opencv2/hed.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#pragma once
#include "opencv2/core.hpp"
#include <string>

namespace cv {
namespace hed {

/** @defgroup hed Holistically-nested Edge Detection
This module implements HED edge detection as described in:

Xie, S., & Tu, Z. (2015). Holistically-nested edge detection.
Proceedings of the IEEE international conference on computer vision.
https://arxiv.org/abs/1504.06375
*/

//! @addtogroup hed
//! @{

/** @brief HED edge detector using a pretrained Caffe model.

Unlike classical detectors such as Canny, HED uses a VGG-based
convolutional network trained on human-annotated boundaries to
produce semantically meaningful edge maps.

@note Requires hed_pretrained_bsds.caffemodel and deploy.prototxt.
Download from: https://vcl.ucsd.edu/hed/
*/
class CV_EXPORTS_W HEDDetector {
public:
/** @brief Creates an HEDDetector instance.
@param modelPath path to hed_pretrained_bsds.caffemodel
@param protoPath path to deploy.prototxt
*/
CV_WRAP static cv::Ptr<HEDDetector> create(
const std::string& modelPath,
const std::string& protoPath
);

/** @brief Detects edges in an image.
@param image input BGR image (CV_8UC3)
@return edge map as CV_32F with values in [0, 1]
*/
CV_WRAP virtual cv::Mat detectEdges(cv::InputArray image) = 0;

/** @brief Destructor. */
virtual ~HEDDetector() {}
};

//! @}

} // namespace hed
} // namespace cv
Loading