How does one create custom convolution, maxpool and softmax layers in Opencv dnn module?

asked 2019-03-05 09:05:50 -0600

Tuc gravatar image

I am trying to implement a custom object detection network without Tensorflow dependency. My weights are stored in nchw order in binary file and can easily be loaded into cv::Mat. However, I can't seem to find an example of how to build custom layers in dnn module. Official documentation is slightly confusing for me.

edit retag flag offensive close merge delete

Comments

Here is link: convolution, maxpool and softmax. And this too:maxpool

supra56 gravatar imagesupra56 ( 2019-03-05 09:17:39 -0600 )edit

here's an example of a custom (cv2.dnn) layer: https://github.com/opencv/opencv/blob...

and some boilerplate c++ code: https://github.com/opencv/opencv/blob...

berak gravatar imageberak ( 2019-03-05 10:09:31 -0600 )edit

Maybe I expressed myself wrongly, I didn't mean how ti implement it, but how to create for example a cv::dnn::Convolution layer and add it to cv::dnn::Net with function int cv::dnn::Net::addLayerToPrev ( const String & name, const String & type, LayerParams & params ). Basically what should parameters name, type and params be if I want to add new convolution layer with kernel size 3x3, input channels 3, output channels 10 and stride 1.

Tuc gravatar imageTuc ( 2019-03-11 06:25:58 -0600 )edit