title: opencv traffic light detection
body: <pre><code>import cv2 
  import numpy as np
  
  import warnings
  warnings.filterwarnings(&quot;ignore&quot;)
  
  cap = cv2.VideoCapture(0)
  
  while True :
      ret ,frame = cap.read()
      
      hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
      
      lower_yellow = np.array([20,0,0])
      upper_yellow = np.array([40,255,255])
      
      mask = cv2.inRange(hsv, lower_yellow, upper_yellow)
      res = cv2.bitwise_and(frame,frame, mask= mask)
      
      img = cv2.medianBlur(res, 5)
      ccimg = cv2.cvtColor(img, cv2.COLOR_HSV2BGR)
      cimg = cv2.cvtColor(ccimg, cv2.COLOR_BGR2GRAY)
      circles = cv2.HoughCircles(cimg, cv2.HOUGH_GRADIENT, 1, 20,param1=50, param2=30, minRadius=20, maxRadius=30)
      if circles is not None:
          print(&quot;circle is found&quot;)
          circles = np.uint16(np.around(circles))
          for i in circles[0, :]:
                  cv2.circle(cimg, (i[0], i[1]), i[2], (0, 255, 0), 2)
                  cv2.circle(cimg, (i[0], i[1]), 2, (0, 0, 255), 3)
      cv2.imshow('detected circles', cimg)
      cv2.imshow('res',res)
        
      if cv2.waitKey(1) &amp; 0xFF == ord(&quot;q&quot;):
          break
  cv2.destroyAllWindows()
  </code></pre>
  <p>I am tring to detect trafict light by using opencv , initially i want to detect yellow color by using HSV space and then median filtering and finding the circle but it raises errors <code>async ReadSample() call is failed with error status: -1072873821</code> and <code>OnReadSample() is called with error status: -1072873821 </code> probably errors are caused by the if state for checking if it finds any circle or not also the error is a long list but these two are repeated.</p>