Webcam is still held even after Python program ends
<p>I'm trying to use my webcam <a href="http://www.trust.com/en/product/16428-spotlight-webcam-pro" rel="nofollow">Trust Spotlight Webcam PRO</a> with Python and OpenCV and I have a problem with holding the webcam after the program ends.</p>

<p>Simple script:</p>

<pre><code>import cv2

vc = cv2.VideoCapture(1)
while True:
    _, frame = vc.read()
    cv2.imshow('Web cam', frame)

    if cv2.waitKey(1) &amp; 0xFF == ord('q'):
        break

vc.release()
cv2.destroyAllWindows()
</code></pre>

<p>Everything works well when I connect the webcam to my laptop and I run the script - I see the camera image. When I stop the capturing loop by pressing 'q' key I would suppose that the <code>vc.release()</code> command releases the camera from the use. But after this first run I cannot run the script again, because this time I get the error message:</p>

<pre><code>OpenCV Error: Assertion failed (size.width&gt;0 &amp;&amp; size.height&gt;0) in cv::imshow, file ..\..\..\..\opencv\modules\highgui\src\window.cpp, line 261
Traceback (most recent call last):
  File ".../sample.py", line 8, in &lt;module&gt;
    cv2.imshow('Web cam', frame)
cv2.error: ..\..\..\..\opencv\modules\highgui\src\window.cpp:261: error: (-215) size.width&gt;0 &amp;&amp; size.height&gt;0 in function cv::imshow
</code></pre>

<p>I am pretty sure that some process is still holding my webcam. I also cannot connect to this webcam in this time from any other program (I tried Skype). And I also get the same error when I connect the webcam to the laptop, connect to the webcam via Skype and run the script above.</p>

<p>How can I release my webcam for future use?</p>

<p>It seems there really probably was some (for me hidden) process, what still held the camera. When I shut down my laptop and turn it back on everything works fine.</p>

python opencv webcam