title: cv2.putText text stays in image after next cv2.read
body: <p>I am working on some code for my master thesis. There are two threads, one does cv2.VideoCapture(), sets the ready Event(), in the second thread while loop waits for the event to be set and then does some image processing. Typical producer, consumer problem.</p>
  <p>The problem is, that I am trying to create &quot;model&quot; of the scene, where I would update pixels only in areas without red circle, which i am using as a marker to detect position of an object. I need to remember part of image behind the red marker and then update area everywhere else.</p>
  <p>The problem is, that i need to mark the center of the red circle. I use the cv2.circle(). Black dot somehow gets in the model, even though I have never put it there. The cv2.putText() function has the same problem. The code looks like this.</p>
  <pre><code>if __name__ == &quot;__main__&quot;:
      ready = Event()
      vs = VideoStream(0, ready).start()
      v = Vision(vs.read())
      cv2.imshow('firework', v.getImg())
  
      while cv2.getWindowProperty('firework', cv2.WND_PROP_VISIBLE) &gt;= 1: 
          # data acquisition
          while not ready.isSet():
              pass
          img = vs.read()
          ready.clear()
  
          # image processing
          v.updateImg(img)
          v.detectRedMarker() # set cX, cY
          mask = v.getROIMask(radius=100)
          v.updateModel(mask) # circle mask, center cX, cY
  
          # extras
          img = v.putMarkerToImg(img)
          cv2.imshow('firework', img)
  
          if cv2.waitKey(1) == ord(' '):
              break
      vs.stop()
  </code></pre>
  <p>Methods in the Vision class...</p>
  <pre><code>def updateImg(self, img):
      self.img = img
      self.imgGray = cv2.cvtColor(self.img,cv2.COLOR_BGR2GRAY)
      return
  
  def getROIMask(self,radius):
      mask = np.zeros((self.imgHeight, self.imgWidth),np.uint8)
      cv2.circle(mask, (self.cX, self.cY), radius, 1, thickness=-1)
      return mask
  
  def updateModel(self,mask):
      modelUpdate = cv2.bitwise_and(self.imgGray, cv2.bitwise_not(mask*255))
      modelOld = cv2.bitwise_and(self.model, (mask*255))
      self.model = cv2.add(modelOld,modelUpdate)
      return
  </code></pre>
  <p>As you can see, I put the dot in the center of the red marker after i update the model and then read new image in the next iteration. Somehow the black dot gets into the model. Can anyone please suggest how does this happen?</p>
  <p><a href="https://i.stack.imgur.com/hn4aU.png" rel="nofollow noreferrer">Black dot marking the center of red circle somehow gets into the model</a></p>