<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 3.4.1</li>
<li>Operating System / Platform =&gt; Windows 64 Bit</li>
<li>Compiler =&gt; Visual Studio 2017</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">So I'm training an <strong>Inception resnet model</strong> on tensorflow, and I get a .ckpt/.meta files. From this I generate a .pb frozen graph. I call this .pb file in C++ for inference.</p>
<p dir="auto">But the opencv module comes up with the error as<br>
<code class="notranslate">OpenCV(3.4.1) Error: Unspecified error (Unknown layer type OneShotIterator in op OneShotIterator) in cv::dnn::experimental_dnn_v4 </code></p>
<p dir="auto">Why does Opencv not recognize my pipeline layer? The same thing happened when the code initially had a FIFOQueue as pipeline for data. Is there someway I can remove these layers?</p>
<p dir="auto">I looked at the layers in Opencv 4.1.0 and it doesn't have a one shot iterator, so please help me out!</p>

<h5 dir="auto">Steps to reproduce</h5>
<p dir="auto">One thing I'm not so sure is if I can use the sample C++ file for <strong>inception model</strong> to call my graph which is not inception but <strong>inception resnet</strong>? Does it make any difference? attached code below</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.

// Copyright (C) 2016, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.

/*
Sample of using OpenCV dnn module with Tensorflow Inception model.
*/

#include &lt;stdafx.h&gt;
using namespace cv;
using namespace cv::dnn;

#include &lt;fstream&gt;
#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
using namespace std;

const String keys =
&quot;{help h    || Sample app for loading Inception TensorFlow model. &quot;
&quot;The model and class names list can be downloaded here: &quot;
&quot;https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip }&quot;
&quot;{model m   |tensorflow_inception_graph.pb| path to TensorFlow .pb model file }&quot;
&quot;{image i   || path to image file }&quot;
&quot;{i_blob    | input | input blob name) }&quot;
&quot;{o_blob    | softmax2 | output blob name) }&quot;
&quot;{c_names c | imagenet_comp_graph_label_strings.txt | path to file with classnames for class id }&quot;
&quot;{result r  || path to save output blob (optional, binary format, NCHW order) }&quot;
;

void getMaxClass(const Mat &amp;probBlob, int *classId, double *classProb);
std::vector&lt;String&gt; readClassNames(const char *filename);

int main(int argc, char **argv)
{
	cv::CommandLineParser parser(argc, argv, keys);

	if (parser.has(&quot;help&quot;))
	{
		parser.printMessage();
		return 0;
	}

	String modelFile = &quot;frozen_mode_final.pb&quot;;
	String imageFile = &quot;Lena.jpg&quot;;
	String inBlobName = &quot;input&quot;;
	String outBlobName = &quot;outputs_&quot;;

	if (!parser.check())
	{
		parser.printErrors();
		return 0;
	}

	String classNamesFile = &quot;imagenet_comp_graph_label_strings.txt&quot;;
	String resultFile = &quot;output.txt&quot;;

	//! [Initialize network]
	dnn::Net net = readNetFromTensorflow(modelFile);
	//! [Initialize network]

	if (net.empty())
	{
		std::cerr &lt;&lt; &quot;Can't load network by using the mode file: &quot; &lt;&lt; std::endl;
		std::cerr &lt;&lt; modelFile &lt;&lt; std::endl;
		exit(-1);
	}

	//! [Prepare blob]
	Mat img = imread(imageFile);
	if (img.empty())
	{
		std::cerr &lt;&lt; &quot;Can't read image from the file: &quot; &lt;&lt; imageFile &lt;&lt; std::endl;
		exit(-1);
	}

	Mat inputBlob = blobFromImage(img, 1.0f, Size(299, 299), Scalar(), true, false);   //Convert Mat to batch of images
	//! [Prepare blob]
	inputBlob -= 117.0;
	//! [Set input blob]
	net.setInput(inputBlob, inBlobName);        //set the network input
	//! [Set input blob]

	cv::TickMeter tm;
	tm.start();

	//! [Make forward pass]
	Mat result = net.forward(outBlobName);                          //compute output
	//! [Make forward pass]

	tm.stop();

	if (!resultFile.empty()) {
		CV_Assert(result.isContinuous());

		ofstream fout(resultFile.c_str(), ios::out | ios::binary);
		fout.write((char*)result.data, result.total() * sizeof(float));
		fout.close();
	}

	std::cout &lt;&lt; &quot;Output blob shape &quot; &lt;&lt; result.size[0] &lt;&lt; &quot; x &quot; &lt;&lt; result.size[1] &lt;&lt; &quot; x &quot; &lt;&lt; result.size[2] &lt;&lt; &quot; x &quot; &lt;&lt; result.size[3] &lt;&lt; std::endl;
	std::cout &lt;&lt; &quot;Inference time, ms: &quot; &lt;&lt; tm.getTimeMilli() &lt;&lt; std::endl;

	if (!classNamesFile.empty()) {
		std::vector&lt;String&gt; classNames = readClassNames(classNamesFile.c_str());

		int classId;
		double classProb;
		getMaxClass(result, &amp;classId, &amp;classProb);//find the best class

		//! [Print results]
		std::cout &lt;&lt; &quot;Best class: #&quot; &lt;&lt; classId &lt;&lt; &quot; '&quot; &lt;&lt; classNames.at(classId) &lt;&lt; &quot;'&quot; &lt;&lt; std::endl;
		std::cout &lt;&lt; &quot;Probability: &quot; &lt;&lt; classProb * 100 &lt;&lt; &quot;%&quot; &lt;&lt; std::endl;
	}
	return 0;
} //main


/* Find best class for the blob (i. e. class with maximal probability) */
void getMaxClass(const Mat &amp;probBlob, int *classId, double *classProb)
{
	Mat probMat = probBlob.reshape(1, 1); //reshape the blob to 1x1000 matrix
	Point classNumber;

	minMaxLoc(probMat, NULL, classProb, NULL, &amp;classNumber);
	*classId = classNumber.x;
}

std::vector&lt;String&gt; readClassNames(const char *filename)
{
	std::vector&lt;String&gt; classNames;

	std::ifstream fp(filename);
	if (!fp.is_open())
	{
		std::cerr &lt;&lt; &quot;File with classes labels not found: &quot; &lt;&lt; filename &lt;&lt; std::endl;
		exit(-1);
	}

	std::string name;
	while (!fp.eof())
	{
		std::getline(fp, name);
		if (name.length())
			classNames.push_back(name);
	}

	fp.close();
	return classNames;
}```"><pre lang="//" class="notranslate"><code class="notranslate">// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.

// Copyright (C) 2016, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.

/*
Sample of using OpenCV dnn module with Tensorflow Inception model.
*/

#include &lt;stdafx.h&gt;
using namespace cv;
using namespace cv::dnn;

#include &lt;fstream&gt;
#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
using namespace std;

const String keys =
"{help h    || Sample app for loading Inception TensorFlow model. "
"The model and class names list can be downloaded here: "
"https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip }"
"{model m   |tensorflow_inception_graph.pb| path to TensorFlow .pb model file }"
"{image i   || path to image file }"
"{i_blob    | input | input blob name) }"
"{o_blob    | softmax2 | output blob name) }"
"{c_names c | imagenet_comp_graph_label_strings.txt | path to file with classnames for class id }"
"{result r  || path to save output blob (optional, binary format, NCHW order) }"
;

void getMaxClass(const Mat &amp;probBlob, int *classId, double *classProb);
std::vector&lt;String&gt; readClassNames(const char *filename);

int main(int argc, char **argv)
{
	cv::CommandLineParser parser(argc, argv, keys);

	if (parser.has("help"))
	{
		parser.printMessage();
		return 0;
	}

	String modelFile = "frozen_mode_final.pb";
	String imageFile = "Lena.jpg";
	String inBlobName = "input";
	String outBlobName = "outputs_";

	if (!parser.check())
	{
		parser.printErrors();
		return 0;
	}

	String classNamesFile = "imagenet_comp_graph_label_strings.txt";
	String resultFile = "output.txt";

	//! [Initialize network]
	dnn::Net net = readNetFromTensorflow(modelFile);
	//! [Initialize network]

	if (net.empty())
	{
		std::cerr &lt;&lt; "Can't load network by using the mode file: " &lt;&lt; std::endl;
		std::cerr &lt;&lt; modelFile &lt;&lt; std::endl;
		exit(-1);
	}

	//! [Prepare blob]
	Mat img = imread(imageFile);
	if (img.empty())
	{
		std::cerr &lt;&lt; "Can't read image from the file: " &lt;&lt; imageFile &lt;&lt; std::endl;
		exit(-1);
	}

	Mat inputBlob = blobFromImage(img, 1.0f, Size(299, 299), Scalar(), true, false);   //Convert Mat to batch of images
	//! [Prepare blob]
	inputBlob -= 117.0;
	//! [Set input blob]
	net.setInput(inputBlob, inBlobName);        //set the network input
	//! [Set input blob]

	cv::TickMeter tm;
	tm.start();

	//! [Make forward pass]
	Mat result = net.forward(outBlobName);                          //compute output
	//! [Make forward pass]

	tm.stop();

	if (!resultFile.empty()) {
		CV_Assert(result.isContinuous());

		ofstream fout(resultFile.c_str(), ios::out | ios::binary);
		fout.write((char*)result.data, result.total() * sizeof(float));
		fout.close();
	}

	std::cout &lt;&lt; "Output blob shape " &lt;&lt; result.size[0] &lt;&lt; " x " &lt;&lt; result.size[1] &lt;&lt; " x " &lt;&lt; result.size[2] &lt;&lt; " x " &lt;&lt; result.size[3] &lt;&lt; std::endl;
	std::cout &lt;&lt; "Inference time, ms: " &lt;&lt; tm.getTimeMilli() &lt;&lt; std::endl;

	if (!classNamesFile.empty()) {
		std::vector&lt;String&gt; classNames = readClassNames(classNamesFile.c_str());

		int classId;
		double classProb;
		getMaxClass(result, &amp;classId, &amp;classProb);//find the best class

		//! [Print results]
		std::cout &lt;&lt; "Best class: #" &lt;&lt; classId &lt;&lt; " '" &lt;&lt; classNames.at(classId) &lt;&lt; "'" &lt;&lt; std::endl;
		std::cout &lt;&lt; "Probability: " &lt;&lt; classProb * 100 &lt;&lt; "%" &lt;&lt; std::endl;
	}
	return 0;
} //main


/* Find best class for the blob (i. e. class with maximal probability) */
void getMaxClass(const Mat &amp;probBlob, int *classId, double *classProb)
{
	Mat probMat = probBlob.reshape(1, 1); //reshape the blob to 1x1000 matrix
	Point classNumber;

	minMaxLoc(probMat, NULL, classProb, NULL, &amp;classNumber);
	*classId = classNumber.x;
}

std::vector&lt;String&gt; readClassNames(const char *filename)
{
	std::vector&lt;String&gt; classNames;

	std::ifstream fp(filename);
	if (!fp.is_open())
	{
		std::cerr &lt;&lt; "File with classes labels not found: " &lt;&lt; filename &lt;&lt; std::endl;
		exit(-1);
	}

	std::string name;
	while (!fp.eof())
	{
		std::getline(fp, name);
		if (name.length())
			classNames.push_back(name);
	}

	fp.close();
	return classNames;
}```
</code></pre></div>
<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; :4.1.0:</li>
<li>Operating System / Platform =&gt; :ubuntu 18.04 LTS:</li>
<li>Compiler =&gt; : clang-7:</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    An issue was discovered in opencv 4.1.0, there is an out of bounds read/write in Function HaarEvaluator::OptFeature::calc in cascadedetect.hpp, which leads to denial of service."><pre class="notranslate"><code class="notranslate">    An issue was discovered in opencv 4.1.0, there is an out of bounds read/write in Function HaarEvaluator::OptFeature::calc in cascadedetect.hpp, which leads to denial of service.
</code></pre></div>
<p dir="auto">src</p>
<div class="highlight highlight-source-c notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#define CALC_SUM_OFS_(p0, p1, p2, p3, ptr) \
((ptr)[p0] - (ptr)[p1] - (ptr)[p2] + (ptr)[p3])

#define CALC_SUM_OFS(rect, ptr) CALC_SUM_OFS_((rect)[0], (rect)[1], (rect)[2], (rect)[3], ptr)"><pre class="notranslate"><span class="pl-k">#define</span> <span class="pl-en">CALC_SUM_OFS_</span>(<span class="pl-s1">p0</span>, <span class="pl-s1">p1</span>, <span class="pl-s1">p2</span>, <span class="pl-s1">p3</span>, <span class="pl-s1">ptr</span>) \
((ptr)[p0] - (ptr)[p1] - (ptr)[p2] + (ptr)[p3])

<span class="pl-k">#define</span> <span class="pl-en">CALC_SUM_OFS</span>(<span class="pl-s1">rect</span>, <span class="pl-s1">ptr</span>) CALC_SUM_OFS_((rect)[0], (rect)[1], (rect)[2], (rect)[3], ptr)</pre></div>
<p dir="auto">debug</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In file: /home/pwd/SofterWare/opencv-4.1.0/modules/objdetect/src/cascadedetect.hpp
   390     ofs[2][0] = ofs[2][1] = ofs[2][2] = ofs[2][3] = 0;
   391 }
   392
   393 inline float HaarEvaluator::OptFeature :: calc( const int* ptr ) const
   394 {
 ► 395     float ret = weight[0] * CALC_SUM_OFS(ofs[0], ptr) +
   396                 weight[1] * CALC_SUM_OFS(ofs[1], ptr);
   397
   398     if( weight[2] != 0.0f )
   399         ret += weight[2] * CALC_SUM_OFS(ofs[2], ptr);
   400
─────────────────────────────────────────────────────────────────────────────────────────────────────[ STACK ]─────────────────────────────────────────────────────────────────────────────────────────────────────
00:0000│ rbp rsp  0x7fffc7ffe2b0 —▸ 0x7fffc7ffe2e0 —▸ 0x7fffc7ffe3c0 —▸ 0x7fffc7ffe470 —▸ 0x7fffc7ffe5b0 ◂— ...
01:0008│          0x7fffc7ffe2b8 —▸ 0x7ffff5e3c218 ◂— mov    rax, qword ptr [rbp - 0x18]
02:0010│          0x7fffc7ffe2c0 —▸ 0x7fffc7ffe2e0 —▸ 0x7fffc7ffe3c0 —▸ 0x7fffc7ffe470 —▸ 0x7fffc7ffe5b0 ◂— ...
03:0018│          0x7fffc7ffe2c8 —▸ 0x7fffcc000ce0 —▸ 0x7ffff60d0e08 —▸ 0x7ffff5e25d30 (cv::HaarEvaluator::~HaarEvaluator()) ◂— push   rbp
04:0020│          0x7fffc7ffe2d0 ◂— 0x7d00000000
05:0028│          0x7fffc7ffe2d8 —▸ 0x7fffcc000ce0 —▸ 0x7ffff60d0e08 —▸ 0x7ffff5e25d30 (cv::HaarEvaluator::~HaarEvaluator()) ◂— push   rbp
06:0030│          0x7fffc7ffe2e0 —▸ 0x7fffc7ffe3c0 —▸ 0x7fffc7ffe470 —▸ 0x7fffc7ffe5b0 —▸ 0x7fffc7ffe650 ◂— ...
07:0038│          0x7fffc7ffe2e8 —▸ 0x7ffff5e2bdad ◂— movss  dword ptr [rbp - 0xcc], xmm0
───────────────────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]───────────────────────────────────────────────────────────────────────────────────────────────────
 ► f 0     7ffff5e3c24c
   f 1     7ffff5e3c218
   f 2     7ffff5e2bdad
   f 3     7ffff5e2ba90
   f 4     7ffff5e3bd74
   f 5     7fffef87dc59
   f 6     7fffef87ea3b cv::ParallelJob::execute(bool)+603
   f 7     7fffef87e21a cv::WorkerThread::thread_body()+890
   f 8     7fffef880e05 cv::WorkerThread::thread_loop_wrapper(void*)+21
   f 9     7fffee3d46db start_thread+219
Program received signal SIGSEGV (fault address 0x7ffdd53a6cdc)
pwndbg&gt; p ofs 
$9 = {{-2147481185, -2147481182, -2147479073, -2147479070}, {2470, 2471, 4582, 4583}, {0, 0, 0, 0}}"><pre class="notranslate"><code class="notranslate">In file: /home/pwd/SofterWare/opencv-4.1.0/modules/objdetect/src/cascadedetect.hpp
   390     ofs[2][0] = ofs[2][1] = ofs[2][2] = ofs[2][3] = 0;
   391 }
   392
   393 inline float HaarEvaluator::OptFeature :: calc( const int* ptr ) const
   394 {
 ► 395     float ret = weight[0] * CALC_SUM_OFS(ofs[0], ptr) +
   396                 weight[1] * CALC_SUM_OFS(ofs[1], ptr);
   397
   398     if( weight[2] != 0.0f )
   399         ret += weight[2] * CALC_SUM_OFS(ofs[2], ptr);
   400
─────────────────────────────────────────────────────────────────────────────────────────────────────[ STACK ]─────────────────────────────────────────────────────────────────────────────────────────────────────
00:0000│ rbp rsp  0x7fffc7ffe2b0 —▸ 0x7fffc7ffe2e0 —▸ 0x7fffc7ffe3c0 —▸ 0x7fffc7ffe470 —▸ 0x7fffc7ffe5b0 ◂— ...
01:0008│          0x7fffc7ffe2b8 —▸ 0x7ffff5e3c218 ◂— mov    rax, qword ptr [rbp - 0x18]
02:0010│          0x7fffc7ffe2c0 —▸ 0x7fffc7ffe2e0 —▸ 0x7fffc7ffe3c0 —▸ 0x7fffc7ffe470 —▸ 0x7fffc7ffe5b0 ◂— ...
03:0018│          0x7fffc7ffe2c8 —▸ 0x7fffcc000ce0 —▸ 0x7ffff60d0e08 —▸ 0x7ffff5e25d30 (cv::HaarEvaluator::~HaarEvaluator()) ◂— push   rbp
04:0020│          0x7fffc7ffe2d0 ◂— 0x7d00000000
05:0028│          0x7fffc7ffe2d8 —▸ 0x7fffcc000ce0 —▸ 0x7ffff60d0e08 —▸ 0x7ffff5e25d30 (cv::HaarEvaluator::~HaarEvaluator()) ◂— push   rbp
06:0030│          0x7fffc7ffe2e0 —▸ 0x7fffc7ffe3c0 —▸ 0x7fffc7ffe470 —▸ 0x7fffc7ffe5b0 —▸ 0x7fffc7ffe650 ◂— ...
07:0038│          0x7fffc7ffe2e8 —▸ 0x7ffff5e2bdad ◂— movss  dword ptr [rbp - 0xcc], xmm0
───────────────────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]───────────────────────────────────────────────────────────────────────────────────────────────────
 ► f 0     7ffff5e3c24c
   f 1     7ffff5e3c218
   f 2     7ffff5e2bdad
   f 3     7ffff5e2ba90
   f 4     7ffff5e3bd74
   f 5     7fffef87dc59
   f 6     7fffef87ea3b cv::ParallelJob::execute(bool)+603
   f 7     7fffef87e21a cv::WorkerThread::thread_body()+890
   f 8     7fffef880e05 cv::WorkerThread::thread_loop_wrapper(void*)+21
   f 9     7fffee3d46db start_thread+219
Program received signal SIGSEGV (fault address 0x7ffdd53a6cdc)
pwndbg&gt; p ofs 
$9 = {{-2147481185, -2147481182, -2147479073, -2147479070}, {2470, 2471, 4582, 4583}, {0, 0, 0, 0}}
</code></pre></div>
<h5 dir="auto">Steps to reproduce</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="classifier /work/funcs/appname.bmp poc"><pre class="notranslate"><code class="notranslate">classifier /work/funcs/appname.bmp poc
</code></pre></div>
<p dir="auto"><a href="https://github.com/opencv/opencv/files/3420045/poc1.tar.gz">poc1.tar.gz</a></p>