title: Double imshow in python script with opencv
body: <p>I have following code:</p>
  <pre><code>import numpy as np
  import cv2
  import pickle
  import rtsp
  import PIL as Image
  
  face_cascade = cv2.CascadeClassifier('cascades\data\haarcascade_frontalface_alt2.xml')
  recognizer = cv2.face.LBPHFaceRecognizer_create()
  recognizer.read(&quot;trainner.yml&quot;)
  
  labels = {&quot;person_name&quot;: 1}
  with open(&quot;labels.pickle&quot;, 'rb') as f:
      og_labels = pickle.load(f)
      labels = {v:k for k,v in og_labels.items()}
  
  url = 'rtsp://user:pass@xxx.xxx.x.xxx:YYYY/stream0/mobotix.mjpeg'
  with rtsp.Client(url) as client:
    client.preview()
    while True:
      frame = client.read(raw=True)
      gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
      faces = face_cascade.detectMultiScale(gray, scaleFactor=1.3, minNeighbors=5)
      for (x,y,w,h) in faces:
        print(x,y,w,h)
        roi_gray = gray[y:y+h, x:x+w]
        roi_color = frame[y:y+h, x:x+w]
          
        #recognize?
        id_, conf = recognizer.predict(roi_gray)
        if conf&gt;=45: # and conf &lt;=85:
          print(id_)
          print(labels[id_])
          font = cv2.FONT_HERSHEY_SIMPLEX
          name = labels[id_]
          color = (0,0,255)
          stroke = 2
          cv2.putText(frame, name, (x,y), font, 1, color, stroke, cv2.LINE_AA)
  
        #img_item = &quot;my-image.png&quot;
        #cv2.imwrite(img_item, roi_gray)
  
        color = (0, 0, 255)
        stroke = 2
        end_cord_x = x + w
        end_cord_y = y + h
        cv2.rectangle(frame, (x,y), (end_cord_x, end_cord_y), color, stroke)
  
      cv2.imshow('IP cam',frame)
     
      if cv2.waitKey(20) &amp; 0xFF == ord('q'):
          break
  
  cv2.destroyAllWindows()
  </code></pre>
  <p>Everything is working fine, I'm running my code and first it's opening the Cam view of &quot;client.preview&quot;, face detection is not working at this time. When I close this one, the IPcam windows opens and everything is working. (I'm still getting a lot of missed frames by the RTSP stream but no direct issue).</p>
  <p>If I leave the code &quot;client.preview&quot; out of it, I'm getting an error from opencv because of src_empty.
  If I try to change the code to &quot;client.read()&quot; idem an error occurs from opencv because of src_empty.</p>
  <p>How should I fix this?</p>