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

<ul dir="auto">
<li>OpenCV =&gt; 3.1.0-master</li>
<li>Operating System / Platform =&gt; macOS Sierra (10.12) x86_64</li>
<li>Compiler =&gt; Apple LLVM version 8.0.0 (clang-800.0.38)</li>
<li>build using Homebrew [today, 08:30CEST]:<br>
brew install ant<br>
brew install opencv3 --HEAD --with-java --with-ffmpeg --with-tbb</li>
</ul>
<h5 dir="auto">Detailed description</h5>

<p dir="auto">If you use VideoCapture via Java wrappers and if you try to release the camera, it always crashes the Java process.  It can successfully read the frame though. Releasing the mat works fine, releasing the video capture crashes.</p>
<h5 dir="auto">Steps to reproduce</h5>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    public static void main(String[] args) {
        VideoCapture capture = new VideoCapture(0);
        Mat mat = new Mat();
        capture.read(mat);
        mat.release();
        capture.release(); //crashes here
    }"><pre class="notranslate">    <span class="pl-k">public</span> <span class="pl-k">static</span> <span class="pl-smi">void</span> <span class="pl-s1">main</span>(<span class="pl-smi">String</span>[] <span class="pl-s1">args</span>) {
        <span class="pl-smi">VideoCapture</span> <span class="pl-s1">capture</span> = <span class="pl-k">new</span> <span class="pl-smi">VideoCapture</span>(<span class="pl-c1">0</span>);
        <span class="pl-smi">Mat</span> <span class="pl-s1">mat</span> = <span class="pl-k">new</span> <span class="pl-smi">Mat</span>();
        <span class="pl-s1">capture</span>.<span class="pl-en">read</span>(<span class="pl-s1">mat</span>);
        <span class="pl-s1">mat</span>.<span class="pl-en">release</span>();
        <span class="pl-s1">capture</span>.<span class="pl-en">release</span>(); <span class="pl-c">//crashes here</span>
    }</pre></div>
<p dir="auto">Afterwards it shows following:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fff954f9f6f, pid=4925, tid=0x000000000000080b
#
# JRE version: Java(TM) SE Runtime Environment (8.0_102-b14) (build 1.8.0_102-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.102-b14 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [libobjc.A.dylib+0x8f6f]  objc_release+0x1f
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try &quot;ulimit -c unlimited&quot; before starting Java again
#"><pre class="notranslate"><code class="notranslate">#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fff954f9f6f, pid=4925, tid=0x000000000000080b
#
# JRE version: Java(TM) SE Runtime Environment (8.0_102-b14) (build 1.8.0_102-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.102-b14 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [libobjc.A.dylib+0x8f6f]  objc_release+0x1f
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
</code></pre></div>
<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; 3.1</li>
<li>Operating System / Platform =&gt; Mac OSX</li>
<li>Compiler =&gt; XCode Version 8.0 (8A218a)</li>
</ul>
<h5 dir="auto">Detailed description</h5>

<p dir="auto">I tried to experiment with VideoCapture class in java. It looks like there is a bug - it is possible to open the camera but closing is not possible.</p>
<h5 dir="auto">Steps to reproduce</h5>
<p dir="auto">This code leads to java crash ():</p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    VideoCapture cap = new VideoCapture();

    cap.open(0); // camera is opening up 

    Mat img = new Mat();

    cap.read(img);

    cap.release(); // java crashes
"><pre class="notranslate"><code class="notranslate">    VideoCapture cap = new VideoCapture();

    cap.open(0); // camera is opening up 

    Mat img = new Mat();

    cap.read(img);

    cap.release(); // java crashes

</code></pre></div>