title: Python opencv security camera window crashs
body: <p>I am trying to write a program with python using opencv library to create a security camera that detect faces and movements.</p>
  <p>CODE :</p>
  <pre><code>import cv2
  import time
  import datetime
  
  cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
  
  while True:
      _, frame = cap.read()
  
      cv2.imshow(&quot;Security Camera&quot;, frame)
  
      if cv2.waitKey(1) == ord('q'):
          break
      
      cap.release()
      cv2.destroyAllWindows()
  </code></pre>
  <p>When i try to run the code i get this error message after the camera window opens and crashes within a second :</p>
  <p>ERROR MESSAGE :</p>
  <blockquote>
  <p>C:/Users/DELL/AppData/Local/Programs/Python/Python39/python.exe
  e:/coding/python/cv2-sec/main.py Traceback (most recent call last):<br />
  File &quot;e:\coding\python\cv2-sec\main.py&quot;, line 10, in 
  cv2.imshow(&quot;Security Camera&quot;, frame) cv2.error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-sn_xpupm\opencv\modules\imgproc\src\color.cpp:182:
  error: (-215:Assertion failed) !_src.empty() in function
  'cv::cvtColor'</p>
  </blockquote>
  <p>I tried all possible solutions available online with no luck.
  please support if possible.
  thnx.</p>