Code in Python:

#importing libraries
import cv2
import numpy as np

def calledFunction():
    pass

img = np.zeros((1024,512,3),np.uint8);
winName = 'Colour Palette';
cv2.namedWindow(winName);
    
#add Blue Green Red trackbar
cv2.createTrackbar('Blue',winName,0,255,calledFunction);
cv2.createTrackbar('Green',winName,0,255,calledFunction);
cv2.createTrackbar('Red',winName,0,255,calledFunction);
    
while(True):
    cv2.imshow(winName,img);
    
    # Wait for Esc key to stop 
    if cv2.waitKey(1) == 27:
        break;
    Blue = cv2.getTrackbarPos('Blue',winName);
    Green = cv2.getTrackbarPos('Green',winName);
    Red = cv2.getTrackbarPos('Red',winName);
    
    img[:]=[Blue,Green,Red];
#destroy all windows
cv2.destroyAllWindows();

OUTPUT:

Thank you Rishika Gupta for this article.


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Insert math as
Block
Inline
Additional settings
Formula color
Text color
#333333
Type math using LaTeX
Preview
\({}\)
Nothing to preview
Insert