Dnn tiny yolo selecting between graylevel and color image c++

asked 2019-06-23 06:31:14 -0500

Shay Weissman gravatar image
  • OpenCV => 3.4.5
    • Operating System / Platform => Windows 7/10 64 Bit
    • Compiler => Visual Studio 2015
    • Languege C++ I have 2 trained tiny yolo models. One trained on 3 channel (RGB) data and one trained on one channel (GRAY LEVEL) data. The difference is in the channels parameter in the cfg file. When I prepare the blob I need to know how many channels to give (blobFromImage). I want to get that info from the loaded network. I thought I can get it gy getLayershapes() am I right? If yet then the first input parameter (cv::dnn::MatShape netInputShape) How do I get it? thanks.
edit retag flag offensive close merge delete

Comments

I want to get that info from the loaded network.

you can't. the layersizes are still variable, and only have something meaningful in it after you call net.setInput(). and that's where the cat bites its tail.

you probably have 2 different .cfg files for your models, maybe you can infer the channel size from the resp. filenames ?

berak gravatar imageberak ( 2019-06-23 11:32:42 -0500 )edit

Maybe you can try to get the first convolution layer and determine input channels number by it's weights.

dkurt gravatar imagedkurt ( 2019-06-24 22:40:35 -0500 )edit