<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; 3.4.5 / 4.0.0 / 4.0.1</li>
<li>Operating System / Platform =&gt; Ubuntu 16</li>
<li>Compiler =&gt; g++</li>
<li>Python =&gt; 3.6.8</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">I compiled the open-cv with gstreamer support, and I tried to freeze my python codes with cx_freeze / pyinstaller. It prompt success whild freezing. But when I try to run the binary file, it prompted as follow:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  File &quot;/usr/local/lib/python3.6/site-packages/cx_Freeze/initscripts/__startup__.py&quot;, line 14, in run
    module.run()
  File &quot;/usr/local/lib/python3.6/site-packages/cx_Freeze/initscripts/Console.py&quot;, line 26, in run
    exec(code, m.__dict__)
  File &quot;/tmp/tmpe6jo_q_3/scripts/my_own_scripts.py&quot;, line 14, in &lt;module&gt;
  File &quot;/usr/local/lib/python3.6/site-packages/cv2/__init__.py&quot;, line 89, in &lt;module&gt;
    bootstrap()
  File &quot;/usr/local/lib/python3.6/site-packages/cv2/__init__.py&quot;, line 58, in bootstrap
    load_first_config(['config.py'], True)
  File &quot;/usr/local/lib/python3.6/site-packages/cv2/__init__.py&quot;, line 56, in load_first_config
    raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))
ImportError: OpenCV loader: missing configuration file: ['config.py']. Check OpenCV installation."><pre class="notranslate"><code class="notranslate">  File "/usr/local/lib/python3.6/site-packages/cx_Freeze/initscripts/__startup__.py", line 14, in run
    module.run()
  File "/usr/local/lib/python3.6/site-packages/cx_Freeze/initscripts/Console.py", line 26, in run
    exec(code, m.__dict__)
  File "/tmp/tmpe6jo_q_3/scripts/my_own_scripts.py", line 14, in &lt;module&gt;
  File "/usr/local/lib/python3.6/site-packages/cv2/__init__.py", line 89, in &lt;module&gt;
    bootstrap()
  File "/usr/local/lib/python3.6/site-packages/cv2/__init__.py", line 58, in bootstrap
    load_first_config(['config.py'], True)
  File "/usr/local/lib/python3.6/site-packages/cv2/__init__.py", line 56, in load_first_config
    raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))
ImportError: OpenCV loader: missing configuration file: ['config.py']. Check OpenCV installation.
</code></pre></div>
<p dir="auto">This error is not existed if I use open-cv with<br>
<code class="notranslate">pip install opencv-python</code><br>
However, I need the gstream support for open-cv, so I have to compile it myself.<br>
Please help me to check whether it is a bug or not. Thank you</p>
<p dir="auto">Lanny</p>
<h5 dir="auto">Steps to reproduce</h5>
<ol dir="auto">
<li>compile opencv as guided</li>
<li>compose a python scripts to include opencv</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import cv2

if __name__ == '__main__':
    print(&quot;Hello, world!&quot;)"><pre class="notranslate"><code class="notranslate">import cv2

if __name__ == '__main__':
    print("Hello, world!")
</code></pre></div>
<ol start="3" dir="auto">
<li>freeze it with cx_freeze of pyinstaller</li>
<li>execute the binay.</li>
</ol>
<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 4.3.0</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto"><strong>History of the region layer:</strong></p>
<ul dir="auto">
<li>YOLOv2 added in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="260115588" data-permission-text="Title is private" data-url="https://github.com/opencv/opencv/issues/9705" data-hovercard-type="pull_request" data-hovercard-url="/opencv/opencv/pull/9705/hovercard" href="https://github.com/opencv/opencv/pull/9705">#9705</a>. YOLOv2 detected objects at one scale; hence, there is just one region layer. The region layer would output unfiltered detections. The obvious step after region layer was to perform NMS. Hence, NMS was presumably integrated into the region layer.</li>
<li>YOLOv3 support was added in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="314683296" data-permission-text="Title is private" data-url="https://github.com/opencv/opencv/issues/11322" data-hovercard-type="pull_request" data-hovercard-url="/opencv/opencv/pull/11322/hovercard" href="https://github.com/opencv/opencv/pull/11322">#11322</a>. The improved YOLOv3 was detecting objects at three different scales. Each scale had a separate yolo layer in darknet and NMS was performed on all the detections at the end. The <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="314683296" data-permission-text="Title is private" data-url="https://github.com/opencv/opencv/issues/11322" data-hovercard-type="pull_request" data-hovercard-url="/opencv/opencv/pull/11322/hovercard" href="https://github.com/opencv/opencv/pull/11322">#11322</a> creates a region layer for each yolo layer and <em>hence performs NMS in each region layer</em>.</li>
</ul>
<p dir="auto"><strong>Is the nms spurious?</strong></p>
<p dir="auto">The NMS was added in the YOLOv2 PR where there was just one region layer. The next step after the region computation would be NMS (which is probably why NMS was integrated into region). YOLOv3 has three region layers. Is it right to use the region layer as it is without disabling NMS?</p>
<p dir="auto"><strong>Performance penalty for the CUDA backend:</strong><br>
The NMS is performed on CPU in the CUDA backend. This has a huge performance toll. The switch from GPU to CPU during inference introduces additional synchronization overhead, interference from OS scheduling decisions and prevents the latency hiding ability of CUDA streams.</p>
<p dir="auto">The toll is so significant that FPS of YOLOv4 improves by almost 40% on RTX 2070 Super when NMS is disabled.</p>
<h5 dir="auto">Issue submission checklist</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I report the issue, it's not a question

</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I checked the problem with documentation, FAQ, open issues,<br>
answers.opencv.org, Stack Overflow, etc and have not found solution

</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I updated to latest OpenCV version and the issue is still there

</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> There is reproducer code and related data files: videos, images, onnx, etc

</li>
</ul>