title: Change the color of the cv2.rectangle
body: <p>I'm trying to make a color detection system where when I click on the window it tells the color. I'm now trying to make the color of the <code>cv2.rectangle</code> to change the color to what color I click on.</p>
  
  <p>This is what I have done so far</p>
  
  <pre><code>import cv2
  import webcolors
  from tkinter import *
  from PIL import Image
  from PIL import ImageTk
  from tkinter import filedialog
  import cv2
  # --- functions ---
  
  def closest_colour(requested_colour):
      global colorcode
      colorcode = requested_colour
      min_colours = {}
      for key, name in webcolors.css3_hex_to_names.items():
          r_c, g_c, b_c = webcolors.hex_to_rgb(key)
          rd = (r_c - requested_colour[0]) ** 2
          gd = (g_c - requested_colour[1]) ** 2
          bd = (b_c - requested_colour[2]) ** 2
          min_colours[(rd + gd + bd)] = name
      return min_colours[min(min_colours.keys())]
  
  def get_colour_name(requested_colour):
  
      try:
          closest_name = actual_name = webcolors.rgb_to_name(requested_colour)
      except ValueError:
          closest_name = closest_colour(requested_colour)
          actual_name = ""
      return actual_name, closest_name
  
  def click_event(event, x, y, flags, param):
      global closest_name, colour2 # inform function to assign to global/external variable instead of creating local one
  
      if event == cv2.EVENT_LBUTTONDOWN:
          B, G, R = frame[x, y]
          colour2 = (R, G, B)  # reverse values
          colour = frame[y,x][::-1] # reverse values
          actual_name, closest_name = get_colour_name(colour)
  
  
  font = cv2.FONT_HERSHEY_DUPLEX
  
  closest_name = '' # create global variable at start
  requested_colour = ''
  cap = cv2.VideoCapture(0);
  
  cv2.namedWindow('frame')
  cv2.setMouseCallback('frame', click_event)
  
  while True:
      ret, frame = cap.read()
  
      if closest_name:
          cv2.rectangle(frame, (600, 60), (0, 0), (224, 224, 224),cv2.FILLED)
          cv2.rectangle(frame, (10, 10), (100, 50), (colour2), -1)
          cv2.rectangle(frame, (10, 10), (100, 50), (0, 0, 0), 2)
  
          cv2.putText(frame, closest_name, (110, 40), font, 1, (0, 0, 0), 1)
  
  
      cv2.imshow('frame', frame)
      cv2.resizeWindow('frame', 500, 450)
  
      if cv2.waitKey(40) == 27:
          break
  
  </code></pre>
  
  <p>This is the error I'm getting</p>
  
  <blockquote>
    <p>Traceback (most recent call last):   File "C:/Users/Suhail
    Misbah/PycharmProjects/Color_Detection/colordetection.py", line 70, in
    
        cv2.rectangle(frame, (10, 10), (100, 50), (colour2), -1) TypeError: an integer is required (got type tuple)</p>
  </blockquote>