title: Reduce brigthness in real time OpenCv Python
body: <p>I am looking around how to reduce the brightness of the webcam image.
  Can you tell me how to do it?</p>
  <p>I couldn't find anything ...</p>
  <p>To increase the value I use this function (I increase the brightness with a trackbar):</p>
  <pre><code>def change_brightness(frame, value):
      hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
      h, s, v = cv2.split(hsv)
  
      lim = 255 - value
      v[v &gt; lim] = 255
      v[v &lt;= lim] += value
  
      final_hsv = cv2.merge((h, s, v))
      img = cv2.cvtColor(final_hsv, cv2.COLOR_HSV2BGR)
      return img
  </code></pre>
  <p>This is the full code:</p>
  <pre><code>cv2.namedWindow(&quot;VIDEO&quot;)
  #cv2.createTrackbar(&quot;alpha&quot;, &quot;VIDEO&quot;, 0, 4, nothing)
  cv2.createTrackbar(&quot;gamma&quot;, &quot;VIDEO&quot;, 50, 100, nothing)
  while True:
          k = cv2.waitKey(1)
          _, frame = video.read()
          frame = cv2.resize(frame, FRAME_DIM)  # frame contiene l'immagine della webcam
          frame = cv2.flip(frame, 1) # giro orizzontalmente (parametro = 1) l'immagine
  
          #test = cv2.getTrackbarPos(&quot;alpha&quot;, &quot;VIDEO&quot;)
          test = cv2.getTrackbarPos(&quot;gamma&quot;, &quot;VIDEO&quot;)
          
          gamma = cv2.getTrackbarPos(&quot;gamma&quot;, &quot;VIDEO&quot;)
          frame = change_brightness(frame, gamma)
          if (k % 256 == ord(&quot;q&quot;)):  # PATH, folder_name, full_path, IMG_LABELquando premo &quot;q&quot; si chiude la webcam e la relativa finestra
              cv2.destroyAllWindows()
              break
          camera = cv2.imshow(&quot;VIDEO&quot;, frame)
  </code></pre>