<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 4.1.2</li>
<li>Operating System / Platform =&gt; Linux armv7l</li>
<li>Compiler =&gt; GCC 8.3.0</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">Upon trying to create a VideoCapture or VideoWriter object using the GStreamer backend, the Python interpreter freezes indefinitely.</p>
<h5 dir="auto">Steps to reproduce</h5>
<ol dir="auto">
<li>Compile OpenCV with GStreamer support. May also need to be on an ARM platform.</li>
<li>Open the python3 interpreter.</li>
<li>import cv2 and create a new VideoCapture or VideoWriter object using the GStreamer backend.</li>
<li>Press Ctrl+C.</li>
<li>Errors will appear. After this point, only a <code class="notranslate">kill -9</code> will stop the process.</li>
</ol>
<p dir="auto">Output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pi@opensight:~ $ python3
Python 3.7.3 (default, Apr  3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import cv2
&gt;&gt;&gt; x = cv2.VideoCapture(1)
^C
(python3:1013): GStreamer-CRITICAL **: 03:20:46.243:
Trying to dispose element pipeline0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.

[ WARN:0] global /home/pi/opencv/opencv-4.1.2/modules/videoio/src/cap_gstreamer.cpp (886) open OpenCV | GStreamer warning: unable to start pipeline

(python3:1013): GStreamer-CRITICAL **: 03:20:46.244:
Trying to dispose element videoconvert0, but it is in PLAYING instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.

[ WARN:0] global /home/pi/opencv/opencv-4.1.2/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created

(python3:1013): GStreamer-CRITICAL **: 03:20:46.244:
Trying to dispose element appsink0, but it is in READY instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element."><pre class="notranslate"><code class="notranslate">pi@opensight:~ $ python3
Python 3.7.3 (default, Apr  3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import cv2
&gt;&gt;&gt; x = cv2.VideoCapture(1)
^C
(python3:1013): GStreamer-CRITICAL **: 03:20:46.243:
Trying to dispose element pipeline0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.

[ WARN:0] global /home/pi/opencv/opencv-4.1.2/modules/videoio/src/cap_gstreamer.cpp (886) open OpenCV | GStreamer warning: unable to start pipeline

(python3:1013): GStreamer-CRITICAL **: 03:20:46.244:
Trying to dispose element videoconvert0, but it is in PLAYING instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.

[ WARN:0] global /home/pi/opencv/opencv-4.1.2/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created

(python3:1013): GStreamer-CRITICAL **: 03:20:46.244:
Trying to dispose element appsink0, but it is in READY instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
</code></pre></div>
<p dir="auto">Basically, this is a GSoC project which has not been applied this year:</p>
<p dir="auto">We want to see some kind of higher level API which can manage DL networks. There are several criterias for now:</p>
<ul dir="auto">
<li>Hide asynchronous inference management internally. User just choose the number of requests (what about heterogenous scenario? In example, use both GPU and VPU with specific number of requestst for each other).</li>
<li>Models from <a href="https://github.com/opencv/opencv/blob/master/samples/dnn/models.yml">https://github.com/opencv/opencv/blob/master/samples/dnn/models.yml</a> should be downloaded automatically in samples. Can we also introduce some kind of new automatically generated classes definitions for them? I.e.:</li>
</ul>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="CV_EXPORTS_W YOLOv3 : public Model {
  YOLOv3(const std::string&amp; model = &quot;yolov3.weights&quot;, const std::string&amp; config= &quot;yolov3.cfg&quot;, int weight = 416, int height = 416, Scalar mean = Scalar(), float scale = 0.00392);
};"><pre class="notranslate">CV_EXPORTS_W YOLOv3 : public Model {
  <span class="pl-c1">YOLOv3</span>(<span class="pl-k">const</span> std::string&amp; model = <span class="pl-s"><span class="pl-pds">"</span>yolov3.weights<span class="pl-pds">"</span></span>, <span class="pl-k">const</span> std::string&amp; config= <span class="pl-s"><span class="pl-pds">"</span>yolov3.cfg<span class="pl-pds">"</span></span>, <span class="pl-k">int</span> weight = <span class="pl-c1">416</span>, <span class="pl-k">int</span> height = <span class="pl-c1">416</span>, Scalar mean = <span class="pl-c1">Scalar</span>(), <span class="pl-k">float</span> scale = <span class="pl-c1">0.00392</span>);
};</pre></div>
<p dir="auto">User do not need to care about input's preprocessing. We can do it automatically. The base class can find the files (already implemented) or download if there are no (need to do).</p>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class Model : public Net {
  Model(const std::string&amp; model, const std::string&amp; config = &quot;&quot;, int weight = -1, int height = -1, Scalar mean = Scalar(), float scale = 1.0);

  // Overridden version which accepts frame and can make blob.
  void setInput();
};"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-en">Model</span> : <span class="pl-k">public</span> <span class="pl-en">Net</span> {
  <span class="pl-en">Model</span>(<span class="pl-k">const</span> std::string&amp; model, <span class="pl-k">const</span> std::string&amp; config = <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>, <span class="pl-k">int</span> weight = -<span class="pl-c1">1</span>, <span class="pl-k">int</span> height = -<span class="pl-c1">1</span>, Scalar mean = Scalar(), <span class="pl-k">float</span> scale = <span class="pl-c1">1.0</span>);

  <span class="pl-c"><span class="pl-c">//</span> Overridden version which accepts frame and can make blob.</span>
  <span class="pl-k">void</span> <span class="pl-en">setInput</span>();
};</pre></div>
<ul dir="auto">
<li>We can add some methods to simplify postprocessing (i.e. detect type of output layer for detection network as we do in object detection samples):</li>
</ul>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="void detect(std::vector&lt;float&gt;&amp; confidences, std::vector&lt;Rect&gt;&amp; boxes, float confThreshold, float nmsThreshold);"><pre class="notranslate"><span class="pl-k">void</span> <span class="pl-en">detect</span>(std::vector&lt;<span class="pl-k">float</span>&gt;&amp; confidences, std::vector&lt;<span class="pl-c1">Rect</span>&gt;&amp; boxes, <span class="pl-k">float</span> confThreshold, <span class="pl-k">float</span> nmsThreshold);</pre></div>
<p dir="auto">So instead doing <code class="notranslate">forward</code> with postprocessing and can just call <code class="notranslate">detect</code> and then manage the predictions (i.e. draw it on the frame).</p>
<ul dir="auto">
<li></li>
</ul>