Apply HED by opencv and c++
This page explain how to do it, you can find the link of the model and prototxt from there too. The author register a new layer, without it opencv cannot generate proper results.
Apply DexiNed by opencv and c++
You can find out the explanation of DexiNed from this page, in order to perform edge detection by DexiNed, we need to convert the model to onnx, I prefer pytorch for this purpose. Why I do not prefer tensorflow? Because convert the model of tensorflow to the format opencv can read is much more complicated from my ex experiences, tensorflow is feature rich but I always feel like they are trying very hard to make things unnecessary complicated, their notoriously bad api design explain this very well.
1.Convert pytorch model of DexiNed to onnx
- Clone the project blogCodes2
- Navigate into edges_detection_with_deep_learning
- Clone the project DexiNed
- Copy the file model.py in edges_detection_with_deep_learning/model.py into DexiNed/DexiNed-Pytorch
- Run the script to_onnx.py
2.Load and forward image by DexiNed and HED
3. Detect edges of image
4. Detect edges of video
Results of image detection
Results of video detection
Runtime performance on gpu(gtx 1060)Following results are based on the video I posted on youtube.The video has 733 images. From left to right is original frame, frame processed by HED, frame processed by DexiNed.
HED elapsed time is 43870ms, fps is 16.7085.
DexiNed elapsed time is 45149ms, fps is 16.2351.
The crop layer of HED do not support cuda, it should become faster after the cuda layer is done.
Located at github.