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

<ul dir="auto">
<li>OpenCV =&gt; 3.1</li>
<li>Operating System / Platform =&gt; Windows 10 64bit and Ubuntu Linux 64bit</li>
<li>Compiler =&gt; gcc 5.3.0</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">The gstreamer implementation in videoio module uses CV_ERROR() on open() instead of just returning false like all other implementations. This causes an exception to be thrown, but in projects where exceptions are disabled we cannot have that - exceptions are just handled as crashes. But in this case an error can be thrown only if a file doesn't exist or if a pipeline is wrong. In our software we have a modular api that allows several pipelines in a priority order - if a pipeline cannot be used it goes to the next one. It doesn't work because the first pipeline crashes instead of returning false like the ffmpeg, dshow or any other implementation. This is clearly an inconsistency in OpenCV api.</p>
<h5 dir="auto">Steps to reproduce</h5>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    int main() {
      cv::VideoCapture cap(&quot;shmsrc /tmp/socket ! video/x-raw, 1920, 1080, 1/60, format=UYVY ! videoconvert ! video/x-raw, BGR ! appsink sync=true&quot;); 
    }"><pre class="notranslate">    <span class="pl-k">int</span> <span class="pl-en">main</span>() {
      cv::VideoCapture <span class="pl-smi">cap</span>(<span class="pl-s"><span class="pl-pds">"</span>shmsrc /tmp/socket ! video/x-raw, 1920, 1080, 1/60, format=UYVY ! videoconvert ! video/x-raw, BGR ! appsink sync=true<span class="pl-pds">"</span></span>); 
    }</pre></div>
<p dir="auto">That will crash if the socket doesn't exist. It would be good if it returned false if used with Open() and just set internally as not-running, so we could check with isOpened.</p>
<h3 dir="auto">Please state the information for your system</h3>
<ul dir="auto">
<li>OpenCV version: 3.1.0</li>
<li>Host OS: Linux (Ubuntu 14.04)</li>
</ul>
<h3 dir="auto">In which part of the OpenCV library you got the issue?</h3>
<p dir="auto">-videoio</p>
<h3 dir="auto">Expected behaviour</h3>
<p dir="auto">I expect ot be able to open an "OpenNI" device with gstreamer conpiled in, but no gstreamer capable devices available</p>
<h3 dir="auto">Actual behaviour</h3>
<p dir="auto">The gstreamer capture device throws a CV_ERROR when it fails to open a gstreamer device. Preventing the auto selection feature from continuing to the OpenNI open code.</p>
<h3 dir="auto">Additional description</h3>
<p dir="auto">at line 818 of cap_gstreamer.cpp (tag 3.1.0)<br>
you will find the following<br>
CV_ERROR(CV_StsError, "GStreamer: unable to start pipeline\n");<br>
This line aborts the autosearch feature of VideoCapture with a device # of 0 (first video device found)</p>
<h3 dir="auto">Code example to reproduce the issue / Steps to reproduce the issue</h3>
<p dir="auto">Please try to give a full example which will compile as is.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#include &quot;opencv2/core.hpp&quot;
#include &lt;iostream&gt;
using namespace std;
using namespace cv;

int main()
{
    VideoCapture cap(0);

    return 0;
}"><pre class="notranslate"><code class="notranslate">#include "opencv2/core.hpp"
#include &lt;iostream&gt;
using namespace std;
using namespace cv;

int main()
{
    VideoCapture cap(0);

    return 0;
}
</code></pre></div>