<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV = 4.0.0-pre</li>
<li>Operating System / Platform = Ubuntu 16.04</li>
<li>Compiler = GCC (4.8)</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">I've trained a darknet classifier to classify digits ,  classifier works correctly on the darknet framework , but when I load it to opencv using the <a href="https://github.com/opencv/opencv/blob/master/samples/dnn/classification.cpp">classification.cpp</a> sample (with minor modifications to load image from file), I get same wrong result for every image.<br>
I've modified the scale, height and width parameters as mentioned in other issues but get the same result.<br>
here is the darknet result:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/43341727/45631397-79c21c00-baa3-11e8-89a3-a39623c49295.png"><img src="https://user-images.githubusercontent.com/43341727/45631397-79c21c00-baa3-11e8-89a3-a39623c49295.png" alt="darknet_output" style="max-width: 100%;"></a><br>
and opencv code result:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/43341727/45631433-8a729200-baa3-11e8-87b0-b1314359ddfb.png"><img src="https://user-images.githubusercontent.com/43341727/45631433-8a729200-baa3-11e8-87b0-b1314359ddfb.png" alt="opencv_output" style="max-width: 100%;"></a></p>
<p dir="auto">attached is a zip file with network config and weights files,  and some image samples.<br>
Will greatly appreciate your help.</p>
<h5 dir="auto">Steps to reproduce</h5>
<ul dir="auto">
<li>Run the below code using attached zipped config files in opencv</li>
<li>command line parameters I've used are:<br>
-width=28 -height=28 -mean=0 0 0  scale=0.00392 -rgb</li>
</ul>
<p dir="auto"><a href="https://github.com/opencv/opencv/files/2389131/darknet-digits.zip">darknet-digits.zip</a></p>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#include &lt;fstream&gt;
#include &lt;sstream&gt;
#include &lt;iostream&gt;

#include &lt;opencv2/dnn.hpp&gt;
#include &lt;opencv2/imgproc.hpp&gt;
#include &lt;opencv2/highgui.hpp&gt;

const char* keys =
   &quot;{ help  h     | | Print help message. }&quot;
   &quot;{ input i     | | Path to input image or video file. Skip this argument to capture frames from a camera.}&quot;
   &quot;{ model m     | | Path to a binary file of model contains trained weights. &quot;
                     &quot;It could be a file with extensions .caffemodel (Caffe), &quot;
                     &quot;.pb (TensorFlow), .t7 or .net (Torch), .weights (Darknet) }&quot;
   &quot;{ config c    | | Path to a text file of model contains network configuration. &quot;
                     &quot;It could be a file with extensions .prototxt (Caffe), .pbtxt (TensorFlow), .cfg (Darknet) }&quot;
   &quot;{ framework f | | Optional name of an origin framework of the model. Detect it automatically if it does not set. }&quot;
   &quot;{ classes     | | Optional path to a text file with names of classes. }&quot;
   &quot;{ mean        | | Preprocess input image by subtracting mean values. Mean values should be in BGR order and delimited by spaces. }&quot;
   &quot;{ scale       | 1 | Preprocess input image by multiplying on a scale factor. }&quot;
   &quot;{ width       |   | Preprocess input image by resizing to a specific width. }&quot;
   &quot;{ height      |   | Preprocess input image by resizing to a specific height. }&quot;
   &quot;{ rgb         |   | Indicate that model works with RGB input images instead BGR ones. }&quot;
   &quot;{ backend     | 0 | Choose one of computation backends: &quot;
                       &quot;0: automatically (by default), &quot;
                       &quot;1: Halide language (http://halide-lang.org/), &quot;
                       &quot;2: Intel's Deep Learning Inference Engine (https://software.intel.com/openvino-toolkit), &quot;
                       &quot;3: OpenCV implementation }&quot;
   &quot;{ target      | 0 | Choose one of target computation devices: &quot;
                       &quot;0: CPU target (by default), &quot;
                       &quot;1: OpenCL, &quot;
                       &quot;2: OpenCL fp16 (half-float precision), &quot;
                       &quot;3: VPU }&quot;;

using namespace cv;
using namespace dnn;
using namespace std;

std::vector&lt;std::string&gt; classes;

int main(int argc, char** argv)
{
   CommandLineParser parser(argc, argv, keys);
   parser.about(&quot;Use this script to run classification deep learning networks using OpenCV.&quot;);
   if (argc == 1 || parser.has(&quot;help&quot;))
   {
       parser.printMessage();
       return 0;
   }

   float scale = parser.get&lt;float&gt;(&quot;scale&quot;);
   Scalar mean = parser.get&lt;Scalar&gt;(&quot;mean&quot;);
   bool swapRB = parser.get&lt;bool&gt;(&quot;rgb&quot;);
   int inpWidth = parser.get&lt;int&gt;(&quot;width&quot;);
   int inpHeight = parser.get&lt;int&gt;(&quot;height&quot;);
   String model = parser.get&lt;String&gt;(&quot;model&quot;);
   String config = parser.get&lt;String&gt;(&quot;config&quot;);
   String framework = parser.get&lt;String&gt;(&quot;framework&quot;);
   int backendId = parser.get&lt;int&gt;(&quot;backend&quot;);
   int targetId = parser.get&lt;int&gt;(&quot;target&quot;);

   // Open file with classes names.
   if (parser.has(&quot;classes&quot;))
   {
       std::string file = parser.get&lt;String&gt;(&quot;classes&quot;);
       std::ifstream ifs(file.c_str());
       if (!ifs.is_open())
           CV_Error(Error::StsError, &quot;File &quot; + file + &quot; not found&quot;);
       std::string line;
       while (std::getline(ifs, line))
       {
           classes.push_back(line);
       }
   }

   if (!parser.check())
   {
       parser.printErrors();
       return 1;
   }
   CV_Assert(!model.empty());

   //! [Read and initialize network]
   Net net = readNet(model, config, framework);
   net.setPreferableBackend(backendId);
   net.setPreferableTarget(targetId);
   //! [Read and initialize network]

   // Create a window
   static const std::string kWinName = &quot;Deep learning image classification in OpenCV&quot;;
   namedWindow(kWinName, WINDOW_NORMAL);

   //! [Open a video file or an image file or a camera stream]
   //VideoCapture cap;
   //if (parser.has(&quot;input&quot;))
   //    cap.open(parser.get&lt;String&gt;(&quot;input&quot;));
   //else
   //    cap.open(0);
   //! [Open a video file or an image file or a camera stream]

   // Process frames.
   Mat frame, blob;
   while (waitKey(1) != 27)
   {
       //cap &gt;&gt; frame;
       //if (frame.empty())
       //{
       //    waitKey();
       //    break;
       //}

       string filePath;
       cout &lt;&lt; &quot;enter file path: &quot; &lt;&lt; std::endl;
       cin &gt;&gt; filePath ;
       frame = imread(filePath, IMREAD_COLOR);
       
       //! [Create a 4D blob from a frame]
       blobFromImage(frame, blob, scale, Size(inpWidth, inpHeight), mean, swapRB, false);
       //! [Create a 4D blob from a frame]

       //! [Set input blob]
       net.setInput(blob);
       //! [Set input blob]
       //! [Make forward pass]
       Mat prob = net.forward();
       //! [Make forward pass]

       //! [Get a class with a highest score]
       Point classIdPoint;
       double confidence;
       minMaxLoc(prob.reshape(1, 1), 0, &amp;confidence, 0, &amp;classIdPoint);
       int classId = classIdPoint.x;
       //! [Get a class with a highest score]

       // Put efficiency information.
       std::vector&lt;double&gt; layersTimes;
       double freq = getTickFrequency() / 1000;
       double t = net.getPerfProfile(layersTimes) / freq;
       std::string label = format(&quot;Time: %.2f ms&quot;, t);
       putText(frame, label, Point(0, 15), FONT_HERSHEY_SIMPLEX, 0.3, Scalar(0, 255, 0));
       cout &lt;&lt; label &lt;&lt; endl;
       // Print predicted class.
       label = format(&quot;%s: %.4f&quot;, (classes.empty() ? format(&quot;Class #%d&quot;, classId).c_str() :
                                                     classes[classId].c_str()),
                                  confidence);
       putText(frame, label, Point(0, 40), FONT_HERSHEY_SIMPLEX, 0.3, Scalar(0, 255, 0));
       cout &lt;&lt; label &lt;&lt; endl;
       imshow(kWinName, frame);
       waitKey(1);
   }
return 0;
}"><pre class="notranslate">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>fstream<span class="pl-pds">&gt;</span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>sstream<span class="pl-pds">&gt;</span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>iostream<span class="pl-pds">&gt;</span></span>

#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>opencv2/dnn.hpp<span class="pl-pds">&gt;</span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>opencv2/imgproc.hpp<span class="pl-pds">&gt;</span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>opencv2/highgui.hpp<span class="pl-pds">&gt;</span></span>

<span class="pl-k">const</span> <span class="pl-k">char</span>* keys =
   <span class="pl-s"><span class="pl-pds">"</span>{ help  h     | | Print help message. }<span class="pl-pds">"</span></span>
   <span class="pl-s"><span class="pl-pds">"</span>{ input i     | | Path to input image or video file. Skip this argument to capture frames from a camera.}<span class="pl-pds">"</span></span>
   <span class="pl-s"><span class="pl-pds">"</span>{ model m     | | Path to a binary file of model contains trained weights. <span class="pl-pds">"</span></span>
                     <span class="pl-s"><span class="pl-pds">"</span>It could be a file with extensions .caffemodel (Caffe), <span class="pl-pds">"</span></span>
                     <span class="pl-s"><span class="pl-pds">"</span>.pb (TensorFlow), .t7 or .net (Torch), .weights (Darknet) }<span class="pl-pds">"</span></span>
   <span class="pl-s"><span class="pl-pds">"</span>{ config c    | | Path to a text file of model contains network configuration. <span class="pl-pds">"</span></span>
                     <span class="pl-s"><span class="pl-pds">"</span>It could be a file with extensions .prototxt (Caffe), .pbtxt (TensorFlow), .cfg (Darknet) }<span class="pl-pds">"</span></span>
   <span class="pl-s"><span class="pl-pds">"</span>{ framework f | | Optional name of an origin framework of the model. Detect it automatically if it does not set. }<span class="pl-pds">"</span></span>
   <span class="pl-s"><span class="pl-pds">"</span>{ classes     | | Optional path to a text file with names of classes. }<span class="pl-pds">"</span></span>
   <span class="pl-s"><span class="pl-pds">"</span>{ mean        | | Preprocess input image by subtracting mean values. Mean values should be in BGR order and delimited by spaces. }<span class="pl-pds">"</span></span>
   <span class="pl-s"><span class="pl-pds">"</span>{ scale       | 1 | Preprocess input image by multiplying on a scale factor. }<span class="pl-pds">"</span></span>
   <span class="pl-s"><span class="pl-pds">"</span>{ width       |   | Preprocess input image by resizing to a specific width. }<span class="pl-pds">"</span></span>
   <span class="pl-s"><span class="pl-pds">"</span>{ height      |   | Preprocess input image by resizing to a specific height. }<span class="pl-pds">"</span></span>
   <span class="pl-s"><span class="pl-pds">"</span>{ rgb         |   | Indicate that model works with RGB input images instead BGR ones. }<span class="pl-pds">"</span></span>
   <span class="pl-s"><span class="pl-pds">"</span>{ backend     | 0 | Choose one of computation backends: <span class="pl-pds">"</span></span>
                       <span class="pl-s"><span class="pl-pds">"</span>0: automatically (by default), <span class="pl-pds">"</span></span>
                       <span class="pl-s"><span class="pl-pds">"</span>1: Halide language (http://halide-lang.org/), <span class="pl-pds">"</span></span>
                       <span class="pl-s"><span class="pl-pds">"</span>2: Intel's Deep Learning Inference Engine (https://software.intel.com/openvino-toolkit), <span class="pl-pds">"</span></span>
                       <span class="pl-s"><span class="pl-pds">"</span>3: OpenCV implementation }<span class="pl-pds">"</span></span>
   <span class="pl-s"><span class="pl-pds">"</span>{ target      | 0 | Choose one of target computation devices: <span class="pl-pds">"</span></span>
                       <span class="pl-s"><span class="pl-pds">"</span>0: CPU target (by default), <span class="pl-pds">"</span></span>
                       <span class="pl-s"><span class="pl-pds">"</span>1: OpenCL, <span class="pl-pds">"</span></span>
                       <span class="pl-s"><span class="pl-pds">"</span>2: OpenCL fp16 (half-float precision), <span class="pl-pds">"</span></span>
                       <span class="pl-s"><span class="pl-pds">"</span>3: VPU }<span class="pl-pds">"</span></span>;

<span class="pl-k">using</span> <span class="pl-k">namespace</span> <span class="pl-en">cv</span><span class="pl-k">;</span>
<span class="pl-k">using</span> <span class="pl-k">namespace</span> <span class="pl-en">dnn</span><span class="pl-k">;</span>
<span class="pl-k">using</span> <span class="pl-k">namespace</span> <span class="pl-en">std</span><span class="pl-k">;</span>

std::vector&lt;std::string&gt; classes;

<span class="pl-k">int</span> <span class="pl-en">main</span>(<span class="pl-k">int</span> argc, <span class="pl-k">char</span>** argv)
{
   CommandLineParser <span class="pl-smi">parser</span>(argc, argv, keys);
   parser.<span class="pl-c1">about</span>(<span class="pl-s"><span class="pl-pds">"</span>Use this script to run classification deep learning networks using OpenCV.<span class="pl-pds">"</span></span>);
   <span class="pl-k">if</span> (argc == <span class="pl-c1">1</span> || parser.<span class="pl-c1">has</span>(<span class="pl-s"><span class="pl-pds">"</span>help<span class="pl-pds">"</span></span>))
   {
       parser.<span class="pl-c1">printMessage</span>();
       <span class="pl-k">return</span> <span class="pl-c1">0</span>;
   }

   <span class="pl-k">float</span> scale = parser.<span class="pl-smi">get</span>&lt;<span class="pl-k">float</span>&gt;(<span class="pl-s"><span class="pl-pds">"</span>scale<span class="pl-pds">"</span></span>);
   Scalar mean = parser.<span class="pl-smi">get</span>&lt;Scalar&gt;(<span class="pl-s"><span class="pl-pds">"</span>mean<span class="pl-pds">"</span></span>);
   <span class="pl-k">bool</span> swapRB = parser.<span class="pl-smi">get</span>&lt;<span class="pl-k">bool</span>&gt;(<span class="pl-s"><span class="pl-pds">"</span>rgb<span class="pl-pds">"</span></span>);
   <span class="pl-k">int</span> inpWidth = parser.<span class="pl-smi">get</span>&lt;<span class="pl-k">int</span>&gt;(<span class="pl-s"><span class="pl-pds">"</span>width<span class="pl-pds">"</span></span>);
   <span class="pl-k">int</span> inpHeight = parser.<span class="pl-smi">get</span>&lt;<span class="pl-k">int</span>&gt;(<span class="pl-s"><span class="pl-pds">"</span>height<span class="pl-pds">"</span></span>);
   String model = parser.<span class="pl-smi">get</span>&lt;String&gt;(<span class="pl-s"><span class="pl-pds">"</span>model<span class="pl-pds">"</span></span>);
   String config = parser.<span class="pl-smi">get</span>&lt;String&gt;(<span class="pl-s"><span class="pl-pds">"</span>config<span class="pl-pds">"</span></span>);
   String framework = parser.<span class="pl-smi">get</span>&lt;String&gt;(<span class="pl-s"><span class="pl-pds">"</span>framework<span class="pl-pds">"</span></span>);
   <span class="pl-k">int</span> backendId = parser.<span class="pl-smi">get</span>&lt;<span class="pl-k">int</span>&gt;(<span class="pl-s"><span class="pl-pds">"</span>backend<span class="pl-pds">"</span></span>);
   <span class="pl-k">int</span> targetId = parser.<span class="pl-smi">get</span>&lt;<span class="pl-k">int</span>&gt;(<span class="pl-s"><span class="pl-pds">"</span>target<span class="pl-pds">"</span></span>);

   <span class="pl-c"><span class="pl-c">//</span> Open file with classes names.</span>
   <span class="pl-k">if</span> (parser.<span class="pl-c1">has</span>(<span class="pl-s"><span class="pl-pds">"</span>classes<span class="pl-pds">"</span></span>))
   {
       std::string file = parser.<span class="pl-smi">get</span>&lt;String&gt;(<span class="pl-s"><span class="pl-pds">"</span>classes<span class="pl-pds">"</span></span>);
       std::ifstream <span class="pl-smi">ifs</span>(file.<span class="pl-c1">c_str</span>());
       <span class="pl-k">if</span> (!ifs.<span class="pl-c1">is_open</span>())
           <span class="pl-c1">CV_Error</span>(Error::StsError, <span class="pl-s"><span class="pl-pds">"</span>File <span class="pl-pds">"</span></span> + file + <span class="pl-s"><span class="pl-pds">"</span> not found<span class="pl-pds">"</span></span>);
       std::string line;
       <span class="pl-k">while</span> (<span class="pl-c1">std::getline</span>(ifs, line))
       {
           classes.<span class="pl-c1">push_back</span>(line);
       }
   }

   <span class="pl-k">if</span> (!parser.<span class="pl-c1">check</span>())
   {
       parser.<span class="pl-c1">printErrors</span>();
       <span class="pl-k">return</span> <span class="pl-c1">1</span>;
   }
   <span class="pl-c1">CV_Assert</span>(!model.<span class="pl-c1">empty</span>());

   <span class="pl-c"><span class="pl-c">//</span>! [Read and initialize network]</span>
   Net net = <span class="pl-c1">readNet</span>(model, config, framework);
   net.<span class="pl-c1">setPreferableBackend</span>(backendId);
   net.<span class="pl-c1">setPreferableTarget</span>(targetId);
   <span class="pl-c"><span class="pl-c">//</span>! [Read and initialize network]</span>

   <span class="pl-c"><span class="pl-c">//</span> Create a window</span>
   <span class="pl-k">static</span> <span class="pl-k">const</span> std::string <span class="pl-c1">kWinName</span> = <span class="pl-s"><span class="pl-pds">"</span>Deep learning image classification in OpenCV<span class="pl-pds">"</span></span>;
   <span class="pl-c1">namedWindow</span>(<span class="pl-c1">kWinName</span>, WINDOW_NORMAL);

   <span class="pl-c"><span class="pl-c">//</span>! [Open a video file or an image file or a camera stream]</span>
   <span class="pl-c"><span class="pl-c">//</span>VideoCapture cap;</span>
   <span class="pl-c"><span class="pl-c">//</span>if (parser.has("input"))</span>
   <span class="pl-c"><span class="pl-c">//</span>    cap.open(parser.get&lt;String&gt;("input"));</span>
   <span class="pl-c"><span class="pl-c">//</span>else</span>
   <span class="pl-c"><span class="pl-c">//</span>    cap.open(0);</span>
   <span class="pl-c"><span class="pl-c">//</span>! [Open a video file or an image file or a camera stream]</span>

   <span class="pl-c"><span class="pl-c">//</span> Process frames.</span>
   Mat frame, blob;
   <span class="pl-k">while</span> (<span class="pl-c1">waitKey</span>(<span class="pl-c1">1</span>) != <span class="pl-c1">27</span>)
   {
       <span class="pl-c"><span class="pl-c">//</span>cap &gt;&gt; frame;</span>
       <span class="pl-c"><span class="pl-c">//</span>if (frame.empty())</span>
       <span class="pl-c"><span class="pl-c">//</span>{</span>
       <span class="pl-c"><span class="pl-c">//</span>    waitKey();</span>
       <span class="pl-c"><span class="pl-c">//</span>    break;</span>
       <span class="pl-c"><span class="pl-c">//</span>}</span>

       string filePath;
       cout &lt;&lt; <span class="pl-s"><span class="pl-pds">"</span>enter file path: <span class="pl-pds">"</span></span> &lt;&lt; std::endl;
       cin &gt;&gt; filePath ;
       frame = <span class="pl-c1">imread</span>(filePath, IMREAD_COLOR);
       
       <span class="pl-c"><span class="pl-c">//</span>! [Create a 4D blob from a frame]</span>
       <span class="pl-c1">blobFromImage</span>(frame, blob, scale, <span class="pl-c1">Size</span>(inpWidth, inpHeight), mean, swapRB, <span class="pl-c1">false</span>);
       <span class="pl-c"><span class="pl-c">//</span>! [Create a 4D blob from a frame]</span>

       <span class="pl-c"><span class="pl-c">//</span>! [Set input blob]</span>
       net.<span class="pl-c1">setInput</span>(blob);
       <span class="pl-c"><span class="pl-c">//</span>! [Set input blob]</span>
       <span class="pl-c"><span class="pl-c">//</span>! [Make forward pass]</span>
       Mat prob = net.<span class="pl-c1">forward</span>();
       <span class="pl-c"><span class="pl-c">//</span>! [Make forward pass]</span>

       <span class="pl-c"><span class="pl-c">//</span>! [Get a class with a highest score]</span>
       <span class="pl-c1">Point</span> classIdPoint;
       <span class="pl-k">double</span> confidence;
       <span class="pl-c1">minMaxLoc</span>(prob.<span class="pl-c1">reshape</span>(<span class="pl-c1">1</span>, <span class="pl-c1">1</span>), <span class="pl-c1">0</span>, &amp;confidence, <span class="pl-c1">0</span>, &amp;classIdPoint);
       <span class="pl-k">int</span> classId = classIdPoint.<span class="pl-smi">x</span>;
       <span class="pl-c"><span class="pl-c">//</span>! [Get a class with a highest score]</span>

       <span class="pl-c"><span class="pl-c">//</span> Put efficiency information.</span>
       std::vector&lt;<span class="pl-k">double</span>&gt; layersTimes;
       <span class="pl-k">double</span> freq = <span class="pl-c1">getTickFrequency</span>() / <span class="pl-c1">1000</span>;
       <span class="pl-k">double</span> t = net.<span class="pl-c1">getPerfProfile</span>(layersTimes) / freq;
       std::string label = <span class="pl-c1">format</span>(<span class="pl-s"><span class="pl-pds">"</span>Time: %.2f ms<span class="pl-pds">"</span></span>, t);
       <span class="pl-c1">putText</span>(frame, label, <span class="pl-c1">Point</span>(<span class="pl-c1">0</span>, <span class="pl-c1">15</span>), FONT_HERSHEY_SIMPLEX, <span class="pl-c1">0.3</span>, <span class="pl-c1">Scalar</span>(<span class="pl-c1">0</span>, <span class="pl-c1">255</span>, <span class="pl-c1">0</span>));
       cout &lt;&lt; label &lt;&lt; endl;
       <span class="pl-c"><span class="pl-c">//</span> Print predicted class.</span>
       label = <span class="pl-c1">format</span>(<span class="pl-s"><span class="pl-pds">"</span>%s: %.4f<span class="pl-pds">"</span></span>, (classes.<span class="pl-c1">empty</span>() ? <span class="pl-c1">format</span>(<span class="pl-s"><span class="pl-pds">"</span>Class #%d<span class="pl-pds">"</span></span>, classId).<span class="pl-c1">c_str</span>() :
                                                     classes[classId].<span class="pl-c1">c_str</span>()),
                                  confidence);
       <span class="pl-c1">putText</span>(frame, label, <span class="pl-c1">Point</span>(<span class="pl-c1">0</span>, <span class="pl-c1">40</span>), FONT_HERSHEY_SIMPLEX, <span class="pl-c1">0.3</span>, <span class="pl-c1">Scalar</span>(<span class="pl-c1">0</span>, <span class="pl-c1">255</span>, <span class="pl-c1">0</span>));
       cout &lt;&lt; label &lt;&lt; endl;
       <span class="pl-c1">imshow</span>(<span class="pl-c1">kWinName</span>, frame);
       <span class="pl-c1">waitKey</span>(<span class="pl-c1">1</span>);
   }
<span class="pl-k">return</span> <span class="pl-c1">0</span>;
}</pre></div>
<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; 4.0.1</li>
<li>Operating System / Platform =&gt; Ubuntu 16.04</li>
<li>Compiler =&gt; gcc</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">Hi,</p>
<p dir="auto">I am using OpenCV DNN module for NN inference. Inference on single image, i.e. batch size of 1 works fine but when I try to use more than one images in inference batch, it fails giving error</p>
<p dir="auto">what(): OpenCV(4.0.1-openvino) /home/jenkins/workspace/OpenCV/OpenVINO/build/opencv/modules/dnn/src/op_inf_engine.cpp:553: error: (-215:Assertion failed) Failed to initialize Inference Engine backend: Input blob size is not equal network input size (1350000!=270000). in function 'initPlugin'</p>
<p dir="auto">I am using blobFromImages instead of blobFromImage. Blob has 'batch_size' images in it but just inference doesn't work.</p>
<p dir="auto">I know OpenVINO API has SetBatch() method.</p>
<p dir="auto">Should I instead switch to OpenVINO API for inference?</p>
<p dir="auto">Thanks for your time.</p>